From 15dafeff3daad33e6aaf7e4666ee286737f8376d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 4 Mar 2019 20:37:03 -0800 Subject: [PATCH] use IntoFuture instead of Future --- actix-utils/CHANGES.md | 7 +++++++ actix-utils/Cargo.toml | 4 ++-- actix-utils/src/either.rs | 10 +++++----- actix-utils/src/framed.rs | 6 +++--- actix-utils/src/stream.rs | 3 ++- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index 05a89916..64c361a1 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.3.2] - 2019-03-04 + +### Changed + +* Use IntoFuture for new services + + ## [0.3.1] - 2019-03-04 ### Changed diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 23c7361a..1862ed6d 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "0.3.1" +version = "0.3.2" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] @@ -18,7 +18,7 @@ name = "actix_utils" path = "src/lib.rs" [dependencies] -actix-service = "0.3.1" +actix-service = "0.3.2" actix-codec = "0.1.0" bytes = "0.4" futures = "0.1.24" diff --git a/actix-utils/src/either.rs b/actix-utils/src/either.rs index 8946ba9b..71f99f26 100644 --- a/actix-utils/src/either.rs +++ b/actix-utils/src/either.rs @@ -1,6 +1,6 @@ //! Contains `Either` service and related types and functions. use actix_service::{NewService, Service}; -use futures::{future, try_ready, Async, Future, Poll}; +use futures::{future, try_ready, Async, Future, IntoFuture, Poll}; /// Combine two different service types into a single type. /// @@ -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)), - Either::B(ref inner) => EitherNewService::B(inner.new_service(cfg)), + Either::A(ref inner) => EitherNewService::A(inner.new_service(cfg).into_future()), + Either::B(ref inner) => EitherNewService::B(inner.new_service(cfg).into_future()), } } } @@ -119,8 +119,8 @@ impl Clone for Either { #[doc(hidden)] pub enum EitherNewService, B: NewService, C> { - A(A::Future), - B(B::Future), + A(::Future), + B(::Future), } impl Future for EitherNewService diff --git a/actix-utils/src/framed.rs b/actix-utils/src/framed.rs index cee68ba9..e0719069 100644 --- a/actix-utils/src/framed.rs +++ b/actix-utils/src/framed.rs @@ -7,7 +7,7 @@ use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed}; use actix_service::{IntoNewService, IntoService, NewService, Service}; use futures::future::{ok, FutureResult}; use futures::task::AtomicTask; -use futures::{Async, Future, Poll, Sink, Stream}; +use futures::{Async, Future, IntoFuture, Poll, Sink, Stream}; use log::debug; use crate::cell::Cell; @@ -120,7 +120,7 @@ where fn call(&mut self, req: Framed) -> Self::Future { FramedServiceResponseFuture { - fut: self.factory.new_service(&self.config), + fut: self.factory.new_service(&self.config).into_future(), framed: Some(req), } } @@ -137,7 +137,7 @@ where ::Item: 'static, ::Error: std::fmt::Debug, { - fut: S::Future, + fut: ::Future, framed: Option>, } diff --git a/actix-utils/src/stream.rs b/actix-utils/src/stream.rs index e98659c9..f871c758 100644 --- a/actix-utils/src/stream.rs +++ b/actix-utils/src/stream.rs @@ -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, Poll, Stream}; +use futures::{Async, IntoFuture, Poll, Stream}; type Request = Result<::Item, ::Error>; @@ -113,6 +113,7 @@ where Box::new( self.factory .new_service(&self.config) + .into_future() .and_then(move |srv| StreamDispatcher::new(req, srv)), ) }