diff --git a/src/connection/handshake.rs b/src/connection/handshake.rs index 86febba..83ef0c4 100644 --- a/src/connection/handshake.rs +++ b/src/connection/handshake.rs @@ -3,11 +3,10 @@ use std::{str::FromStr, sync::atomic::Ordering}; use anyhow::Error; use semver::Version; -use crate::model::authenticated::MessageHandler; use crate::{ connection::ConnectionError, - handshake::{HandshakeFinalize, HandshakeResponse, InitiateHandshake}, - model::authenticated::{AuthenticatedInstance, Message, NetworkMessage, State}, + messages::handshake::{HandshakeFinalize, HandshakeResponse, InitiateHandshake}, + model::authenticated::{AuthenticatedInstance, Message, MessageHandler, NetworkMessage, State}, validate_version, }; diff --git a/src/handshake.rs b/src/handshake.rs deleted file mode 100644 index 15637ee..0000000 --- a/src/handshake.rs +++ /dev/null @@ -1,29 +0,0 @@ -use semver::Version; -use serde::{Deserialize, Serialize}; - -use crate::model::instance::Instance; - -/// Sent by the initiator of a new inter-daemon connection. -#[derive(Clone, Serialize, Deserialize)] -pub struct InitiateHandshake { - pub version: Version, -} - -/// Sent in response to [`InitiateHandshake`] -#[derive(Clone, Serialize, Deserialize)] -pub struct HandshakeResponse { - pub identity: Instance, - pub version: Version, -} - -#[derive(Clone, Serialize, Deserialize)] -pub struct HandshakeFinalize { - pub success: bool, -} - -#[derive(Clone, Serialize, Deserialize)] -pub enum HandshakeMessage { - Initiate(InitiateHandshake), - Response(HandshakeResponse), - Finalize(HandshakeFinalize), -} diff --git a/src/lib.rs b/src/lib.rs index 4baf7fa..9c1400e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,6 @@ use semver::{Version, VersionReq}; pub mod authentication; pub mod backend; pub mod connection; -pub mod handshake; pub mod messages; pub mod model; diff --git a/src/messages/handshake.rs b/src/messages/handshake.rs new file mode 100644 index 0000000..e62f3ad --- /dev/null +++ b/src/messages/handshake.rs @@ -0,0 +1,22 @@ +use semver::Version; +use serde::{Deserialize, Serialize}; + +use crate::model::instance::Instance; + +/// Sent by the initiator of a new inter-daemon connection. +#[derive(Clone, Serialize, Deserialize)] +pub struct InitiateHandshake { + pub version: Version, +} + +/// Sent in response to [`InitiateHandshake`] +#[derive(Clone, Serialize, Deserialize)] +pub struct HandshakeResponse { + pub identity: Instance, + pub version: Version, +} + +#[derive(Clone, Serialize, Deserialize)] +pub struct HandshakeFinalize { + pub success: bool, +} diff --git a/src/messages/mod.rs b/src/messages/mod.rs index b19d96e..6e31b47 100644 --- a/src/messages/mod.rs +++ b/src/messages/mod.rs @@ -5,6 +5,7 @@ use crate::model::user::User; pub mod authentication; pub mod discovery; +pub mod handshake; pub mod issues; pub mod repository; pub mod user;