|
|
@ -67,7 +67,7 @@ mod encryption { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn wrap_stream<S>(socket: S, domain: String, mode: Mode) |
|
|
|
pub fn wrap_stream<S>(socket: S, domain: String, mode: Mode) |
|
|
|
-> Box<Future<Item=AutoStream<S>, Error=Error> + Send> |
|
|
|
-> Box<dyn Future<Item=AutoStream<S>, Error=Error> + Send> |
|
|
|
where |
|
|
|
where |
|
|
|
S: 'static + AsyncRead + AsyncWrite + Send, |
|
|
|
S: 'static + AsyncRead + AsyncWrite + Send, |
|
|
|
{ |
|
|
|
{ |
|
|
@ -77,8 +77,8 @@ mod encryption { |
|
|
|
Box::new(future::result(TlsConnector::new()) |
|
|
|
Box::new(future::result(TlsConnector::new()) |
|
|
|
.map(TokioTlsConnector::from) |
|
|
|
.map(TokioTlsConnector::from) |
|
|
|
.and_then(move |connector| connector.connect(&domain, socket)) |
|
|
|
.and_then(move |connector| connector.connect(&domain, socket)) |
|
|
|
.map(|s| StreamSwitcher::Tls(s)) |
|
|
|
.map(StreamSwitcher::Tls) |
|
|
|
.map_err(|e| Error::Tls(e))) |
|
|
|
.map_err(Error::Tls)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -123,7 +123,7 @@ fn domain(request: &Request) -> Result<String, Error> { |
|
|
|
/// Creates a WebSocket handshake from a request and a stream,
|
|
|
|
/// Creates a WebSocket handshake from a request and a stream,
|
|
|
|
/// upgrading the stream to TLS if required.
|
|
|
|
/// upgrading the stream to TLS if required.
|
|
|
|
pub fn client_async_tls<R, S>(request: R, stream: S) |
|
|
|
pub fn client_async_tls<R, S>(request: R, stream: S) |
|
|
|
-> Box<Future<Item=(WebSocketStream<AutoStream<S>>, Response), Error=Error> + Send> |
|
|
|
-> Box<dyn Future<Item=(WebSocketStream<AutoStream<S>>, Response), Error=Error> + Send> |
|
|
|
where |
|
|
|
where |
|
|
|
R: Into<Request<'static>>, |
|
|
|
R: Into<Request<'static>>, |
|
|
|
S: 'static + AsyncRead + AsyncWrite + NoDelay + Send, |
|
|
|
S: 'static + AsyncRead + AsyncWrite + NoDelay + Send, |
|
|
@ -138,7 +138,7 @@ where |
|
|
|
// Make sure we check domain and mode first. URL must be valid.
|
|
|
|
// Make sure we check domain and mode first. URL must be valid.
|
|
|
|
let mode = match url_mode(&request.url) { |
|
|
|
let mode = match url_mode(&request.url) { |
|
|
|
Ok(m) => m, |
|
|
|
Ok(m) => m, |
|
|
|
Err(e) => return Box::new(future::err(e.into())), |
|
|
|
Err(e) => return Box::new(future::err(e)), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Box::new(wrap_stream(stream, domain, mode) |
|
|
|
Box::new(wrap_stream(stream, domain, mode) |
|
|
@ -152,7 +152,7 @@ where |
|
|
|
|
|
|
|
|
|
|
|
/// Connect to a given URL.
|
|
|
|
/// Connect to a given URL.
|
|
|
|
pub fn connect_async<R>(request: R) |
|
|
|
pub fn connect_async<R>(request: R) |
|
|
|
-> Box<Future<Item=(WebSocketStream<AutoStream<TcpStream>>, Response), Error=Error> + Send> |
|
|
|
-> Box<dyn Future<Item=(WebSocketStream<AutoStream<TcpStream>>, Response), Error=Error> + Send> |
|
|
|
where |
|
|
|
where |
|
|
|
R: Into<Request<'static>> |
|
|
|
R: Into<Request<'static>> |
|
|
|
{ |
|
|
|
{ |
|
|
|