1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 21:51:06 +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"]
[dependencies]
actix-service = "0.3.2"
#actix-service = "0.3.2"
actix-service = { path="../actix-service" }
actix-rt = "0.1.0"
log = "0.4"

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::{fmt, io, net};
use actix_service::{IntoNewService, NewService};
use futures::future::{join_all, Future, IntoFuture};
use futures::future::{join_all, Future};
use log::error;
use tokio_tcp::TcpStream;
@ -223,7 +223,6 @@ where
Box::new(
self.inner
.new_service(&())
.into_future()
.map_err(|_| ())
.map(|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_service::{NewService, Service};
use futures::future::{err, ok, FutureResult, IntoFuture};
use futures::future::{err, ok, FutureResult};
use futures::{Future, Poll};
use log::error;
use tokio_reactor::Handle;
@ -129,7 +129,6 @@ where
self.inner
.create()
.new_service(&())
.into_future()
.map_err(|_| ())
.map(move |inner| {
let service: BoxedServerService = Box::new(StreamService::new(inner));

View File

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

View File

@ -1,6 +1,6 @@
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 crate::cell::Cell;
@ -142,10 +142,7 @@ where
type Future = AndThenNewServiceFuture<A, B, C>;
fn new_service(&self, cfg: &C) -> Self::Future {
AndThenNewServiceFuture::new(
self.a.new_service(cfg).into_future(),
self.b.new_service(cfg).into_future(),
)
AndThenNewServiceFuture::new(self.a.new_service(cfg), self.b.new_service(cfg))
}
}
@ -168,8 +165,8 @@ where
A: NewService<C>,
B: NewService<C, Request = A::Response>,
{
fut_b: <B::Future as IntoFuture>::Future,
fut_a: <A::Future as IntoFuture>::Future,
fut_b: B::Future,
fut_a: A::Future,
a: Option<A::Service>,
b: Option<B::Service>,
}
@ -179,10 +176,7 @@ where
A: NewService<C>,
B: NewService<C, Request = A::Response>,
{
fn new(
fut_a: <A::Future as IntoFuture>::Future,
fut_b: <B::Future as IntoFuture>::Future,
) -> Self {
fn new(fut_a: A::Future, fut_b: B::Future) -> Self {
AndThenNewServiceFuture {
fut_a,
fut_b,

View File

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

View File

@ -124,7 +124,7 @@ where
type Future = ApplyNewServiceFuture<T, F, In, Out, Cfg>;
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,
Out: IntoFuture,
{
fut: <T::Future as IntoFuture>::Future,
fut: T::Future,
f: Option<F>,
r: PhantomData<(In, Out)>,
}
@ -145,7 +145,7 @@ where
F: FnMut(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture,
{
fn new(fut: <T::Future as IntoFuture>::Future, f: F) -> Self {
fn new(fut: T::Future, f: F) -> Self {
ApplyNewServiceFuture {
f: Some(f),
fut,

View File

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

View File

@ -199,7 +199,7 @@ pub trait NewService<Config = ()> {
type InitError;
/// 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.
fn new_service(&self, cfg: &Config) -> Self::Future;

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use futures::{Async, Future, IntoFuture, Poll};
use futures::{Async, Future, Poll};
use super::{NewService, Service};
@ -146,7 +146,7 @@ where
type Future = MapNewServiceFuture<A, F, Res, Cfg>;
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>,
F: FnMut(A::Response) -> Res,
{
fut: <A::Future as IntoFuture>::Future,
fut: A::Future,
f: Option<F>,
}
@ -164,7 +164,7 @@ where
A: NewService<Cfg>,
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 }
}
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use futures::{Async, Future, IntoFuture, Poll};
use futures::{Async, Future, Poll};
use super::{NewService, Service};
@ -147,7 +147,7 @@ where
type Future = MapErrNewServiceFuture<A, F, E, C>;
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>,
F: Fn(A::Error) -> E,
{
fut: <A::Future as IntoFuture>::Future,
fut: A::Future,
f: F,
}
@ -165,7 +165,7 @@ where
A: NewService<C>,
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 }
}
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use futures::{Future, IntoFuture, Poll};
use futures::{Future, Poll};
use super::NewService;
@ -54,7 +54,7 @@ where
type Future = MapInitErrFuture<A, F, E, C>;
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: F,
fut: <A::Future as IntoFuture>::Future,
fut: A::Future,
}
impl<A, F, E, C> MapInitErrFuture<A, F, E, C>
@ -72,7 +72,7 @@ where
A: NewService<C>,
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 }
}
}

View File

@ -1,6 +1,6 @@
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 crate::cell::Cell;
@ -157,10 +157,7 @@ where
type Future = ThenNewServiceFuture<A, B, C>;
fn new_service(&self, cfg: &C) -> Self::Future {
ThenNewServiceFuture::new(
self.a.new_service(cfg).into_future(),
self.b.new_service(cfg).into_future(),
)
ThenNewServiceFuture::new(self.a.new_service(cfg), self.b.new_service(cfg))
}
}
@ -188,8 +185,8 @@ where
InitError = A::InitError,
>,
{
fut_b: <B::Future as IntoFuture>::Future,
fut_a: <A::Future as IntoFuture>::Future,
fut_b: B::Future,
fut_a: A::Future,
a: Option<A::Service>,
b: Option<B::Service>,
}
@ -204,10 +201,7 @@ where
InitError = A::InitError,
>,
{
fn new(
fut_a: <A::Future as IntoFuture>::Future,
fut_b: <B::Future as IntoFuture>::Future,
) -> Self {
fn new(fut_a: A::Future, fut_b: B::Future) -> Self {
ThenNewServiceFuture {
fut_a,
fut_b,

View File

@ -31,7 +31,7 @@ pub trait Transform<S> {
type InitError;
/// 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.
fn new_transform(&self, service: S) -> Self::Future;
@ -147,7 +147,7 @@ where
A: NewService<C>,
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>,
t_cell: Rc<T>,
}

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ use std::rc::Rc;
use actix_service::{IntoNewService, IntoService, NewService, Service};
use futures::future::{ok, Future, FutureResult};
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>;
@ -113,7 +113,6 @@ where
Box::new(
self.factory
.new_service(&self.config)
.into_future()
.and_then(move |srv| StreamDispatcher::new(req, srv)),
)
}