|
|
|
@ -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: Stream, |
|
|
|
|
pub fn accept_with_config<S: Read + Write>( |
|
|
|
|
stream: S, |
|
|
|
|
config: Option<WebSocketConfig>, |
|
|
|
|
) -> Result<WebSocket<Stream>, HandshakeError<ServerHandshake<Stream, NoCallback>>> |
|
|
|
|
where |
|
|
|
|
Stream: Read + Write, |
|
|
|
|
{ |
|
|
|
|
) -> Result<WebSocket<S>, HandshakeError<ServerHandshake<S, NoCallback>>> { |
|
|
|
|
accept_hdr_with_config(stream, NoCallback, config) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -50,15 +47,11 @@ pub fn accept<S: Read + Write>( |
|
|
|
|
/// 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<S, C>( |
|
|
|
|
pub fn accept_hdr_with_config<S: Read + Write, C: Callback>( |
|
|
|
|
stream: S, |
|
|
|
|
callback: C, |
|
|
|
|
config: Option<WebSocketConfig>, |
|
|
|
|
) -> Result<WebSocket<S>, HandshakeError<ServerHandshake<S, C>>> |
|
|
|
|
where |
|
|
|
|
S: Read + Write, |
|
|
|
|
C: Callback, |
|
|
|
|
{ |
|
|
|
|
) -> Result<WebSocket<S>, HandshakeError<ServerHandshake<S, C>>> { |
|
|
|
|
ServerHandshake::start(stream, callback, config).handshake() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|