Derive Debugs

Deny missing debug and resolve resulting errors to satisfy:
https://rust-lang-nursery.github.io/api-guidelines/debuggability.html#all-public-types-implement-debug-c-debug

Requires updated input_buffer pushed to crates.io:
 - Resolved build errors by using github version of code until new version available on crates.io

Upgrade env_logger dev-dependency to v0.5.3
 - Removed unwrap call from env_logger::init()  as it is no longer needed.
pull/25/head
Sean Schwartz 7 years ago
parent 2d8395031b
commit 66d2c15f2d
  1. 5
      Cargo.toml
  2. 2
      examples/autobahn-client.rs
  3. 2
      examples/autobahn-server.rs
  4. 2
      examples/client.rs
  5. 4
      src/handshake/client.rs
  6. 1
      src/handshake/headers.rs
  7. 4
      src/handshake/machine.rs
  8. 2
      src/handshake/mod.rs
  9. 4
      src/handshake/server.rs
  10. 1
      src/lib.rs
  11. 1
      src/protocol/frame/mod.rs
  12. 3
      src/protocol/message.rs
  13. 2
      src/protocol/mod.rs
  14. 3
      src/stream.rs

@ -20,7 +20,8 @@ base64 = "0.9.0"
byteorder = "1.1.0" byteorder = "1.1.0"
bytes = "0.4.6" bytes = "0.4.6"
httparse = "1.2.3" 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" log = "0.4.1"
rand = "0.4.2" rand = "0.4.2"
sha1 = "0.4.0" sha1 = "0.4.0"
@ -32,4 +33,4 @@ optional = true
version = "0.1.5" version = "0.1.5"
[dev-dependencies] [dev-dependencies]
env_logger = "0.4.3" env_logger = "0.5.3"

