Skip to content

Commit

Permalink
switch to use pin-project-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed May 8, 2024
1 parent 72b65db commit e288973
Show file tree
Hide file tree
Showing 23 changed files with 183 additions and 183 deletions.
24 changes: 2 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ futures-util = "0.3"
atomic-waker = "1.1"
async-trait = "0.1"
async-recursion = "1.1"
pin-project = "1.1"
pin-project-lite = "0.2"
#
rustls = "0.21.12"
tokio-rustls = "0.24"
Expand Down
2 changes: 1 addition & 1 deletion g3proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ip_network.workspace = true
ip_network_table.workspace = true
radix_trie.workspace = true
base64.workspace = true
pin-project.workspace = true
pin-project-lite.workspace = true
memchr.workspace = true
arc-swap.workspace = true
capnp-rpc.workspace = true
Expand Down
11 changes: 6 additions & 5 deletions g3proxy/src/escape/direct_fixed/http_forward/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::task::{Context, Poll};

use async_trait::async_trait;
use http::Method;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};

use g3_http::client::{HttpForwardRemoteResponse, HttpResponseParseError};
Expand All @@ -33,10 +33,11 @@ use crate::module::http_forward::{
HttpForwardTaskRemoteWrapperStats,
};

#[pin_project]
pub(crate) struct DirectHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
pin_project! {
pub(crate) struct DirectHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
}
}

impl<R> DirectHttpForwardReader<R>
Expand Down
13 changes: 7 additions & 6 deletions g3proxy/src/escape/direct_fixed/http_forward/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;

use g3_http::server::HttpProxyClientRequest;
Expand All @@ -34,11 +34,12 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(crate) struct DirectHttpForwardWriter<W: AsyncWrite, S: HttpForwardTaskRemoteStats> {
#[pin]
inner: W,
escaper_stats: Option<Arc<S>>,
pin_project! {
pub(crate) struct DirectHttpForwardWriter<W: AsyncWrite, S: HttpForwardTaskRemoteStats> {
#[pin]
inner: W,
escaper_stats: Option<Arc<S>>,
}
}

impl<W, S> DirectHttpForwardWriter<W, S>
Expand Down
15 changes: 8 additions & 7 deletions g3proxy/src/escape/direct_float/http_forward/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;

use g3_http::server::HttpProxyClientRequest;
Expand All @@ -36,12 +36,13 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(super) struct DirectFloatHttpForwardWriter<W: AsyncWrite> {
bind: DirectFloatBindIp,
#[pin]
inner: W,
escaper_stats: Option<Arc<DirectFixedEscaperStats>>,
pin_project! {
pub(super) struct DirectFloatHttpForwardWriter<W: AsyncWrite> {
bind: DirectFloatBindIp,
#[pin]
inner: W,
escaper_stats: Option<Arc<DirectFixedEscaperStats>>,
}
}

impl<W> DirectFloatHttpForwardWriter<W>
Expand Down
11 changes: 6 additions & 5 deletions g3proxy/src/escape/proxy_float/peer/http/http_forward/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::task::{Context, Poll};

use async_trait::async_trait;
use http::Method;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};

use g3_http::client::{HttpForwardRemoteResponse, HttpResponseParseError};
Expand All @@ -33,10 +33,11 @@ use crate::module::http_forward::{
HttpForwardTaskRemoteWrapperStats,
};

#[pin_project]
pub(super) struct HttpPeerHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
pin_project! {
pub(super) struct HttpPeerHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
}
}

impl<R> HttpPeerHttpForwardReader<R>
Expand Down
30 changes: 16 additions & 14 deletions g3proxy/src/escape/proxy_float/peer/http/http_forward/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;
use tokio::time::Instant;

Expand All @@ -36,13 +36,14 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(super) struct HttpPeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpPeerSharedConfig>,
#[pin]
inner: W,
upstream: UpstreamAddr,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
pin_project! {
pub(super) struct HttpPeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpPeerSharedConfig>,
#[pin]
inner: W,
upstream: UpstreamAddr,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
}
}

impl<W> HttpPeerHttpForwardWriter<W>
Expand Down Expand Up @@ -134,12 +135,13 @@ where
}
}

#[pin_project]
pub(super) struct HttpPeerHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpPeerSharedConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
pin_project! {
pub(super) struct HttpPeerHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpPeerSharedConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
}
}

