diff --git a/src/client.rs b/src/client.rs index a5a221a..c7224ca 100644 --- a/src/client.rs +++ b/src/client.rs @@ -16,17 +16,23 @@ use crate::user; #[derive(Debug)] enum IncomingMessage { Proto(proto::Response), + + #[allow(dead_code)] ControlNotification(control::Notification), } #[derive(Debug)] enum PeerState { /// We are trying to establish a direct connection. + #[allow(dead_code)] Opening, + /// We are trying to establish a reverse connection. OpeningFirewalled, + /// We are waiting for a reverse connection to be established to us. WaitingFirewalled, + /// The connection is open. Open, } @@ -42,10 +48,13 @@ struct Peer { } pub struct Client { + #[allow(deprecated)] proto_tx: mio::deprecated::Sender, proto_rx: crossbeam_channel::Receiver, control_tx: Option, + + #[allow(dead_code)] control_rx: crossbeam_channel::Receiver, login_status: LoginStatus, @@ -60,6 +69,7 @@ impl Client { /// Returns a new client that will communicate with the protocol agent /// through `proto_tx` and `proto_rx`, and with the controller agent /// through `control_rx`. + #[allow(deprecated)] pub fn new( proto_tx: mio::deprecated::Sender, proto_rx: crossbeam_channel::Receiver, @@ -121,6 +131,7 @@ impl Client { /// Send a request to the server. fn send_to_server(&self, request: server::ServerRequest) { + #[allow(deprecated)] self.proto_tx .send(proto::Request::ServerRequest(request)) .unwrap(); @@ -128,6 +139,7 @@ impl Client { /// Send a message to a peer. fn send_to_peer(&self, peer_id: usize, message: peer::Message) { + #[allow(deprecated)] self.proto_tx .send(proto::Request::PeerMessage(peer_id, message)) .unwrap(); @@ -135,6 +147,7 @@ impl Client { /// Send a response to the controller client. fn send_to_controller(&mut self, response: control::Response) { + #[allow(deprecated)] let result = match self.control_tx { None => { // Silently drop control requests when controller is @@ -347,6 +360,7 @@ impl Client { let peer = occupied_entry.get_mut(); peer.state = PeerState::WaitingFirewalled; + #[allow(deprecated)] self.proto_tx .send(proto::Request::ServerRequest( server::ServerRequest::ConnectToPeerRequest(server::ConnectToPeerRequest { @@ -365,6 +379,7 @@ impl Client { ); let (peer, _) = occupied_entry.remove(); + #[allow(deprecated)] self.proto_tx .send(proto::Request::ServerRequest( server::ServerRequest::CannotConnectRequest(server::CannotConnectRequest { @@ -522,6 +537,7 @@ impl Client { "Opening peer connection {} to {}:{} to pierce firewall", peer_id, response.ip, response.port ); + #[allow(deprecated)] self.proto_tx .send(proto::Request::PeerConnect( peer_id, diff --git a/src/control/ws.rs b/src/control/ws.rs index c85e6bc..d983191 100644 --- a/src/control/ws.rs +++ b/src/control/ws.rs @@ -51,7 +51,7 @@ impl error::Error for SendError { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { SendError::JSONEncoderError(ref err) => Some(err), SendError::WebSocketError(ref err) => Some(err), diff --git a/src/handlers/login_handler.rs b/src/handlers/login_handler.rs index 2051f82..3913805 100644 --- a/src/handlers/login_handler.rs +++ b/src/handlers/login_handler.rs @@ -9,7 +9,7 @@ use crate::proto::server::LoginResponse; pub struct LoginHandler; impl MessageHandler for LoginHandler { - fn run(self, context: &Context, message: &LoginResponse) -> io::Result<()> { + fn run(self, context: &Context, _message: &LoginResponse) -> io::Result<()> { let lock = context.login.lock(); match *lock { diff --git a/src/message_handler.rs b/src/message_handler.rs index d0b2c49..be2543c 100644 --- a/src/message_handler.rs +++ b/src/message_handler.rs @@ -1,4 +1,3 @@ -use std::fmt::Debug; use std::io; use crate::context::Context; diff --git a/src/proto/handler.rs b/src/proto/handler.rs index 04c9c21..774d21a 100644 --- a/src/proto/handler.rs +++ b/src/proto/handler.rs @@ -116,6 +116,7 @@ where } impl Handler { + #[allow(deprecated)] fn new( client_tx: crossbeam_channel::Sender, event_loop: &mut mio::deprecated::EventLoop, @@ -158,6 +159,7 @@ impl Handler { }) } + #[allow(deprecated)] fn connect_to_peer( &mut self, peer_id: usize, @@ -202,6 +204,7 @@ impl Handler { Ok(()) } + #[allow(deprecated)] fn process_server_intent( &mut self, intent: Intent, @@ -225,6 +228,7 @@ impl Handler { } } + #[allow(deprecated)] fn process_peer_intent( &mut self, intent: Intent, @@ -255,6 +259,7 @@ impl Handler { } } +#[allow(deprecated)] impl mio::deprecated::Handler for Handler { type Timeout = (); type Message = Request; @@ -342,9 +347,11 @@ impl mio::deprecated::Handler for Handler { } } +#[allow(deprecated)] pub type Sender = mio::deprecated::Sender; pub struct Agent { + #[allow(deprecated)] event_loop: mio::deprecated::EventLoop, handler: Handler, } @@ -352,6 +359,7 @@ pub struct Agent { impl Agent { pub fn new(client_tx: crossbeam_channel::Sender) -> io::Result { // Create the event loop. + #[allow(deprecated)] let mut event_loop = mio::deprecated::EventLoop::new()?; // Create the handler for the event loop and register the handler's // sockets with the event loop. @@ -364,10 +372,12 @@ impl Agent { } pub fn channel(&self) -> Sender { + #[allow(deprecated)] self.event_loop.channel() } pub fn run(&mut self) -> io::Result<()> { + #[allow(deprecated)] self.event_loop.run(&mut self.handler) } } diff --git a/src/proto/packet.rs b/src/proto/packet.rs index d4e9417..9317728 100644 --- a/src/proto/packet.rs +++ b/src/proto/packet.rs @@ -8,6 +8,7 @@ use std::net; use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt}; use encoding::all::ISO_8859_1; use encoding::{DecoderTrap, EncoderTrap, Encoding}; +#[allow(deprecated)] use mio::deprecated::TryRead; use super::constants::*; @@ -155,7 +156,7 @@ impl error::Error for PacketReadError { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { PacketReadError::InvalidBoolError(_) => None, PacketReadError::InvalidU16Error(_) => None, @@ -361,6 +362,8 @@ impl Parser { // Try to read as many bytes as we currently need from the underlying // byte stream. let offset = self.buffer.len() - self.num_bytes_left; + + #[allow(deprecated)] match stream.try_read(&mut self.buffer[offset..])? { None => (), diff --git a/src/proto/peer/message.rs b/src/proto/peer/message.rs index c26fae2..243fd43 100644 --- a/src/proto/peer/message.rs +++ b/src/proto/peer/message.rs @@ -155,8 +155,6 @@ impl ValueDecode for PeerInit { #[cfg(test)] mod tests { - use std::io; - use bytes::BytesMut; use crate::proto::value_codec::tests::roundtrip; diff --git a/src/proto/server/request.rs b/src/proto/server/request.rs index f15832c..f1b1182 100644 --- a/src/proto/server/request.rs +++ b/src/proto/server/request.rs @@ -586,8 +586,6 @@ impl ValueDecode for UserStatusRequest { #[cfg(test)] mod tests { - use std::io; - use bytes::BytesMut; use crate::proto::value_codec::tests::roundtrip; diff --git a/src/proto/server/response.rs b/src/proto/server/response.rs index 8cd1a7d..3c7c8e3 100644 --- a/src/proto/server/response.rs +++ b/src/proto/server/response.rs @@ -1,4 +1,3 @@ -use std::io; use std::net; use crate::proto::packet::{Packet, PacketReadError, ReadFromPacket}; @@ -1337,7 +1336,6 @@ impl ValueDecode for WishlistIntervalResponse { #[cfg(test)] mod tests { - use std::io; use std::net; use bytes::BytesMut; diff --git a/src/proto/stream.rs b/src/proto/stream.rs index bd33e1a..8d75a87 100644 --- a/src/proto/stream.rs +++ b/src/proto/stream.rs @@ -39,6 +39,7 @@ impl OutBuf { self.remaining() > 0 } + #[allow(deprecated)] fn try_write_to(&mut self, mut writer: T) -> io::Result> where T: mio::deprecated::TryWrite, @@ -167,6 +168,7 @@ impl Stream { /// The stream is ready to read, write, or both. pub fn on_ready(&mut self, event_set: mio::Ready) -> Intent { + #[allow(deprecated)] if event_set.is_hup() || event_set.is_error() { return Intent::Done; } @@ -198,6 +200,7 @@ impl Stream { } // We're always interested in reading more. + #[allow(deprecated)] let mut event_set = mio::Ready::readable() | mio::Ready::hup() | mio::Ready::error(); // If there is still stuff to write in the queue, we're interested in // the socket becoming writable too. diff --git a/src/proto/value_codec.rs b/src/proto/value_codec.rs index dd8b939..fc23ae7 100644 --- a/src/proto/value_codec.rs +++ b/src/proto/value_codec.rs @@ -465,7 +465,6 @@ impl ValueEncode for Vec { #[cfg(test)] pub mod tests { use std::fmt; - use std::io; use std::net; use std::u16; use std::u32;