diff --git a/Cargo.toml b/Cargo.toml index 69a8a235787b..8a9070e45b8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,7 +119,7 @@ lru_time_cache = "0.10" hyper = { version = "0.13", optional = true } http = { version = "0.2", optional = true } tower = { version = "0.3", optional = true } -pin-project = "0.4" +pin-project = "0.4.17" socket2 = "0.3" cfg-if = "0.1" bloomfilter = "^1.0.2" diff --git a/src/relay/tcprelay/http_local.rs b/src/relay/tcprelay/http_local.rs index 81c708de78ef..3ad00dffcd58 100644 --- a/src/relay/tcprelay/http_local.rs +++ b/src/relay/tcprelay/http_local.rs @@ -55,7 +55,7 @@ use crate::{ use super::ProxyStream; -#[pin_project] +#[pin_project(project = ProxyHttpStreamProj)] enum ProxyHttpStream { Http(#[pin] ProxyStream), #[cfg(feature = "local-http-native-tls")] @@ -167,13 +167,10 @@ impl ProxyHttpStream { macro_rules! forward_call { ($self:expr, $method:ident $(, $param:expr)*) => { - // #[project] match $self.as_mut().project() { - // ProxyHttpStream::Http(stream) => stream.$method($($param),*), - __ProxyHttpStreamProjection::Http(stream) => stream.$method($($param),*), + ProxyHttpStreamProj::Http(stream) => stream.$method($($param),*), #[cfg(any(feature = "local-http-native-tls", feature = "local-http-rustls"))] - // ProxyHttpStream::Https(stream, ..) => stream.$method($($param),*), - __ProxyHttpStreamProjection::Https(stream, ..) => stream.$method($($param),*), + ProxyHttpStreamProj::Https(stream, ..) => stream.$method($($param),*), } }; } diff --git a/src/relay/tcprelay/proxy_stream.rs b/src/relay/tcprelay/proxy_stream.rs index f0a8efd81259..59d5dbd22685 100644 --- a/src/relay/tcprelay/proxy_stream.rs +++ b/src/relay/tcprelay/proxy_stream.rs @@ -12,7 +12,7 @@ use std::{ use bytes::{Buf, BytesMut}; use futures::ready; use log::{debug, error, trace}; -use pin_project::{pin_project, project}; +use pin_project::pin_project; use tokio::io::{AsyncRead, AsyncWrite, ReadHalf, WriteHalf}; use crate::{ @@ -50,7 +50,6 @@ impl ProxiedConnection { } impl AsyncRead for ProxiedConnection { - #[project] fn poll_read(self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &mut [u8]) -> Poll> { self.project().stream.poll_read(cx, buf) } @@ -163,7 +162,7 @@ impl AsyncWrite for ProxiedConnection { } } -#[pin_project] +#[pin_project(project = ProxyConnectionProj)] enum ProxyConnection { Direct(#[pin] STcpStream), Proxied(#[pin] ProxiedConnection), @@ -188,36 +187,29 @@ impl ProxyConnection { macro_rules! forward_call { ($self:expr, $method:ident $(, $param:expr)*) => { - // #[project] match $self.as_mut().project() { - // ProxyConnection::Direct(stream) => stream.$method($($param),*), - __ProxyConnectionProjection::Direct(stream) => stream.$method($($param),*), - // ProxyConnection::Proxied(stream) => stream.$method($($param),*), - __ProxyConnectionProjection::Proxied(stream) => stream.$method($($param),*), + ProxyConnectionProj::Direct(stream) => stream.$method($($param),*), + ProxyConnectionProj::Proxied(stream) => stream.$method($($param),*), } }; } impl AsyncRead for ProxyConnection { - #[project] fn poll_read(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &mut [u8]) -> Poll> { forward_call!(self, poll_read, cx, buf) } } impl AsyncWrite for ProxyConnection { - #[project] fn poll_write(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &[u8]) -> Poll> { // let p = forward_call!(self, poll_write, cx, buf); forward_call!(self, poll_write, cx, buf) } - #[project] fn poll_flush(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> { forward_call!(self, poll_flush, cx) } - #[project] fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll> { forward_call!(self, poll_shutdown, cx) }