diff --git a/src/client.rs b/src/client.rs index 0cd263b..f5ff448 100644 --- a/src/client.rs +++ b/src/client.rs @@ -6,6 +6,7 @@ use slab; use crate::config; use crate::control; +use crate::login::LoginStatus; use crate::proto; use crate::proto::peer; use crate::proto::server; @@ -18,13 +19,6 @@ enum IncomingMessage { ControlNotification(control::Notification), } -#[derive(Clone, Debug)] -enum LoginStatus { - Pending, - Success(String), - Failure(String), -} - #[derive(Debug)] enum PeerState { /// We are trying to establish a direct connection. diff --git a/src/login.rs b/src/login.rs new file mode 100644 index 0000000..14fba48 --- /dev/null +++ b/src/login.rs @@ -0,0 +1,22 @@ +/// Represents the status of the login operation. +/// +/// In order to interact with the server, a client cannot simply open a network +/// connection. Instead, it must send a login request with basic credentials. +/// The server is supposed the respond with a success or error message. Once +/// successfully logged in, the client can interact with the server. +#[derive(Clone, Debug)] +pub enum LoginStatus { + // TODO: add a state representing the fact that no request has been sent. + + /// Sent request, awaiting response. + Pending, + + /// Logged in. + /// Stores the MOTD as received from the server. + Success(String), + + /// Failed to log in. + /// Stores the error message as received from the server. + Failure(String), +} + diff --git a/src/main.rs b/src/main.rs index 1a6ad35..735065a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ mod control; mod dispatcher; mod executor; mod handlers; +mod login; mod message_handler; mod proto; mod room;