diff --git a/Cargo.toml b/Cargo.toml index c9fe75d..9c69d14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,8 @@ base64 = "0.9.0" byteorder = "1.1.0" bytes = "0.4.6" httparse = "1.2.3" -input_buffer = "0.1.1" +# Required until input_buffer has new version published with Debug derive fix present +input_buffer = { git = "https://github.com/snapview/input_buffer" } log = "0.4.1" rand = "0.4.2" sha1 = "0.4.0" @@ -32,4 +33,4 @@ optional = true version = "0.1.5" [dev-dependencies] -env_logger = "0.4.3" +env_logger = "0.5.3" diff --git a/examples/autobahn-client.rs b/examples/autobahn-client.rs index 8a08e4b..e053f5e 100644 --- a/examples/autobahn-client.rs +++ b/examples/autobahn-client.rs @@ -45,7 +45,7 @@ fn run_test(case: u32) -> Result<()> { } fn main() { - env_logger::init().unwrap(); + env_logger::init(); let total = get_case_count().unwrap(); diff --git a/examples/autobahn-server.rs b/examples/autobahn-server.rs index 697d880..10aba75 100644 --- a/examples/autobahn-server.rs +++ b/examples/autobahn-server.rs @@ -30,7 +30,7 @@ fn handle_client(stream: TcpStream) -> Result<()> { } fn main() { - env_logger::init().unwrap(); + env_logger::init(); let server = TcpListener::bind("127.0.0.1:9001").unwrap(); diff --git a/examples/client.rs b/examples/client.rs index 8e11038..13b7d59 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -6,7 +6,7 @@ use url::Url; use tungstenite::{Message, connect}; fn main() { - env_logger::init().unwrap(); + env_logger::init(); let (mut socket, response) = connect(Url::parse("ws://localhost:3012/socket").unwrap()) .expect("Can't connect"); diff --git a/src/handshake/client.rs b/src/handshake/client.rs index d6a5264..00767c4 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -17,6 +17,7 @@ use super::machine::{HandshakeMachine, StageResult, TryParse}; use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key}; /// Client request. +#[derive(Debug)] pub struct Request<'t> { /// `ws://` or `wss://` URL to connect to. pub url: Url, @@ -67,6 +68,7 @@ impl From for Request<'static> { } /// Client handshake role. +#[derive(Debug)] pub struct ClientHandshake { verify_data: VerifyData, _marker: PhantomData, @@ -131,6 +133,7 @@ impl HandshakeRole for ClientHandshake { } /// Information for handshake verification. +#[derive(Debug)] struct VerifyData { /// Accepted server key. accept_key: String, @@ -183,6 +186,7 @@ impl VerifyData { } /// Server response. +#[derive(Debug)] pub struct Response { /// HTTP response code of the response. pub code: u16, diff --git a/src/handshake/headers.rs b/src/handshake/headers.rs index dff0782..73419b6 100644 --- a/src/handshake/headers.rs +++ b/src/handshake/headers.rs @@ -56,6 +56,7 @@ impl Headers { } /// The iterator over headers. +#[derive(Debug)] pub struct HeadersIter<'name, 'headers> { name: &'name str, iter: slice::Iter<'headers, (String, Box<[u8]>)>, diff --git a/src/handshake/machine.rs b/src/handshake/machine.rs index bacc866..a945be1 100644 --- a/src/handshake/machine.rs +++ b/src/handshake/machine.rs @@ -6,6 +6,7 @@ use error::{Error, Result}; use util::NonBlockingResult; /// A generic handshake state machine. +#[derive(Debug)] pub struct HandshakeMachine { stream: Stream, state: HandshakeState, @@ -98,6 +99,7 @@ impl HandshakeMachine { } /// The result of the round. +#[derive(Debug)] pub enum RoundResult { /// Round not done, I/O would block. WouldBlock(HandshakeMachine), @@ -108,6 +110,7 @@ pub enum RoundResult { } /// The result of the stage. +#[derive(Debug)] pub enum StageResult { /// Reading round finished. DoneReading { result: Obj, stream: Stream, tail: Vec }, @@ -122,6 +125,7 @@ pub trait TryParse: Sized { } /// The handshake state. +#[derive(Debug)] enum HandshakeState { /// Reading data from the peer. Reading(InputBuffer), diff --git a/src/handshake/mod.rs b/src/handshake/mod.rs index a6d9192..9c47aa7 100644 --- a/src/handshake/mod.rs +++ b/src/handshake/mod.rs @@ -17,6 +17,7 @@ use error::Error; use self::machine::{HandshakeMachine, RoundResult, StageResult, TryParse}; /// A WebSocket handshake. +#[derive(Debug)] pub struct MidHandshake { role: Role, machine: HandshakeMachine, @@ -99,6 +100,7 @@ pub trait HandshakeRole { /// Stage processing result. #[doc(hidden)] +#[derive(Debug)] pub enum ProcessingResult { Continue(HandshakeMachine), Done(FinalResult), diff --git a/src/handshake/server.rs b/src/handshake/server.rs index a59eded..e88cd38 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -14,6 +14,7 @@ use super::machine::{HandshakeMachine, StageResult, TryParse}; use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key}; /// Request from the client. +#[derive(Debug)] pub struct Request { /// Path part of the URL. pub path: String, @@ -90,7 +91,7 @@ impl Callback for F where F: FnOnce(&Request) -> Result { /// Callback which is called whenever the server read the request from the client and is ready /// to reply to it. The callback returns an optional headers which will be added to the reply diff --git a/src/lib.rs b/src/lib.rs index 6dd9fb5..47dfa54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![deny( missing_docs, missing_copy_implementations, + missing_debug_implementations, trivial_casts, trivial_numeric_casts, unstable_features, unused_must_use, diff --git a/src/protocol/frame/mod.rs b/src/protocol/frame/mod.rs index 49f9c8c..f90c288 100644 --- a/src/protocol/frame/mod.rs +++ b/src/protocol/frame/mod.rs @@ -14,6 +14,7 @@ use input_buffer::{InputBuffer, MIN_READ}; use error::{Error, Result}; /// A reader and writer for WebSocket frames. +#[derive(Debug)] pub struct FrameSocket { stream: Stream, in_buffer: InputBuffer, diff --git a/src/protocol/message.rs b/src/protocol/message.rs index 44eda20..b2ee1a5 100644 --- a/src/protocol/message.rs +++ b/src/protocol/message.rs @@ -12,6 +12,7 @@ mod string_collect { use error::{Error, Result}; + #[derive(Debug)] pub struct StringCollector { data: String, incomplete: Option, @@ -81,10 +82,12 @@ mod string_collect { use self::string_collect::StringCollector; /// A struct representing the incomplete message. +#[derive(Debug)] pub struct IncompleteMessage { collector: IncompleteMessageCollector, } +#[derive(Debug)] enum IncompleteMessageCollector { Text(StringCollector), Binary(Vec), diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 841cd38..4b78ba2 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -30,6 +30,7 @@ pub enum Role { /// /// This is THE structure you want to create to be able to speak the WebSocket protocol. /// It may be created by calling `connect`, `accept` or `client` functions. +#[derive(Debug)] pub struct WebSocket { /// Server or client? role: Role, @@ -396,6 +397,7 @@ impl WebSocket { } /// The current connection state. +#[derive(Debug)] enum WebSocketState { /// The connection is active. Active, diff --git a/src/stream.rs b/src/stream.rs index ab2c8e2..24324ca 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -12,7 +12,7 @@ use std::net::TcpStream; use native_tls::TlsStream; /// Stream mode, either plain TCP or TLS. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum Mode { /// Plain mode (`ws://` URL). Plain, @@ -40,6 +40,7 @@ impl NoDelay for TlsStream { } /// Stream, either plain TCP or TLS. +#[derive(Debug)] pub enum Stream { /// Unencrypted socket stream. Plain(S),