diff --git a/src/handshake.rs b/src/handshake.rs index ecf6172..83fd7e2 100644 --- a/src/handshake.rs +++ b/src/handshake.rs @@ -2,7 +2,6 @@ use crate::compat::{AllowStd, SetWaker}; use crate::WebSocketStream; use futures::io::{AsyncRead, AsyncWrite}; use log::*; -use pin_project::pin_project; use std::future::Future; use std::io::{Read, Write}; use std::pin::Pin; @@ -51,7 +50,6 @@ where } } -#[pin_project] struct MidHandshake(Option>); enum StartedHandshake { @@ -68,7 +66,7 @@ struct StartedHandshakeFutureInner { async fn handshake(stream: S, f: F) -> Result> where Role: HandshakeRole + Unpin, - Role::InternalStream: SetWaker, + Role::InternalStream: SetWaker + Unpin, F: FnOnce(AllowStd) -> Result> + Unpin, S: AsyncRead + AsyncWrite + Unpin, { @@ -145,13 +143,12 @@ where impl Future for MidHandshake where Role: HandshakeRole + Unpin, - Role::InternalStream: SetWaker, + Role::InternalStream: SetWaker + Unpin, { type Output = Result>; - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.project(); - let mut s = this.0.take().expect("future polled after completion"); + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let mut s = self.as_mut().0.take().expect("future polled after completion"); let machine = s.get_mut(); trace!("Setting context in handshake"); @@ -161,7 +158,7 @@ where Ok(stream) => Poll::Ready(Ok(stream)), Err(Error::Failure(e)) => Poll::Ready(Err(Error::Failure(e))), Err(Error::Interrupted(mid)) => { - *this.0 = Some(mid); + self.0 = Some(mid); Poll::Pending } } diff --git a/src/stream.rs b/src/stream.rs index 9fd9e2a..4912323 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -3,30 +3,26 @@ //! There is no dependency on actual TLS implementations. Everything like //! `native_tls` or `openssl` will work as long as there is a TLS stream supporting standard //! `AsyncRead + AsyncWrite` traits. -use pin_project::{pin_project, project}; use std::pin::Pin; use std::task::{Context, Poll}; use futures::io::{AsyncRead, AsyncWrite}; /// Stream, either plain TCP or TLS. -#[pin_project] pub enum Stream { /// Unencrypted socket stream. - Plain(#[pin] S), + Plain(S), /// Encrypted socket stream. - Tls(#[pin] T), + Tls(T), } impl AsyncRead for Stream { - #[project] fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll> { - #[project] - match self.project() { + match self.get_mut() { Stream::Plain(ref mut s) => Pin::new(s).poll_read(cx, buf), Stream::Tls(ref mut s) => Pin::new(s).poll_read(cx, buf), } @@ -34,32 +30,26 @@ impl AsyncRead for Stream { } impl AsyncWrite for Stream { - #[project] fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { - #[project] - match self.project() { + match self.get_mut() { Stream::Plain(ref mut s) => Pin::new(s).poll_write(cx, buf), Stream::Tls(ref mut s) => Pin::new(s).poll_write(cx, buf), } } - #[project] fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - #[project] - match self.project() { + match self.get_mut() { Stream::Plain(ref mut s) => Pin::new(s).poll_flush(cx), Stream::Tls(ref mut s) => Pin::new(s).poll_flush(cx), } } - #[project] fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - #[project] - match self.project() { + match self.get_mut() { Stream::Plain(ref mut s) => Pin::new(s).poll_close(cx), Stream::Tls(ref mut s) => Pin::new(s).poll_close(cx), }