Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of pin_project::project attribute #267

Merged
merged 1 commit into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
zonyitoo marked this conversation as resolved.
Show resolved Hide resolved
socket2 = "0.3"
cfg-if = "0.1"
bloomfilter = "^1.0.2"
Expand Down
9 changes: 3 additions & 6 deletions src/relay/tcprelay/http_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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),*),
}
};
}
Expand Down
16 changes: 4 additions & 12 deletions src/relay/tcprelay/proxy_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<io::Result<usize>> {
self.project().stream.poll_read(cx, buf)
}
Expand Down Expand Up @@ -163,7 +162,7 @@ impl AsyncWrite for ProxiedConnection {
}
}

#[pin_project]
#[pin_project(project = ProxyConnectionProj)]
enum ProxyConnection {
Direct(#[pin] STcpStream),
Proxied(#[pin] ProxiedConnection),
Expand All @@ -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<io::Result<usize>> {
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<io::Result<usize>> {
// 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<io::Result<()>> {
forward_call!(self, poll_flush, cx)
}

#[project]
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<io::Result<()>> {
forward_call!(self, poll_shutdown, cx)
}
Expand Down