diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index b754172b..8850b674 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## [0.3.4] - 2019-03-12 + +### Changed + +* `TimeoutService`, `InOrderService`, `InFlightService` accepts generic IntoService services. + ## [0.3.3] - 2019-03-09 ### Changed diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 6f00179e..79530e9f 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "0.3.3" +version = "0.3.4" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-utils/src/inflight.rs b/actix-utils/src/inflight.rs index 41955f35..89858f87 100644 --- a/actix-utils/src/inflight.rs +++ b/actix-utils/src/inflight.rs @@ -1,4 +1,4 @@ -use actix_service::{Service, Transform, Void}; +use actix_service::{IntoService, Service, Transform, Void}; use futures::future::{ok, FutureResult}; use futures::{Async, Future, Poll}; @@ -42,11 +42,17 @@ pub struct InFlightService { service: S, } -impl InFlightService { - pub fn new(max: usize, service: S) -> Self { +impl InFlightService +where + S: Service, +{ + pub fn new(max: usize, service: U) -> Self + where + U: IntoService, + { Self { - service, count: Counter::new(max), + service: service.into_service(), } } } diff --git a/actix-utils/src/order.rs b/actix-utils/src/order.rs index b267a0b4..2b29a284 100644 --- a/actix-utils/src/order.rs +++ b/actix-utils/src/order.rs @@ -3,7 +3,7 @@ use std::fmt; use std::marker::PhantomData; use std::rc::Rc; -use actix_service::{Service, Transform, Void}; +use actix_service::{IntoService, Service, Transform, Void}; use futures::future::{ok, FutureResult}; use futures::task::AtomicTask; use futures::unsync::oneshot; @@ -112,9 +112,12 @@ where S::Future: 'static, S::Error: 'static, { - pub fn new(service: S) -> Self { + pub fn new(service: U) -> Self + where + U: IntoService, + { Self { - service, + service: service.into_service(), acks: VecDeque::new(), task: Rc::new(AtomicTask::new()), } diff --git a/actix-utils/src/timeout.rs b/actix-utils/src/timeout.rs index 85d69731..37fd5df1 100644 --- a/actix-utils/src/timeout.rs +++ b/actix-utils/src/timeout.rs @@ -6,7 +6,7 @@ use std::fmt; use std::marker::PhantomData; use std::time::Duration; -use actix_service::{Service, Transform}; +use actix_service::{IntoService, Service, Transform}; use futures::future::{ok, FutureResult}; use futures::{Async, Future, Poll}; use tokio_timer::{clock, Delay}; @@ -106,9 +106,18 @@ pub struct TimeoutService { timeout: Duration, } -impl TimeoutService { - pub fn new(timeout: Duration, service: S) -> Self { - TimeoutService { service, timeout } +impl TimeoutService +where + S: Service, +{ + pub fn new(timeout: Duration, service: U) -> Self + where + U: IntoService, + { + TimeoutService { + timeout, + service: service.into_service(), + } } }