1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 18:02:58 +01:00

revert IntoFuture change

This commit is contained in:
Nikolay Kim 2019-03-04 21:35:47 -08:00
parent 03f2046a42
commit e8a49801eb
20 changed files with 58 additions and 70 deletions

View File

@ -33,7 +33,8 @@ ssl = ["openssl", "tokio-openssl"]
rust-tls = ["rustls", "tokio-rustls", "webpki", "webpki-roots"] rust-tls = ["rustls", "tokio-rustls", "webpki", "webpki-roots"]
[dependencies] [dependencies]
actix-service = "0.3.2" #actix-service = "0.3.2"
actix-service = { path="../actix-service" }
actix-rt = "0.1.0" actix-rt = "0.1.0"
log = "0.4" log = "0.4"

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::{fmt, io, net}; use std::{fmt, io, net};
use actix_service::{IntoNewService, NewService}; use actix_service::{IntoNewService, NewService};
use futures::future::{join_all, Future, IntoFuture}; use futures::future::{join_all, Future};
use log::error; use log::error;
use tokio_tcp::TcpStream; use tokio_tcp::TcpStream;
@ -223,7 +223,6 @@ where
Box::new( Box::new(
self.inner self.inner
.new_service(&()) .new_service(&())
.into_future()
.map_err(|_| ()) .map_err(|_| ())
.map(|s| { .map(|s| {
let service: BoxedServerService = Box::new(StreamService::new(s)); let service: BoxedServerService = Box::new(StreamService::new(s));

View File

@ -3,7 +3,7 @@ use std::time::Duration;
use actix_rt::spawn; use actix_rt::spawn;
use actix_service::{NewService, Service}; use actix_service::{NewService, Service};
use futures::future::{err, ok, FutureResult, IntoFuture}; use futures::future::{err, ok, FutureResult};
use futures::{Future, Poll}; use futures::{Future, Poll};
use log::error; use log::error;
use tokio_reactor::Handle; use tokio_reactor::Handle;
@ -129,7 +129,6 @@ where
self.inner self.inner
.create() .create()
.new_service(&()) .new_service(&())
.into_future()
.map_err(|_| ()) .map_err(|_| ())
.map(move |inner| { .map(move |inner| {
let service: BoxedServerService = Box::new(StreamService::new(inner)); let service: BoxedServerService = Box::new(StreamService::new(inner));

View File

@ -6,6 +6,10 @@
* Add `ApplyTransform` new service for transform and new service. * Add `ApplyTransform` new service for transform and new service.
### Changed
* Revert IntoFuture change
## [0.3.2] - 2019-03-04 ## [0.3.2] - 2019-03-04

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{try_ready, Async, Future, IntoFuture, Poll}; use futures::{try_ready, Async, Future, Poll};
use super::{IntoNewService, NewService, Service}; use super::{IntoNewService, NewService, Service};
use crate::cell::Cell; use crate::cell::Cell;
@ -142,10 +142,7 @@ where
type Future = AndThenNewServiceFuture<A, B, C>; type Future = AndThenNewServiceFuture<A, B, C>;
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
AndThenNewServiceFuture::new( AndThenNewServiceFuture::new(self.a.new_service(cfg), self.b.new_service(cfg))
self.a.new_service(cfg).into_future(),
self.b.new_service(cfg).into_future(),
)
} }
} }
@ -168,8 +165,8 @@ where
A: NewService<C>, A: NewService<C>,
B: NewService<C, Request = A::Response>, B: NewService<C, Request = A::Response>,
{ {
fut_b: <B::Future as IntoFuture>::Future, fut_b: B::Future,
fut_a: <A::Future as IntoFuture>::Future, fut_a: A::Future,
a: Option<A::Service>, a: Option<A::Service>,
b: Option<B::Service>, b: Option<B::Service>,
} }
@ -179,10 +176,7 @@ where
A: NewService<C>, A: NewService<C>,
B: NewService<C, Request = A::Response>, B: NewService<C, Request = A::Response>,
{ {
fn new( fn new(fut_a: A::Future, fut_b: B::Future) -> Self {
fut_a: <A::Future as IntoFuture>::Future,
fut_b: <B::Future as IntoFuture>::Future,
) -> Self {
AndThenNewServiceFuture { AndThenNewServiceFuture {
fut_a, fut_a,
fut_b, fut_b,

View File

@ -1,6 +1,6 @@
use std::rc::Rc; use std::rc::Rc;
use futures::{Async, Future, IntoFuture, Poll}; use futures::{Async, Future, Poll};
use crate::and_then::AndThen; use crate::and_then::AndThen;
use crate::from_err::FromErr; use crate::from_err::FromErr;
@ -67,8 +67,8 @@ where
a: None, a: None,
t: None, t: None,
t_cell: self.t.clone(), t_cell: self.t.clone(),
fut_a: self.a.new_service(cfg).into_future(), fut_a: self.a.new_service(cfg),
fut_b: self.b.new_service(cfg).into_future(), fut_b: self.b.new_service(cfg),
fut_t: None, fut_t: None,
} }
} }
@ -81,9 +81,9 @@ where
T: Transform<B::Service, Request = A::Response, InitError = A::InitError>, T: Transform<B::Service, Request = A::Response, InitError = A::InitError>,
T::Error: From<A::Error>, T::Error: From<A::Error>,
{ {
fut_a: <A::Future as IntoFuture>::Future, fut_a: A::Future,
fut_b: <B::Future as IntoFuture>::Future, fut_b: B::Future,
fut_t: Option<<T::Future as IntoFuture>::Future>, fut_t: Option<T::Future>,
a: Option<A::Service>, a: Option<A::Service>,
t: Option<T::Transform>, t: Option<T::Transform>,
t_cell: Rc<T>, t_cell: Rc<T>,
@ -102,7 +102,7 @@ where
fn poll(&mut self) -> Poll<Self::Item, Self::Error> { fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
if self.fut_t.is_none() { if self.fut_t.is_none() {
if let Async::Ready(service) = self.fut_b.poll()? { if let Async::Ready(service) = self.fut_b.poll()? {
self.fut_t = Some(self.t_cell.new_transform(service).into_future()); self.fut_t = Some(self.t_cell.new_transform(service));
} }
} }

View File

@ -209,8 +209,8 @@ where
Out: IntoFuture, Out: IntoFuture,
Out::Error: Into<A::Error>, Out::Error: Into<A::Error>,
{ {
fut_b: <B::Future as IntoFuture>::Future, fut_b: B::Future,
fut_a: <A::Future as IntoFuture>::Future, fut_a: A::Future,
f: Cell<F>, f: Cell<F>,
a: Option<A::Service>, a: Option<A::Service>,
b: Option<B::Service>, b: Option<B::Service>,

View File

@ -124,7 +124,7 @@ where
type Future = ApplyNewServiceFuture<T, F, In, Out, Cfg>; type Future = ApplyNewServiceFuture<T, F, In, Out, Cfg>;
fn new_service(&self, cfg: &Cfg) -> Self::Future { fn new_service(&self, cfg: &Cfg) -> Self::Future {
ApplyNewServiceFuture::new(self.service.new_service(cfg).into_future(), self.f.clone()) ApplyNewServiceFuture::new(self.service.new_service(cfg), self.f.clone())
} }
} }
@ -134,7 +134,7 @@ where
F: FnMut(In, &mut T::Service) -> Out + Clone, F: FnMut(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture, Out: IntoFuture,
{ {
fut: <T::Future as IntoFuture>::Future, fut: T::Future,
f: Option<F>, f: Option<F>,
r: PhantomData<(In, Out)>, r: PhantomData<(In, Out)>,
} }
@ -145,7 +145,7 @@ where
F: FnMut(In, &mut T::Service) -> Out + Clone, F: FnMut(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture, Out: IntoFuture,
{ {
fn new(fut: <T::Future as IntoFuture>::Future, f: F) -> Self { fn new(fut: T::Future, f: F) -> Self {
ApplyNewServiceFuture { ApplyNewServiceFuture {
f: Some(f), f: Some(f),
fut, fut,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{Async, Future, IntoFuture, Poll}; use futures::{Async, Future, Poll};
use super::{NewService, Service}; use super::{NewService, Service};
@ -124,7 +124,7 @@ where
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
FromErrNewServiceFuture { FromErrNewServiceFuture {
fut: self.a.new_service(cfg).into_future(), fut: self.a.new_service(cfg),
e: PhantomData, e: PhantomData,
} }
} }
@ -135,7 +135,7 @@ where
A: NewService<C>, A: NewService<C>,
E: From<A::Error>, E: From<A::Error>,
{ {
fut: <A::Future as IntoFuture>::Future, fut: A::Future,
e: PhantomData<E>, e: PhantomData<E>,
} }

View File

@ -199,7 +199,7 @@ pub trait NewService<Config = ()> {
type InitError; type InitError;
/// The future of the `Service` instance. /// The future of the `Service` instance.
type Future: IntoFuture<Item = Self::Service, Error = Self::InitError>; type Future: Future<Item = Self::Service, Error = Self::InitError>;
/// Create and return a new service value asynchronously. /// Create and return a new service value asynchronously.
fn new_service(&self, cfg: &Config) -> Self::Future; fn new_service(&self, cfg: &Config) -> Self::Future;

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{Async, Future, IntoFuture, Poll}; use futures::{Async, Future, Poll};
use super::{NewService, Service}; use super::{NewService, Service};
@ -146,7 +146,7 @@ where
type Future = MapNewServiceFuture<A, F, Res, Cfg>; type Future = MapNewServiceFuture<A, F, Res, Cfg>;
fn new_service(&self, cfg: &Cfg) -> Self::Future { fn new_service(&self, cfg: &Cfg) -> Self::Future {
MapNewServiceFuture::new(self.a.new_service(cfg).into_future(), self.f.clone()) MapNewServiceFuture::new(self.a.new_service(cfg), self.f.clone())
} }
} }
@ -155,7 +155,7 @@ where
A: NewService<Cfg>, A: NewService<Cfg>,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
fut: <A::Future as IntoFuture>::Future, fut: A::Future,
f: Option<F>, f: Option<F>,
} }
@ -164,7 +164,7 @@ where
A: NewService<Cfg>, A: NewService<Cfg>,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
fn new(fut: <A::Future as IntoFuture>::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
MapNewServiceFuture { f: Some(f), fut } MapNewServiceFuture { f: Some(f), fut }
} }
} }

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{Async, Future, IntoFuture, Poll}; use futures::{Async, Future, Poll};
use super::{NewService, Service}; use super::{NewService, Service};
@ -147,7 +147,7 @@ where
type Future = MapErrNewServiceFuture<A, F, E, C>; type Future = MapErrNewServiceFuture<A, F, E, C>;
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
MapErrNewServiceFuture::new(self.a.new_service(cfg).into_future(), self.f.clone()) MapErrNewServiceFuture::new(self.a.new_service(cfg), self.f.clone())
} }
} }
@ -156,7 +156,7 @@ where
A: NewService<C>, A: NewService<C>,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
fut: <A::Future as IntoFuture>::Future, fut: A::Future,
f: F, f: F,
} }
@ -165,7 +165,7 @@ where
A: NewService<C>, A: NewService<C>,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
fn new(fut: <A::Future as IntoFuture>::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
MapErrNewServiceFuture { f, fut } MapErrNewServiceFuture { f, fut }
} }
} }

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{Future, IntoFuture, Poll}; use futures::{Future, Poll};
use super::NewService; use super::NewService;
@ -54,7 +54,7 @@ where
type Future = MapInitErrFuture<A, F, E, C>; type Future = MapInitErrFuture<A, F, E, C>;
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
MapInitErrFuture::new(self.a.new_service(cfg).into_future(), self.f.clone()) MapInitErrFuture::new(self.a.new_service(cfg), self.f.clone())
} }
} }
@ -64,7 +64,7 @@ where
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
f: F, f: F,
fut: <A::Future as IntoFuture>::Future, fut: A::Future,
} }
impl<A, F, E, C> MapInitErrFuture<A, F, E, C> impl<A, F, E, C> MapInitErrFuture<A, F, E, C>
@ -72,7 +72,7 @@ where
A: NewService<C>, A: NewService<C>,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
fn new(fut: <A::Future as IntoFuture>::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
MapInitErrFuture { f, fut } MapInitErrFuture { f, fut }
} }
} }

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{try_ready, Async, Future, IntoFuture, Poll}; use futures::{try_ready, Async, Future, Poll};
use super::{IntoNewService, NewService, Service}; use super::{IntoNewService, NewService, Service};
use crate::cell::Cell; use crate::cell::Cell;
@ -157,10 +157,7 @@ where
type Future = ThenNewServiceFuture<A, B, C>; type Future = ThenNewServiceFuture<A, B, C>;
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
ThenNewServiceFuture::new( ThenNewServiceFuture::new(self.a.new_service(cfg), self.b.new_service(cfg))
self.a.new_service(cfg).into_future(),
self.b.new_service(cfg).into_future(),
)
} }
} }
@ -188,8 +185,8 @@ where
InitError = A::InitError, InitError = A::InitError,
>, >,
{ {
fut_b: <B::Future as IntoFuture>::Future, fut_b: B::Future,
fut_a: <A::Future as IntoFuture>::Future, fut_a: A::Future,
a: Option<A::Service>, a: Option<A::Service>,
b: Option<B::Service>, b: Option<B::Service>,
} }
@ -204,10 +201,7 @@ where
InitError = A::InitError, InitError = A::InitError,
>, >,
{ {
fn new( fn new(fut_a: A::Future, fut_b: B::Future) -> Self {
fut_a: <A::Future as IntoFuture>::Future,
fut_b: <B::Future as IntoFuture>::Future,
) -> Self {
ThenNewServiceFuture { ThenNewServiceFuture {
fut_a, fut_a,
fut_b, fut_b,

View File

@ -31,7 +31,7 @@ pub trait Transform<S> {
type InitError; type InitError;
/// The future response value. /// The future response value.
type Future: IntoFuture<Item = Self::Transform, Error = Self::InitError>; type Future: Future<Item = Self::Transform, Error = Self::InitError>;
/// Create and return a new service value asynchronously. /// Create and return a new service value asynchronously.
fn new_transform(&self, service: S) -> Self::Future; fn new_transform(&self, service: S) -> Self::Future;
@ -147,7 +147,7 @@ where
A: NewService<C>, A: NewService<C>,
T: Transform<A::Service, Error = A::Error, InitError = A::InitError>, T: Transform<A::Service, Error = A::Error, InitError = A::InitError>,
{ {
fut_a: <A::Future as IntoFuture>::Future, fut_a: A::Future,
fut_t: Option<<T::Future as IntoFuture>::Future>, fut_t: Option<<T::Future as IntoFuture>::Future>,
t_cell: Rc<T>, t_cell: Rc<T>,
} }

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use futures::{Future, IntoFuture, Poll}; use futures::{Future, Poll};
use super::Transform; use super::Transform;
@ -57,10 +57,7 @@ where
type Future = TransformMapInitErrFuture<T, S, F, E>; type Future = TransformMapInitErrFuture<T, S, F, E>;
fn new_transform(&self, service: S) -> Self::Future { fn new_transform(&self, service: S) -> Self::Future {
TransformMapInitErrFuture::new( TransformMapInitErrFuture::new(self.t.new_transform(service), self.f.clone())
self.t.new_transform(service).into_future(),
self.f.clone(),
)
} }
} }
@ -69,7 +66,7 @@ where
T: Transform<S>, T: Transform<S>,
F: Fn(T::InitError) -> E, F: Fn(T::InitError) -> E,
{ {
fut: <T::Future as IntoFuture>::Future, fut: T::Future,
f: F, f: F,
} }
@ -78,7 +75,7 @@ where
T: Transform<S>, T: Transform<S>,
F: Fn(T::InitError) -> E, F: Fn(T::InitError) -> E,
{ {
fn new(fut: <T::Future as IntoFuture>::Future, f: F) -> Self { fn new(fut: T::Future, f: F) -> Self {
TransformMapInitErrFuture { f, fut } TransformMapInitErrFuture { f, fut }
} }
} }

View File

@ -18,7 +18,8 @@ name = "actix_utils"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-service = "0.3.2" #actix-service = "0.3.2"
actix-service = { path="../actix-service" }
actix-codec = "0.1.0" actix-codec = "0.1.0"
bytes = "0.4" bytes = "0.4"
futures = "0.1.24" futures = "0.1.24"

View File

@ -102,8 +102,8 @@ where
fn new_service(&self, cfg: &C) -> Self::Future { fn new_service(&self, cfg: &C) -> Self::Future {
match self { match self {
Either::A(ref inner) => EitherNewService::A(inner.new_service(cfg).into_future()), Either::A(ref inner) => EitherNewService::A(inner.new_service(cfg)),
Either::B(ref inner) => EitherNewService::B(inner.new_service(cfg).into_future()), Either::B(ref inner) => EitherNewService::B(inner.new_service(cfg)),
} }
} }
} }

View File

@ -120,7 +120,7 @@ where
fn call(&mut self, req: Framed<T, U>) -> Self::Future { fn call(&mut self, req: Framed<T, U>) -> Self::Future {
FramedServiceResponseFuture { FramedServiceResponseFuture {
fut: self.factory.new_service(&self.config).into_future(), fut: self.factory.new_service(&self.config),
framed: Some(req), framed: Some(req),
} }
} }

View File

@ -4,7 +4,7 @@ use std::rc::Rc;
use actix_service::{IntoNewService, IntoService, NewService, Service}; use actix_service::{IntoNewService, IntoService, NewService, Service};
use futures::future::{ok, Future, FutureResult}; use futures::future::{ok, Future, FutureResult};
use futures::unsync::mpsc; use futures::unsync::mpsc;
use futures::{Async, IntoFuture, Poll, Stream}; use futures::{Async, Poll, Stream};
type Request<T> = Result<<T as IntoStream>::Item, <T as IntoStream>::Error>; type Request<T> = Result<<T as IntoStream>::Item, <T as IntoStream>::Error>;
@ -113,7 +113,6 @@ where
Box::new( Box::new(
self.factory self.factory
.new_service(&self.config) .new_service(&self.config)
.into_future()
.and_then(move |srv| StreamDispatcher::new(req, srv)), .and_then(move |srv| StreamDispatcher::new(req, srv)),
) )
} }