Browse Source

Squash a bunch of warnings with allow attributes.

wip
Titouan Rigoudy 4 years ago
parent
commit
e8b2b47aed
11 changed files with 35 additions and 11 deletions
  1. +16
    -0
      src/client.rs
  2. +1
    -1
      src/control/ws.rs
  3. +1
    -1
      src/handlers/login_handler.rs
  4. +0
    -1
      src/message_handler.rs
  5. +10
    -0
      src/proto/handler.rs
  6. +4
    -1
      src/proto/packet.rs
  7. +0
    -2
      src/proto/peer/message.rs
  8. +0
    -2
      src/proto/server/request.rs
  9. +0
    -2
      src/proto/server/response.rs
  10. +3
    -0
      src/proto/stream.rs
  11. +0
    -1
      src/proto/value_codec.rs

+ 16
- 0
src/client.rs View File

@ -16,17 +16,23 @@ use crate::user;
#[derive(Debug)] #[derive(Debug)]
enum IncomingMessage { enum IncomingMessage {
Proto(proto::Response), Proto(proto::Response),
#[allow(dead_code)]
ControlNotification(control::Notification), ControlNotification(control::Notification),
} }
#[derive(Debug)] #[derive(Debug)]
enum PeerState { enum PeerState {
/// We are trying to establish a direct connection. /// We are trying to establish a direct connection.
#[allow(dead_code)]
Opening, Opening,
/// We are trying to establish a reverse connection. /// We are trying to establish a reverse connection.
OpeningFirewalled, OpeningFirewalled,
/// We are waiting for a reverse connection to be established to us. /// We are waiting for a reverse connection to be established to us.
WaitingFirewalled, WaitingFirewalled,
/// The connection is open. /// The connection is open.
Open, Open,
} }
@ -42,10 +48,13 @@ struct Peer {
} }
pub struct Client { pub struct Client {
#[allow(deprecated)]
proto_tx: mio::deprecated::Sender<proto::Request>, proto_tx: mio::deprecated::Sender<proto::Request>,
proto_rx: crossbeam_channel::Receiver<proto::Response>, proto_rx: crossbeam_channel::Receiver<proto::Response>,
control_tx: Option<control::Sender>, control_tx: Option<control::Sender>,
#[allow(dead_code)]
control_rx: crossbeam_channel::Receiver<control::Notification>, control_rx: crossbeam_channel::Receiver<control::Notification>,
login_status: LoginStatus, login_status: LoginStatus,
@ -60,6 +69,7 @@ impl Client {
/// Returns a new client that will communicate with the protocol agent /// Returns a new client that will communicate with the protocol agent
/// through `proto_tx` and `proto_rx`, and with the controller agent /// through `proto_tx` and `proto_rx`, and with the controller agent
/// through `control_rx`. /// through `control_rx`.
#[allow(deprecated)]
pub fn new( pub fn new(
proto_tx: mio::deprecated::Sender<proto::Request>, proto_tx: mio::deprecated::Sender<proto::Request>,
proto_rx: crossbeam_channel::Receiver<proto::Response>, proto_rx: crossbeam_channel::Receiver<proto::Response>,
@ -121,6 +131,7 @@ impl Client {
/// Send a request to the server. /// Send a request to the server.
fn send_to_server(&self, request: server::ServerRequest) { fn send_to_server(&self, request: server::ServerRequest) {
#[allow(deprecated)]
self.proto_tx self.proto_tx
.send(proto::Request::ServerRequest(request)) .send(proto::Request::ServerRequest(request))
.unwrap(); .unwrap();
@ -128,6 +139,7 @@ impl Client {
/// Send a message to a peer. /// Send a message to a peer.
fn send_to_peer(&self, peer_id: usize, message: peer::Message) { fn send_to_peer(&self, peer_id: usize, message: peer::Message) {
#[allow(deprecated)]
self.proto_tx self.proto_tx
.send(proto::Request::PeerMessage(peer_id, message)) .send(proto::Request::PeerMessage(peer_id, message))
.unwrap(); .unwrap();
@ -135,6 +147,7 @@ impl Client {
/// Send a response to the controller client. /// Send a response to the controller client.
fn send_to_controller(&mut self, response: control::Response) { fn send_to_controller(&mut self, response: control::Response) {
#[allow(deprecated)]
let result = match self.control_tx { let result = match self.control_tx {
None => { None => {
// Silently drop control requests when controller is // Silently drop control requests when controller is
@ -347,6 +360,7 @@ impl Client {
let peer = occupied_entry.get_mut(); let peer = occupied_entry.get_mut();
peer.state = PeerState::WaitingFirewalled; peer.state = PeerState::WaitingFirewalled;
#[allow(deprecated)]
self.proto_tx self.proto_tx
.send(proto::Request::ServerRequest( .send(proto::Request::ServerRequest(
server::ServerRequest::ConnectToPeerRequest(server::ConnectToPeerRequest { server::ServerRequest::ConnectToPeerRequest(server::ConnectToPeerRequest {
@ -365,6 +379,7 @@ impl Client {
); );
let (peer, _) = occupied_entry.remove(); let (peer, _) = occupied_entry.remove();
#[allow(deprecated)]
self.proto_tx self.proto_tx
.send(proto::Request::ServerRequest( .send(proto::Request::ServerRequest(
server::ServerRequest::CannotConnectRequest(server::CannotConnectRequest { server::ServerRequest::CannotConnectRequest(server::CannotConnectRequest {
@ -522,6 +537,7 @@ impl Client {
"Opening peer connection {} to {}:{} to pierce firewall", "Opening peer connection {} to {}:{} to pierce firewall",
peer_id, response.ip, response.port peer_id, response.ip, response.port
); );
#[allow(deprecated)]
self.proto_tx self.proto_tx
.send(proto::Request::PeerConnect( .send(proto::Request::PeerConnect(
peer_id, peer_id,


+ 1
- 1
src/control/ws.rs View File

@ -51,7 +51,7 @@ impl error::Error for SendError {
} }
} }
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self { match *self {
SendError::JSONEncoderError(ref err) => Some(err), SendError::JSONEncoderError(ref err) => Some(err),
SendError::WebSocketError(ref err) => Some(err), SendError::WebSocketError(ref err) => Some(err),


+ 1
- 1
src/handlers/login_handler.rs View File

@ -9,7 +9,7 @@ use crate::proto::server::LoginResponse;
pub struct LoginHandler; pub struct LoginHandler;
impl MessageHandler<LoginResponse> for LoginHandler { impl MessageHandler<LoginResponse> 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(); let lock = context.login.lock();
match *lock { match *lock {


+ 0
- 1
src/message_handler.rs View File

@ -1,4 +1,3 @@
use std::fmt::Debug;
use std::io; use std::io;
use crate::context::Context; use crate::context::Context;


+ 10
- 0
src/proto/handler.rs View File

@ -116,6 +116,7 @@ where
} }
impl Handler { impl Handler {
#[allow(deprecated)]
fn new( fn new(
client_tx: crossbeam_channel::Sender<Response>, client_tx: crossbeam_channel::Sender<Response>,
event_loop: &mut mio::deprecated::EventLoop<Self>, event_loop: &mut mio::deprecated::EventLoop<Self>,
@ -158,6 +159,7 @@ impl Handler {
}) })
} }
#[allow(deprecated)]
fn connect_to_peer( fn connect_to_peer(
&mut self, &mut self,
peer_id: usize, peer_id: usize,
@ -202,6 +204,7 @@ impl Handler {
Ok(()) Ok(())
} }
#[allow(deprecated)]
fn process_server_intent( fn process_server_intent(
&mut self, &mut self,
intent: Intent, intent: Intent,
@ -225,6 +228,7 @@ impl Handler {
} }
} }
#[allow(deprecated)]
fn process_peer_intent( fn process_peer_intent(
&mut self, &mut self,
intent: Intent, intent: Intent,
@ -255,6 +259,7 @@ impl Handler {
} }
} }
#[allow(deprecated)]
impl mio::deprecated::Handler for Handler { impl mio::deprecated::Handler for Handler {
type Timeout = (); type Timeout = ();
type Message = Request; type Message = Request;
@ -342,9 +347,11 @@ impl mio::deprecated::Handler for Handler {
} }
} }
#[allow(deprecated)]
pub type Sender = mio::deprecated::Sender<Request>; pub type Sender = mio::deprecated::Sender<Request>;
pub struct Agent { pub struct Agent {
#[allow(deprecated)]
event_loop: mio::deprecated::EventLoop<Handler>, event_loop: mio::deprecated::EventLoop<Handler>,
handler: Handler, handler: Handler,
} }
@ -352,6 +359,7 @@ pub struct Agent {
impl Agent { impl Agent {
pub fn new(client_tx: crossbeam_channel::Sender<Response>) -> io::Result<Self> { pub fn new(client_tx: crossbeam_channel::Sender<Response>) -> io::Result<Self> {
// Create the event loop. // Create the event loop.
#[allow(deprecated)]
let mut event_loop = mio::deprecated::EventLoop::new()?; let mut event_loop = mio::deprecated::EventLoop::new()?;
// Create the handler for the event loop and register the handler's // Create the handler for the event loop and register the handler's
// sockets with the event loop. // sockets with the event loop.
@ -364,10 +372,12 @@ impl Agent {
} }
pub fn channel(&self) -> Sender { pub fn channel(&self) -> Sender {
#[allow(deprecated)]
self.event_loop.channel() self.event_loop.channel()
} }
pub fn run(&mut self) -> io::Result<()> { pub fn run(&mut self) -> io::Result<()> {
#[allow(deprecated)]
self.event_loop.run(&mut self.handler) self.event_loop.run(&mut self.handler)
} }
} }

+ 4
- 1
src/proto/packet.rs View File

@ -8,6 +8,7 @@ use std::net;
use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt};
use encoding::all::ISO_8859_1; use encoding::all::ISO_8859_1;
use encoding::{DecoderTrap, EncoderTrap, Encoding}; use encoding::{DecoderTrap, EncoderTrap, Encoding};
#[allow(deprecated)]
use mio::deprecated::TryRead; use mio::deprecated::TryRead;
use super::constants::*; 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 { match *self {
PacketReadError::InvalidBoolError(_) => None, PacketReadError::InvalidBoolError(_) => None,
PacketReadError::InvalidU16Error(_) => None, PacketReadError::InvalidU16Error(_) => None,
@ -361,6 +362,8 @@ impl Parser {
// Try to read as many bytes as we currently need from the underlying // Try to read as many bytes as we currently need from the underlying
// byte stream. // byte stream.
let offset = self.buffer.len() - self.num_bytes_left; let offset = self.buffer.len() - self.num_bytes_left;
#[allow(deprecated)]
match stream.try_read(&mut self.buffer[offset..])? { match stream.try_read(&mut self.buffer[offset..])? {
None => (), None => (),


+ 0
- 2
src/proto/peer/message.rs View File

@ -155,8 +155,6 @@ impl ValueDecode for PeerInit {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io;
use bytes::BytesMut; use bytes::BytesMut;
use crate::proto::value_codec::tests::roundtrip; use crate::proto::value_codec::tests::roundtrip;


+ 0
- 2
src/proto/server/request.rs View File

@ -586,8 +586,6 @@ impl ValueDecode for UserStatusRequest {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io;
use bytes::BytesMut; use bytes::BytesMut;
use crate::proto::value_codec::tests::roundtrip; use crate::proto::value_codec::tests::roundtrip;


+ 0
- 2
src/proto/server/response.rs View File

@ -1,4 +1,3 @@
use std::io;
use std::net; use std::net;
use crate::proto::packet::{Packet, PacketReadError, ReadFromPacket}; use crate::proto::packet::{Packet, PacketReadError, ReadFromPacket};
@ -1337,7 +1336,6 @@ impl ValueDecode for WishlistIntervalResponse {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::io;
use std::net; use std::net;
use bytes::BytesMut; use bytes::BytesMut;


+ 3
- 0
src/proto/stream.rs View File

@ -39,6 +39,7 @@ impl OutBuf {
self.remaining() > 0 self.remaining() > 0
} }
#[allow(deprecated)]
fn try_write_to<T>(&mut self, mut writer: T) -> io::Result<Option<usize>> fn try_write_to<T>(&mut self, mut writer: T) -> io::Result<Option<usize>>
where where
T: mio::deprecated::TryWrite, T: mio::deprecated::TryWrite,
@ -167,6 +168,7 @@ impl<T: SendPacket> Stream<T> {
/// The stream is ready to read, write, or both. /// The stream is ready to read, write, or both.
pub fn on_ready(&mut self, event_set: mio::Ready) -> Intent { pub fn on_ready(&mut self, event_set: mio::Ready) -> Intent {
#[allow(deprecated)]
if event_set.is_hup() || event_set.is_error() { if event_set.is_hup() || event_set.is_error() {
return Intent::Done; return Intent::Done;
} }
@ -198,6 +200,7 @@ impl<T: SendPacket> Stream<T> {
} }
// We're always interested in reading more. // We're always interested in reading more.
#[allow(deprecated)]
let mut event_set = mio::Ready::readable() | mio::Ready::hup() | mio::Ready::error(); 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 // If there is still stuff to write in the queue, we're interested in
// the socket becoming writable too. // the socket becoming writable too.


+ 0
- 1
src/proto/value_codec.rs View File

@ -465,7 +465,6 @@ impl<T: ValueEncode> ValueEncode for Vec<T> {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use std::fmt; use std::fmt;
use std::io;
use std::net; use std::net;
use std::u16; use std::u16;
use std::u32; use std::u32;


Loading…
Cancel
Save