diff --git a/src/client.rs b/src/client.rs index 103e857..6ecd3a9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -12,7 +12,7 @@ use room; #[derive(Debug)] enum IncomingMessage { ServerResponse(ServerResponse), - ControlRequest(control::ControlRequest), + ControlRequest(control::Request), } #[derive(Debug, Clone)] @@ -26,8 +26,8 @@ pub struct Client { proto_tx: mio::Sender, proto_rx: mpsc::Receiver, - control_tx: mpsc::Sender, - control_rx: mpsc::Receiver, + control_tx: mpsc::Sender, + control_rx: mpsc::Receiver, login_status: LoginStatus, @@ -39,8 +39,8 @@ impl Client { pub fn new( proto_tx: mio::Sender, proto_rx: mpsc::Receiver, - control_tx: mpsc::Sender, - control_rx: mpsc::Receiver) + control_tx: mpsc::Sender, + control_rx: mpsc::Receiver) -> Self { Client { @@ -92,9 +92,9 @@ impl Client { } } - fn handle_control_request(&mut self, request: control::ControlRequest) { + fn handle_control_request(&mut self, request: control::Request) { match request { - control::ControlRequest::LoginStatusRequest => + control::Request::LoginStatusRequest => self.handle_login_status_request(), _ =>{ @@ -123,7 +123,7 @@ impl Client { }, }; debug!("Sending control response: {:?}", response); - self.control_tx.send(control::ControlResponse::LoginStatusResponse(response)); + self.control_tx.send(control::Response::LoginStatusResponse(response)); } fn handle_server_response(&mut self, response: ServerResponse) { diff --git a/src/control/controller.rs b/src/control/controller.rs index d1336cb..384a8bf 100644 --- a/src/control/controller.rs +++ b/src/control/controller.rs @@ -28,7 +28,7 @@ enum Error { IOError(io::Error), JSONEncoderError(json::EncoderError), JSONDecoderError(json::DecoderError), - SendError(mpsc::SendError), + SendError(mpsc::SendError), Utf8Error(str::Utf8Error), WebSocketError(websocket::result::WebSocketError), } @@ -70,8 +70,8 @@ impl From for Error { } } -impl From> for Error { - fn from(err: mpsc::SendError) -> Self { +impl From> for Error { + fn from(err: mpsc::SendError) -> Self { Error::SendError(err) } } @@ -89,13 +89,13 @@ impl From for Error { } pub struct Controller { - client_tx: mpsc::Sender, - client_rx: mpsc::Receiver, + client_tx: mpsc::Sender, + client_rx: mpsc::Receiver, } impl Controller { - pub fn new(tx: mpsc::Sender, - rx: mpsc::Receiver) + pub fn new(tx: mpsc::Sender, + rx: mpsc::Receiver) -> Self { Controller { @@ -150,7 +150,7 @@ impl Controller { fn receiver_loop( mut receiver: WebSocketReceiver, - client_tx: mpsc::Sender, + client_tx: mpsc::Sender, sender_tx: mpsc::Sender<()>) { for message_result in receiver.incoming_messages() { @@ -186,7 +186,7 @@ impl Controller { fn handle_text_message( payload_bytes: &[u8], - client_tx: &mpsc::Sender) + client_tx: &mpsc::Sender) -> Result<(), Error> { let payload = try!(str::from_utf8(payload_bytes)); @@ -197,7 +197,7 @@ impl Controller { fn sender_loop( mut sender: WebSocketSender, - client_rx: &mut mpsc::Receiver, + client_rx: &mut mpsc::Receiver, sender_rx: mpsc::Receiver<()>) { loop { @@ -224,7 +224,7 @@ impl Controller { sender.shutdown_all().unwrap(); } - fn send_response(sender: &mut WebSocketSender, response: ControlResponse) + fn send_response(sender: &mut WebSocketSender, response: Response) -> Result<(), Error> { let encoded = try!(json::encode(&response)); diff --git a/src/control/request.rs b/src/control/request.rs index ba309e1..885a175 100644 --- a/src/control/request.rs +++ b/src/control/request.rs @@ -1,5 +1,5 @@ #[derive(Debug, RustcDecodable, RustcEncodable)] -pub enum ControlRequest { +pub enum Request { LoginStatusRequest, RoomListRequest, } diff --git a/src/control/response.rs b/src/control/response.rs index 4f1b6ca..067f139 100644 --- a/src/control/response.rs +++ b/src/control/response.rs @@ -1,7 +1,7 @@ use room; #[derive(Debug, RustcDecodable, RustcEncodable)] -pub enum ControlResponse { +pub enum Response { LoginStatusResponse(LoginStatusResponse), RoomListResponse(RoomListResponse), }