diff --git a/fuzz/fuzz_targets/read_message_client.rs b/fuzz/fuzz_targets/read_message_client.rs index bd3bf05..898c67b 100644 --- a/fuzz/fuzz_targets/read_message_client.rs +++ b/fuzz/fuzz_targets/read_message_client.rs @@ -1,12 +1,13 @@ #![no_main] -#[macro_use] extern crate libfuzzer_sys; +#[macro_use] +extern crate libfuzzer_sys; extern crate tungstenite; use std::io; use std::io::Cursor; -use tungstenite::WebSocket; -use tungstenite::protocol::Role; use tungstenite::extensions::uncompressed::UncompressedExt; +use tungstenite::protocol::Role; +use tungstenite::WebSocket; //use std::result::Result; // FIXME: copypasted from tungstenite's protocol/mod.rs @@ -33,7 +34,6 @@ impl io::Read for WriteMoc { fuzz_target!(|data: &[u8]| { //let vector: Vec = data.into(); let cursor = Cursor::new(data); - let mut socket: WebSocket<_, UncompressedExt> = - WebSocket::from_raw_socket(WriteMoc(cursor), Role::Client, None); + let mut socket = WebSocket::from_raw_socket(WriteMoc(cursor), Role::Client, None); socket.read_message().ok(); -}); \ No newline at end of file +}); diff --git a/fuzz/fuzz_targets/read_message_server.rs b/fuzz/fuzz_targets/read_message_server.rs index aae4bd2..e508d4e 100644 --- a/fuzz/fuzz_targets/read_message_server.rs +++ b/fuzz/fuzz_targets/read_message_server.rs @@ -5,9 +5,9 @@ extern crate tungstenite; use std::io; use std::io::Cursor; +use tungstenite::extensions::uncompressed::UncompressedExt; use tungstenite::protocol::Role; use tungstenite::WebSocket; -use tungstenite::extensions::uncompressed::UncompressedExt; //use std::result::Result; // FIXME: copypasted from tungstenite's protocol/mod.rs @@ -34,7 +34,6 @@ impl io::Read for WriteMoc { fuzz_target!(|data: &[u8]| { //let vector: Vec = data.into(); let cursor = Cursor::new(data); - let mut socket: WebSocket<_, UncompressedExt> = - WebSocket::from_raw_socket(WriteMoc(cursor), Role::Server, None); + let mut socket = WebSocket::from_raw_socket(WriteMoc(cursor), Role::Server, None); socket.read_message().ok(); }); diff --git a/src/server.rs b/src/server.rs index 34cd83b..53303ee 100644 --- a/src/server.rs +++ b/src/server.rs @@ -20,13 +20,10 @@ use std::io::{Read, Write}; /// If you want TLS support, use `native_tls::TlsStream` or `openssl::ssl::SslStream` /// for the stream here. Any `Read + Write` streams are supported, including /// those from `Mio` and others. -pub fn accept_with_config( - stream: Stream, +pub fn accept_with_config( + stream: S, config: Option, -) -> Result, HandshakeError>> -where - Stream: Read + Write, -{ +) -> Result, HandshakeError>> { accept_hdr_with_config(stream, NoCallback, config) } @@ -50,15 +47,11 @@ pub fn accept( /// This function does the same as `accept()` but accepts an extra callback /// for header processing. The callback receives headers of the incoming /// requests and is able to add extra headers to the reply. -pub fn accept_hdr_with_config( +pub fn accept_hdr_with_config( stream: S, callback: C, config: Option, -) -> Result, HandshakeError>> -where - S: Read + Write, - C: Callback, -{ +) -> Result, HandshakeError>> { ServerHandshake::start(stream, callback, config).handshake() }