refactor(lib): Remove uses of pin_project::project attribute (#2219)
pin-project will deprecate the project attribute due to some unfixable limitations. Refs: https://github.com/taiki-e/pin-project/issues/225
This commit is contained in:
@@ -30,7 +30,7 @@ httparse = "1.0"
|
||||
h2 = "0.2.2"
|
||||
itoa = "0.4.1"
|
||||
log = "0.4"
|
||||
pin-project = "0.4"
|
||||
pin-project = "0.4.17"
|
||||
time = "0.1"
|
||||
tower-service = "0.3"
|
||||
tokio = { version = "0.2.5", features = ["sync"] }
|
||||
|
||||
@@ -17,7 +17,7 @@ use std::time::Duration;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::{self, Either, FutureExt as _};
|
||||
use pin_project::{pin_project, project};
|
||||
use pin_project::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use tower_service::Service;
|
||||
|
||||
@@ -30,7 +30,7 @@ use crate::{Body, Request, Response};
|
||||
|
||||
type Http1Dispatcher<T, B, R> = proto::dispatch::Dispatcher<proto::dispatch::Client<B>, B, T, R>;
|
||||
|
||||
#[pin_project]
|
||||
#[pin_project(project = ProtoClientProj)]
|
||||
enum ProtoClient<T, B>
|
||||
where
|
||||
B: HttpBody,
|
||||
@@ -677,12 +677,10 @@ where
|
||||
{
|
||||
type Output = crate::Result<proto::Dispatched>;
|
||||
|
||||
#[project]
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
|
||||
#[project]
|
||||
match self.project() {
|
||||
ProtoClient::H1(c) => c.poll(cx),
|
||||
ProtoClient::H2(c) => c.poll(cx),
|
||||
ProtoClientProj::H1(c) => c.poll(cx),
|
||||
ProtoClientProj::H2(c) => c.poll(cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::time::Duration;
|
||||
|
||||
use h2::server::{Connection, Handshake, SendResponse};
|
||||
use h2::Reason;
|
||||
use pin_project::{pin_project, project};
|
||||
use pin_project::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
use super::{decode_content_length, ping, PipeToSendStream, SendBuf};
|
||||
@@ -326,7 +326,7 @@ where
|
||||
state: H2StreamState<F, B>,
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
#[pin_project(project = H2StreamStateProj)]
|
||||
enum H2StreamState<F, B>
|
||||
where
|
||||
B: HttpBody,
|
||||
@@ -367,13 +367,11 @@ where
|
||||
B::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||||
E: Into<Box<dyn StdError + Send + Sync>>,
|
||||
{
|
||||
#[project]
|
||||
fn poll2(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
|
||||
let mut me = self.project();
|
||||
loop {
|
||||
#[project]
|
||||
let next = match me.state.as_mut().project() {
|
||||
H2StreamState::Service(h) => {
|
||||
H2StreamStateProj::Service(h) => {
|
||||
let res = match h.poll(cx) {
|
||||
Poll::Ready(Ok(r)) => r,
|
||||
Poll::Pending => {
|
||||
@@ -417,7 +415,7 @@ where
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
}
|
||||
H2StreamState::Body(pipe) => {
|
||||
H2StreamStateProj::Body(pipe) => {
|
||||
return pipe.poll(cx);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ use std::net::SocketAddr;
|
||||
use std::time::Duration;
|
||||
|
||||
use bytes::Bytes;
|
||||
use pin_project::{pin_project, project};
|
||||
use pin_project::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
use super::Accept;
|
||||
@@ -118,7 +118,7 @@ where
|
||||
fallback: Fallback<E>,
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
#[pin_project(project = ProtoServerProj)]
|
||||
pub(super) enum ProtoServer<T, B, S, E = Exec>
|
||||
where
|
||||
S: HttpService<Body>,
|
||||
@@ -836,12 +836,10 @@ where
|
||||
{
|
||||
type Output = crate::Result<proto::Dispatched>;
|
||||
|
||||
#[project]
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
|
||||
#[project]
|
||||
match self.project() {
|
||||
ProtoServer::H1(s) => s.poll(cx),
|
||||
ProtoServer::H2(s) => s.poll(cx),
|
||||
ProtoServerProj::H1(s) => s.poll(cx),
|
||||
ProtoServerProj::H2(s) => s.poll(cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -855,7 +853,7 @@ pub(crate) mod spawn_all {
|
||||
use crate::common::exec::H2Exec;
|
||||
use crate::common::{task, Future, Pin, Poll, Unpin};
|
||||
use crate::service::HttpService;
|
||||
use pin_project::{pin_project, project};
|
||||
use pin_project::pin_project;
|
||||
|
||||
// Used by `SpawnAll` to optionally watch a `Connection` future.
|
||||
//
|
||||
@@ -907,7 +905,7 @@ pub(crate) mod spawn_all {
|
||||
state: State<I, N, S, E, W>,
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
#[pin_project(project = StateProj)]
|
||||
pub enum State<I, N, S: HttpService<Body>, E, W: Watcher<I, S, E>> {
|
||||
Connecting(#[pin] Connecting<I, N, E>, W),
|
||||
Connected(#[pin] W::Future),
|
||||
@@ -934,7 +932,6 @@ pub(crate) mod spawn_all {
|
||||
{
|
||||
type Output = ();
|
||||
|
||||
#[project]
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
|
||||
// If it weren't for needing to name this type so the `Send` bounds
|
||||
// could be projected to the `Serve` executor, this could just be
|
||||
@@ -943,9 +940,8 @@ pub(crate) mod spawn_all {
|
||||
let mut me = self.project();
|
||||
loop {
|
||||
let next = {
|
||||
#[project]
|
||||
match me.state.as_mut().project() {
|
||||
State::Connecting(connecting, watcher) => {
|
||||
StateProj::Connecting(connecting, watcher) => {
|
||||
let res = ready!(connecting.poll(cx));
|
||||
let conn = match res {
|
||||
Ok(conn) => conn,
|
||||
@@ -958,7 +954,7 @@ pub(crate) mod spawn_all {
|
||||
let connected = watcher.watch(conn.with_upgrades());
|
||||
State::Connected(connected)
|
||||
}
|
||||
State::Connected(future) => {
|
||||
StateProj::Connected(future) => {
|
||||
return future.poll(cx).map(|res| {
|
||||
if let Err(err) = res {
|
||||
debug!("connection error: {}", err);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::error::Error as StdError;
|
||||
|
||||
use pin_project::{pin_project, project};
|
||||
use pin_project::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
use super::conn::{SpawnAll, UpgradeableConnection, Watcher};
|
||||
@@ -18,7 +18,7 @@ pub struct Graceful<I, S, F, E> {
|
||||
state: State<I, S, F, E>,
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
#[pin_project(project = StateProj)]
|
||||
pub(super) enum State<I, S, F, E> {
|
||||
Running {
|
||||
drain: Option<(Signal, Watch)>,
|
||||
@@ -58,14 +58,12 @@ where
|
||||
{
|
||||
type Output = crate::Result<()>;
|
||||
|
||||
#[project]
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
|
||||
let mut me = self.project();
|
||||
loop {
|
||||
let next = {
|
||||
#[project]
|
||||
match me.state.as_mut().project() {
|
||||
State::Running {
|
||||
StateProj::Running {
|
||||
drain,
|
||||
spawn_all,
|
||||
signal,
|
||||
@@ -80,7 +78,7 @@ where
|
||||
return spawn_all.poll_watch(cx, &GracefulWatcher(watch));
|
||||
}
|
||||
},
|
||||
State::Draining(ref mut draining) => {
|
||||
StateProj::Draining(ref mut draining) => {
|
||||
return Pin::new(draining).poll(cx).map(Ok);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user