Skip to content

Commit

Permalink
Merge pull request snapview#63 from najamelan/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
daniel-abramov authored Aug 12, 2019
2 parents 52f7468 + 380f531 commit 9cf7243
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod encryption {
}

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
S: 'static + AsyncRead + AsyncWrite + Send,
{
Expand All @@ -77,8 +77,8 @@ mod encryption {
Box::new(future::result(TlsConnector::new())
.map(TokioTlsConnector::from)
.and_then(move |connector| connector.connect(&domain, socket))
.map(|s| StreamSwitcher::Tls(s))
.map_err(|e| Error::Tls(e)))
.map(StreamSwitcher::Tls)
.map_err(Error::Tls))
}
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ fn domain(request: &Request) -> Result<String, Error> {
/// Creates a WebSocket handshake from a request and a stream,
/// upgrading the stream to TLS if required.
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
R: Into<Request<'static>>,
S: 'static + AsyncRead + AsyncWrite + NoDelay + Send,
Expand All @@ -138,7 +138,7 @@ where
// Make sure we check domain and mode first. URL must be valid.
let mode = match url_mode(&request.url) {
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)
Expand All @@ -152,7 +152,7 @@ where

/// Connect to a given URL.
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
R: Into<Request<'static>>
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<T> Stream for WebSocketStream<T> where T: AsyncRead + AsyncWrite {
fn poll(&mut self) -> Poll<Option<Message>, WsError> {
self.inner
.read_message()
.map(|msg| Some(msg))
.map(Some)
.to_async()
.or_else(|err| match err {
WsError::ConnectionClosed => Ok(Async::Ready(None)),
Expand Down

0 comments on commit 9cf7243

Please sign in to comment.