diff --git a/Cargo.toml b/Cargo.toml index f205f6e..d4f3448 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ github-actions = { repository = "quininer/tokio-rustls", workflow = "ci" } [dependencies] tokio-io = "=0.2.0-alpha.6" futures-core-preview = "=0.3.0-alpha.19" -pin-project = "0.4" rustls = "0.16" webpki = "0.21" diff --git a/src/lib.rs b/src/lib.rs index d5113e5..8caf1e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ use std::sync::Arc; use std::future::Future; use std::task::{ Context, Poll }; use futures_core as futures; -use pin_project::{ pin_project, project }; use tokio_io::{ AsyncRead, AsyncWrite }; use webpki::DNSNameRef; use rustls::{ ClientConfig, ClientSession, ServerConfig, ServerSession, Session }; @@ -202,10 +201,9 @@ impl Future for Accept { /// /// This abstracts over the inner `client::TlsStream` and `server::TlsStream`, so you can use /// a single type to keep both client- and server-initiated TLS-encrypted connections. -#[pin_project] pub enum TlsStream { - Client(#[pin] client::TlsStream), - Server(#[pin] server::TlsStream), + Client(client::TlsStream), + Server(server::TlsStream), } impl TlsStream { @@ -254,17 +252,15 @@ impl AsyncRead for TlsStream where T: AsyncRead + AsyncWrite + Unpin, { - #[project] #[inline] fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll> { - #[project] - match self.project() { - TlsStream::Client(x) => x.poll_read(cx, buf), - TlsStream::Server(x) => x.poll_read(cx, buf), + match self.get_mut() { + TlsStream::Client(x) => Pin::new(x).poll_read(cx, buf), + TlsStream::Server(x) => Pin::new(x).poll_read(cx, buf), } } } @@ -273,37 +269,31 @@ impl AsyncWrite for TlsStream where T: AsyncRead + AsyncWrite + Unpin, { - #[project] #[inline] fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { - #[project] - match self.project() { - TlsStream::Client(x) => x.poll_write(cx, buf), - TlsStream::Server(x) => x.poll_write(cx, buf), + match self.get_mut() { + TlsStream::Client(x) => Pin::new(x).poll_write(cx, buf), + TlsStream::Server(x) => Pin::new(x).poll_write(cx, buf), } } - #[project] #[inline] fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - #[project] - match self.project() { - TlsStream::Client(x) => x.poll_flush(cx), - TlsStream::Server(x) => x.poll_flush(cx), + match self.get_mut() { + TlsStream::Client(x) => Pin::new(x).poll_flush(cx), + TlsStream::Server(x) => Pin::new(x).poll_flush(cx), } } - #[project] #[inline] fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - #[project] - match self.project() { - TlsStream::Client(x) => x.poll_shutdown(cx), - TlsStream::Server(x) => x.poll_shutdown(cx), + match self.get_mut() { + TlsStream::Client(x) => Pin::new(x).poll_shutdown(cx), + TlsStream::Server(x) => Pin::new(x).poll_shutdown(cx), } } }