@ -45,7 +45,7 @@ fn run_test(case: u32) -> Result<()> {
} }
fn main() { fn main() {
env_logger::init().unwrap(); env_logger::init();
let total = get_case_count().unwrap(); let total = get_case_count().unwrap();

@ -30,7 +30,7 @@ fn handle_client(stream: TcpStream) -> Result<()> {
} }
fn main() { fn main() {
env_logger::init().unwrap(); env_logger::init();
let server = TcpListener::bind("127.0.0.1:9001").unwrap(); let server = TcpListener::bind("127.0.0.1:9001").unwrap();

@ -6,7 +6,7 @@ use url::Url;
use tungstenite::{Message, connect}; use tungstenite::{Message, connect};
fn main() { fn main() {
env_logger::init().unwrap(); env_logger::init();
let (mut socket, response) = connect(Url::parse("ws://localhost:3012/socket").unwrap()) let (mut socket, response) = connect(Url::parse("ws://localhost:3012/socket").unwrap())
.expect("Can't connect"); .expect("Can't connect");

@ -17,6 +17,7 @@ use super::machine::{HandshakeMachine, StageResult, TryParse};
use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key}; use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key};
/// Client request. /// Client request.
#[derive(Debug)]
pub struct Request<'t> { pub struct Request<'t> {
/// `ws://` or `wss://` URL to connect to. /// `ws://` or `wss://` URL to connect to.
pub url: Url, pub url: Url,
@ -67,6 +68,7 @@ impl From<Url> for Request<'static> {
} }
/// Client handshake role. /// Client handshake role.
#[derive(Debug)]
pub struct ClientHandshake<S> { pub struct ClientHandshake<S> {
verify_data: VerifyData, verify_data: VerifyData,
_marker: PhantomData<S>, _marker: PhantomData<S>,
@ -131,6 +133,7 @@ impl<S: Read + Write> HandshakeRole for ClientHandshake<S> {
} }
/// Information for handshake verification. /// Information for handshake verification.
#[derive(Debug)]
struct VerifyData { struct VerifyData {
/// Accepted server key. /// Accepted server key.
accept_key: String, accept_key: String,
@ -183,6 +186,7 @@ impl VerifyData {
} }
/// Server response. /// Server response.
#[derive(Debug)]
pub struct Response { pub struct Response {
/// HTTP response code of the response. /// HTTP response code of the response.
pub code: u16, pub code: u16,

@ -56,6 +56,7 @@ impl Headers {
} }
/// The iterator over headers. /// The iterator over headers.
#[derive(Debug)]
pub struct HeadersIter<'name, 'headers> { pub struct HeadersIter<'name, 'headers> {
name: &'name str, name: &'name str,
iter: slice::Iter<'headers, (String, Box<[u8]>)>, iter: slice::Iter<'headers, (String, Box<[u8]>)>,

@ -6,6 +6,7 @@ use error::{Error, Result};
use util::NonBlockingResult; use util::NonBlockingResult;
/// A generic handshake state machine. /// A generic handshake state machine.
#[derive(Debug)]
pub struct HandshakeMachine<Stream> { pub struct HandshakeMachine<Stream> {
stream: Stream, stream: Stream,
state: HandshakeState, state: HandshakeState,
@ -98,6 +99,7 @@ impl<Stream: Read + Write> HandshakeMachine<Stream> {
} }
/// The result of the round. /// The result of the round.
#[derive(Debug)]
pub enum RoundResult<Obj, Stream> { pub enum RoundResult<Obj, Stream> {
/// Round not done, I/O would block. /// Round not done, I/O would block.
WouldBlock(HandshakeMachine<Stream>), WouldBlock(HandshakeMachine<Stream>),
@ -108,6 +110,7 @@ pub enum RoundResult<Obj, Stream> {
} }
/// The result of the stage. /// The result of the stage.
#[derive(Debug)]
pub enum StageResult<Obj, Stream> { pub enum StageResult<Obj, Stream> {
/// Reading round finished. /// Reading round finished.
DoneReading { result: Obj, stream: Stream, tail: Vec<u8> }, DoneReading { result: Obj, stream: Stream, tail: Vec<u8> },
@ -122,6 +125,7 @@ pub trait TryParse: Sized {
} }
/// The handshake state. /// The handshake state.
#[derive(Debug)]
enum HandshakeState { enum HandshakeState {
/// Reading data from the peer. /// Reading data from the peer.
Reading(InputBuffer), Reading(InputBuffer),

@ -17,6 +17,7 @@ use error::Error;
use self::machine::{HandshakeMachine, RoundResult, StageResult, TryParse}; use self::machine::{HandshakeMachine, RoundResult, StageResult, TryParse};
/// A WebSocket handshake. /// A WebSocket handshake.
#[derive(Debug)]
pub struct MidHandshake<Role: HandshakeRole> { pub struct MidHandshake<Role: HandshakeRole> {
role: Role, role: Role,
machine: HandshakeMachine<Role::InternalStream>, machine: HandshakeMachine<Role::InternalStream>,
@ -99,6 +100,7 @@ pub trait HandshakeRole {
/// Stage processing result. /// Stage processing result.
#[doc(hidden)] #[doc(hidden)]
#[derive(Debug)]
pub enum ProcessingResult<Stream, FinalResult> { pub enum ProcessingResult<Stream, FinalResult> {
Continue(HandshakeMachine<Stream>), Continue(HandshakeMachine<Stream>),
Done(FinalResult), Done(FinalResult),

@ -14,6 +14,7 @@ use super::machine::{HandshakeMachine, StageResult, TryParse};
use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key}; use super::{MidHandshake, HandshakeRole, ProcessingResult, convert_key};
/// Request from the client. /// Request from the client.
#[derive(Debug)]
pub struct Request { pub struct Request {
/// Path part of the URL. /// Path part of the URL.
pub path: String, pub path: String,
@ -90,7 +91,7 @@ impl<F> Callback for F where F: FnOnce(&Request) -> Result<Option<Vec<(String, S
} }
/// Stub for callback that does nothing. /// Stub for callback that does nothing.
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct NoCallback; pub struct NoCallback;
impl Callback for NoCallback { impl Callback for NoCallback {
@ -101,6 +102,7 @@ impl Callback for NoCallback {
/// Server handshake role. /// Server handshake role.
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
#[derive(Debug)]
pub struct ServerHandshake<S, C> { pub struct ServerHandshake<S, C> {
/// Callback which is called whenever the server read the request from the client and is ready /// 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 /// to reply to it. The callback returns an optional headers which will be added to the reply

@ -2,6 +2,7 @@
#![deny( #![deny(
missing_docs, missing_docs,
missing_copy_implementations, missing_copy_implementations,
missing_debug_implementations,
trivial_casts, trivial_numeric_casts, trivial_casts, trivial_numeric_casts,
unstable_features, unstable_features,
unused_must_use, unused_must_use,

@ -14,6 +14,7 @@ use input_buffer::{InputBuffer, MIN_READ};
use error::{Error, Result}; use error::{Error, Result};
/// A reader and writer for WebSocket frames. /// A reader and writer for WebSocket frames.
#[derive(Debug)]
pub struct FrameSocket<Stream> { pub struct FrameSocket<Stream> {
stream: Stream, stream: Stream,
in_buffer: InputBuffer, in_buffer: InputBuffer,

@ -12,6 +12,7 @@ mod string_collect {
use error::{Error, Result}; use error::{Error, Result};
#[derive(Debug)]
pub struct StringCollector { pub struct StringCollector {
data: String, data: String,
incomplete: Option<utf8::Incomplete>, incomplete: Option<utf8::Incomplete>,
@ -81,10 +82,12 @@ mod string_collect {
use self::string_collect::StringCollector; use self::string_collect::StringCollector;
/// A struct representing the incomplete message. /// A struct representing the incomplete message.
#[derive(Debug)]
pub struct IncompleteMessage { pub struct IncompleteMessage {
collector: IncompleteMessageCollector, collector: IncompleteMessageCollector,
} }
#[derive(Debug)]
enum IncompleteMessageCollector { enum IncompleteMessageCollector {
Text(StringCollector), Text(StringCollector),
Binary(Vec<u8>), Binary(Vec<u8>),

@ -30,6 +30,7 @@ pub enum Role {
/// ///
/// This is THE structure you want to create to be able to speak the WebSocket protocol. /// 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. /// It may be created by calling `connect`, `accept` or `client` functions.
#[derive(Debug)]
pub struct WebSocket<Stream> { pub struct WebSocket<Stream> {
/// Server or client? /// Server or client?
role: Role, role: Role,
@ -396,6 +397,7 @@ impl<Stream: Read + Write> WebSocket<Stream> {
} }
/// The current connection state. /// The current connection state.
#[derive(Debug)]
enum WebSocketState { enum WebSocketState {
/// The connection is active. /// The connection is active.
Active, Active,

@ -12,7 +12,7 @@ use std::net::TcpStream;
use native_tls::TlsStream; use native_tls::TlsStream;
/// Stream mode, either plain TCP or TLS. /// Stream mode, either plain TCP or TLS.
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub enum Mode { pub enum Mode {
/// Plain mode (`ws://` URL). /// Plain mode (`ws://` URL).
Plain, Plain,
@ -40,6 +40,7 @@ impl<S: Read + Write + NoDelay> NoDelay for TlsStream<S> {
} }
/// Stream, either plain TCP or TLS. /// Stream, either plain TCP or TLS.
#[derive(Debug)]
pub enum Stream<S, T> { pub enum Stream<S, T> {
/// Unencrypted socket stream. /// Unencrypted socket stream.
Plain(S), Plain(S),

Loading…
Cancel
Save