mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 19:12:56 +01:00
Remove uses of pin_project::project attribute
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:
parent
755a8bb9d1
commit
9528df4486
@ -24,4 +24,4 @@ futures-sink = { version = "0.3.4", default-features = false }
|
|||||||
tokio = { version = "0.2.4", default-features=false }
|
tokio = { version = "0.2.4", default-features=false }
|
||||||
tokio-util = { version = "0.2.0", default-features=false, features=["codec"] }
|
tokio-util = { version = "0.2.0", default-features=false, features=["codec"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
pin-project = "0.4.8"
|
pin-project = "0.4.17"
|
||||||
|
@ -24,7 +24,7 @@ bytes = "0.5.3"
|
|||||||
either = "1.5.3"
|
either = "1.5.3"
|
||||||
futures-sink = { version = "0.3.4", default-features = false }
|
futures-sink = { version = "0.3.4", default-features = false }
|
||||||
futures-core = { version = "0.3.4", default-features = false }
|
futures-core = { version = "0.3.4", default-features = false }
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.17"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -8,7 +8,6 @@ use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed};
|
|||||||
use actix_service::{IntoService, IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{IntoService, IntoServiceFactory, Service, ServiceFactory};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use futures_core::{ready, stream::Stream};
|
use futures_core::{ready, stream::Stream};
|
||||||
use pin_project::project;
|
|
||||||
|
|
||||||
use crate::connect::{Connect, ConnectResult};
|
use crate::connect::{Connect, ConnectResult};
|
||||||
use crate::dispatcher::Dispatcher;
|
use crate::dispatcher::Dispatcher;
|
||||||
@ -336,7 +335,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = FramedServiceImplResponseInnerProj)]
|
||||||
enum FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>
|
enum FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>
|
||||||
where
|
where
|
||||||
C: Service<Request = Connect<Io, Codec>, Response = ConnectResult<Io, St, Codec, Out>>,
|
C: Service<Request = Connect<Io, Codec>, Response = ConnectResult<Io, St, Codec, Out>>,
|
||||||
@ -378,7 +377,6 @@ where
|
|||||||
<Codec as Encoder>::Error: std::fmt::Debug,
|
<Codec as Encoder>::Error: std::fmt::Debug,
|
||||||
Out: Stream<Item = <Codec as Encoder>::Item> + Unpin,
|
Out: Stream<Item = <Codec as Encoder>::Item> + Unpin,
|
||||||
{
|
{
|
||||||
#[project]
|
|
||||||
fn poll(
|
fn poll(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
@ -386,9 +384,8 @@ where
|
|||||||
FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>,
|
FramedServiceImplResponseInner<St, Io, Codec, Out, C, T>,
|
||||||
Poll<Result<(), ServiceError<C::Error, Codec>>>,
|
Poll<Result<(), ServiceError<C::Error, Codec>>>,
|
||||||
> {
|
> {
|
||||||
#[project]
|
|
||||||
match self.project() {
|
match self.project() {
|
||||||
FramedServiceImplResponseInner::Connect(fut, handler) => match fut.poll(cx) {
|
FramedServiceImplResponseInnerProj::Connect(fut, handler) => match fut.poll(cx) {
|
||||||
Poll::Ready(Ok(res)) => Either::Left(FramedServiceImplResponseInner::Handler(
|
Poll::Ready(Ok(res)) => Either::Left(FramedServiceImplResponseInner::Handler(
|
||||||
handler.new_service(res.state),
|
handler.new_service(res.state),
|
||||||
Some(res.framed),
|
Some(res.framed),
|
||||||
@ -397,7 +394,7 @@ where
|
|||||||
Poll::Pending => Either::Right(Poll::Pending),
|
Poll::Pending => Either::Right(Poll::Pending),
|
||||||
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
|
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
|
||||||
},
|
},
|
||||||
FramedServiceImplResponseInner::Handler(fut, framed, out) => {
|
FramedServiceImplResponseInnerProj::Handler(fut, framed, out) => {
|
||||||
match fut.poll(cx) {
|
match fut.poll(cx) {
|
||||||
Poll::Ready(Ok(handler)) => {
|
Poll::Ready(Ok(handler)) => {
|
||||||
Either::Left(FramedServiceImplResponseInner::Dispatcher(
|
Either::Left(FramedServiceImplResponseInner::Dispatcher(
|
||||||
@ -408,7 +405,7 @@ where
|
|||||||
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
|
Poll::Ready(Err(e)) => Either::Right(Poll::Ready(Err(e.into()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FramedServiceImplResponseInner::Dispatcher(fut) => {
|
FramedServiceImplResponseInnerProj::Dispatcher(fut) => {
|
||||||
Either::Right(fut.poll(cx))
|
Either::Right(fut.poll(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures-util = "0.3.1"
|
futures-util = "0.3.1"
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.17"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
|
@ -81,7 +81,7 @@ where
|
|||||||
state: State<A, B>,
|
state: State<A, B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateProj)]
|
||||||
enum State<A, B>
|
enum State<A, B>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
@ -99,13 +99,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<B::Response, A::Error>;
|
type Output = Result<B::Response, A::Error>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
State::A(fut, b) => match fut.poll(cx)? {
|
StateProj::A(fut, b) => match fut.poll(cx)? {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let b = b.take().unwrap();
|
let b = b.take().unwrap();
|
||||||
this.state.set(State::Empty); // drop fut A
|
this.state.set(State::Empty); // drop fut A
|
||||||
@ -115,11 +113,11 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
State::B(fut) => fut.poll(cx).map(|r| {
|
StateProj::B(fut) => fut.poll(cx).map(|r| {
|
||||||
this.state.set(State::Empty);
|
this.state.set(State::Empty);
|
||||||
r
|
r
|
||||||
}),
|
}),
|
||||||
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,7 +177,7 @@ where
|
|||||||
state: StateRC<A, B>,
|
state: StateRC<A, B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateRCProj)]
|
||||||
enum StateRC<A, B>
|
enum StateRC<A, B>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
@ -197,13 +195,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<B::Response, A::Error>;
|
type Output = Result<B::Response, A::Error>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
StateRC::A(fut, b) => match fut.poll(cx)? {
|
StateRCProj::A(fut, b) => match fut.poll(cx)? {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let b = b.take().unwrap();
|
let b = b.take().unwrap();
|
||||||
this.state.set(StateRC::Empty); // drop fut A
|
this.state.set(StateRC::Empty); // drop fut A
|
||||||
@ -213,11 +209,11 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
StateRC::B(fut) => fut.poll(cx).map(|r| {
|
StateRCProj::B(fut) => fut.poll(cx).map(|r| {
|
||||||
this.state.set(StateRC::Empty);
|
this.state.set(StateRC::Empty);
|
||||||
r
|
r
|
||||||
}),
|
}),
|
||||||
StateRC::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
StateRCProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ where
|
|||||||
state: State<A, B>,
|
state: State<A, B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateProj)]
|
||||||
enum State<A, B>
|
enum State<A, B>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
@ -84,13 +84,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<B::Response, A::Error>;
|
type Output = Result<B::Response, A::Error>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
State::A(fut, b) => match fut.poll(cx)? {
|
StateProj::A(fut, b) => match fut.poll(cx)? {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let mut b = b.take().unwrap();
|
let mut b = b.take().unwrap();
|
||||||
this.state.set(State::Empty); // drop fut A
|
this.state.set(State::Empty); // drop fut A
|
||||||
@ -100,11 +98,11 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
State::B(fut) => fut.poll(cx).map(|r| {
|
StateProj::B(fut) => fut.poll(cx).map(|r| {
|
||||||
this.state.set(State::Empty);
|
this.state.set(State::Empty);
|
||||||
r
|
r
|
||||||
}),
|
}),
|
||||||
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ where
|
|||||||
state: State<A, B, F, Fut, Res, Err>,
|
state: State<A, B, F, Fut, Res, Err>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateProj)]
|
||||||
enum State<A, B, F, Fut, Res, Err>
|
enum State<A, B, F, Fut, Res, Err>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
@ -123,13 +123,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<Res, Err>;
|
type Output = Result<Res, Err>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
State::A(fut, b) => match fut.poll(cx)? {
|
StateProj::A(fut, b) => match fut.poll(cx)? {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let mut b = b.take().unwrap();
|
let mut b = b.take().unwrap();
|
||||||
this.state.set(State::Empty);
|
this.state.set(State::Empty);
|
||||||
@ -140,11 +138,11 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
State::B(fut) => fut.poll(cx).map(|r| {
|
StateProj::B(fut) => fut.poll(cx).map(|r| {
|
||||||
this.state.set(State::Empty);
|
this.state.set(State::Empty);
|
||||||
r
|
r
|
||||||
}),
|
}),
|
||||||
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ where
|
|||||||
state: State<T, R, S>,
|
state: State<T, R, S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateProj)]
|
||||||
enum State<T, R, S>
|
enum State<T, R, S>
|
||||||
where
|
where
|
||||||
T: ServiceFactory<Config = ()>,
|
T: ServiceFactory<Config = ()>,
|
||||||
@ -200,20 +200,18 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<S, T::InitError>;
|
type Output = Result<S, T::InitError>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
State::A(fut) => match fut.poll(cx)? {
|
StateProj::A(fut) => match fut.poll(cx)? {
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
Poll::Ready(srv) => {
|
Poll::Ready(srv) => {
|
||||||
this.state.set(State::B(srv));
|
this.state.set(State::B(srv));
|
||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State::B(srv) => match srv.poll_ready(cx)? {
|
StateProj::B(srv) => match srv.poll_ready(cx)? {
|
||||||
Poll::Ready(_) => {
|
Poll::Ready(_) => {
|
||||||
let fut = (this.store.get_mut().1)(this.cfg.take().unwrap(), srv);
|
let fut = (this.store.get_mut().1)(this.cfg.take().unwrap(), srv);
|
||||||
this.state.set(State::C(fut));
|
this.state.set(State::C(fut));
|
||||||
@ -221,7 +219,7 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
State::C(fut) => fut.poll(cx),
|
StateProj::C(fut) => fut.poll(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ where
|
|||||||
state: State<A, B>,
|
state: State<A, B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = StateProj)]
|
||||||
enum State<A, B>
|
enum State<A, B>
|
||||||
where
|
where
|
||||||
A: Service,
|
A: Service,
|
||||||
@ -84,13 +84,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<B::Response, B::Error>;
|
type Output = Result<B::Response, B::Error>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
State::A(fut, b) => match fut.poll(cx) {
|
StateProj::A(fut, b) => match fut.poll(cx) {
|
||||||
Poll::Ready(res) => {
|
Poll::Ready(res) => {
|
||||||
let mut b = b.take().unwrap();
|
let mut b = b.take().unwrap();
|
||||||
this.state.set(State::Empty); // drop fut A
|
this.state.set(State::Empty); // drop fut A
|
||||||
@ -100,11 +98,11 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
State::B(fut) => fut.poll(cx).map(|r| {
|
StateProj::B(fut) => fut.poll(cx).map(|r| {
|
||||||
this.state.set(State::Empty);
|
this.state.set(State::Empty);
|
||||||
r
|
r
|
||||||
}),
|
}),
|
||||||
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ where
|
|||||||
state: ApplyTransformFutureState<T, S>,
|
state: ApplyTransformFutureState<T, S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project(project = ApplyTransformFutureStateProj)]
|
||||||
pub enum ApplyTransformFutureState<T, S>
|
pub enum ApplyTransformFutureState<T, S>
|
||||||
where
|
where
|
||||||
S: ServiceFactory,
|
S: ServiceFactory,
|
||||||
@ -228,13 +228,11 @@ where
|
|||||||
{
|
{
|
||||||
type Output = Result<T::Transform, T::InitError>;
|
type Output = Result<T::Transform, T::InitError>;
|
||||||
|
|
||||||
#[pin_project::project]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
#[project]
|
|
||||||
match this.state.as_mut().project() {
|
match this.state.as_mut().project() {
|
||||||
ApplyTransformFutureState::A(fut) => match fut.poll(cx)? {
|
ApplyTransformFutureStateProj::A(fut) => match fut.poll(cx)? {
|
||||||
Poll::Ready(srv) => {
|
Poll::Ready(srv) => {
|
||||||
let fut = this.store.0.new_transform(srv);
|
let fut = this.store.0.new_transform(srv);
|
||||||
this.state.set(ApplyTransformFutureState::B(fut));
|
this.state.set(ApplyTransformFutureState::B(fut));
|
||||||
@ -242,7 +240,7 @@ where
|
|||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
ApplyTransformFutureState::B(fut) => fut.poll(cx),
|
ApplyTransformFutureStateProj::B(fut) => fut.poll(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ either = "1.5.3"
|
|||||||
futures-channel = { version = "0.3.4", default-features = false }
|
futures-channel = { version = "0.3.4", default-features = false }
|
||||||
futures-sink = { version = "0.3.4", default-features = false }
|
futures-sink = { version = "0.3.4", default-features = false }
|
||||||
futures-util = { version = "0.3.4", default-features = false }
|
futures-util = { version = "0.3.4", default-features = false }
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.17"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user