impl<W> HttpPeerHttpRequestWriter<W>
Expand Down
11 changes: 6 additions & 5 deletions g3proxy/src/escape/proxy_float/peer/https/http_forward/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::task::{Context, Poll};

use async_trait::async_trait;
use http::Method;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};

use g3_http::client::{HttpForwardRemoteResponse, HttpResponseParseError};
Expand All @@ -33,10 +33,11 @@ use crate::module::http_forward::{
HttpForwardTaskRemoteWrapperStats,
};

#[pin_project]
pub(super) struct HttpsPeerHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
pin_project! {
pub(super) struct HttpsPeerHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
}
}

impl<R> HttpsPeerHttpForwardReader<R>
Expand Down
26 changes: 14 additions & 12 deletions g3proxy/src/escape/proxy_float/peer/https/http_forward/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;
use tokio::time::Instant;

Expand All @@ -36,12 +36,13 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(super) struct HttpsPeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpsPeerSharedConfig>,
#[pin]
inner: W,
upstream: UpstreamAddr,
pin_project! {
pub(super) struct HttpsPeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpsPeerSharedConfig>,
#[pin]
inner: W,
upstream: UpstreamAddr,
}
}

impl<W> HttpsPeerHttpForwardWriter<W>
Expand Down Expand Up @@ -125,11 +126,12 @@ where
}
}

#[pin_project]
pub(super) struct HttpsPeerHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpsPeerSharedConfig>,
#[pin]
inner: W,
pin_project! {
pub(super) struct HttpsPeerHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyFloatHttpsPeerSharedConfig>,
#[pin]
inner: W,
}
}

impl<W> HttpsPeerHttpRequestWriter<W>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;
use tokio::time::Instant;

Expand All @@ -36,12 +36,13 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(super) struct Socks5PeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatSocks5PeerSharedConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
pin_project! {
pub(super) struct Socks5PeerHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyFloatSocks5PeerSharedConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyFloatEscaperStats>>,
}
}

impl<W> Socks5PeerHttpForwardWriter<W>
Expand Down
11 changes: 6 additions & 5 deletions g3proxy/src/escape/proxy_http/http_forward/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::task::{Context, Poll};

use async_trait::async_trait;
use http::Method;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};

use g3_http::client::{HttpForwardRemoteResponse, HttpResponseParseError};
Expand All @@ -33,10 +33,11 @@ use crate::module::http_forward::{
HttpForwardTaskRemoteWrapperStats,
};

#[pin_project]
pub(super) struct ProxyHttpHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
pin_project! {
pub(super) struct ProxyHttpHttpForwardReader<R: AsyncRead> {
#[pin]
inner: LimitedBufReader<R>,
}
}

impl<R> ProxyHttpHttpForwardReader<R>
Expand Down
32 changes: 17 additions & 15 deletions g3proxy/src/escape/proxy_http/http_forward/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use async_trait::async_trait;
use pin_project::pin_project;
use pin_project_lite::pin_project;
use tokio::io::AsyncWrite;

use g3_http::server::HttpProxyClientRequest;
Expand All @@ -35,14 +35,15 @@ use crate::module::http_forward::{
};
use crate::serve::ServerTaskNotes;

#[pin_project]
pub(super) struct ProxyHttpHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyHttpEscaperConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyHttpEscaperStats>>,
upstream: UpstreamAddr,
pass_userid: Option<String>,
pin_project! {
pub(super) struct ProxyHttpHttpForwardWriter<W: AsyncWrite> {
config: Arc<ProxyHttpEscaperConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyHttpEscaperStats>>,
upstream: UpstreamAddr,
pass_userid: Option<String>,
}
}

impl<W> ProxyHttpHttpForwardWriter<W>
Expand Down Expand Up @@ -131,12 +132,13 @@ where
}
}

#[pin_project]
pub(super) struct ProxyHttpHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyHttpEscaperConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyHttpEscaperStats>>,
pin_project! {
pub(super) struct ProxyHttpHttpRequestWriter<W: AsyncWrite> {
config: Arc<ProxyHttpEscaperConfig>,
#[pin]
inner: W,
escaper_stats: Option<Arc<ProxyHttpEscaperStats>>,
}
}

impl<W> ProxyHttpHttpRequestWriter<W>
Expand Down
Loading

0 comments on commit e288973

Please sign in to comment.