diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index a71e29a4..126dfd97 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -18,8 +18,7 @@ name = "actix_utils" path = "src/lib.rs" [dependencies] -#actix-service = "0.2.0" -actix-service = { git = "https://github.com/actix/actix-net.git" } +actix-service = "0.2.0" actix-codec = "0.1.0" bytes = "0.4" futures = "0.1" @@ -28,4 +27,7 @@ tokio-current-thread = "0.1" log = "0.4" [dev-dependencies] -actix-rt = "0.1" \ No newline at end of file +actix-rt = "0.1" + +[patch.crates-io] +actix-service = { git = "https://github.com/actix/actix-net.git" } diff --git a/actix-utils/src/timeout.rs b/actix-utils/src/timeout.rs index c5d2ee65..165dcde3 100644 --- a/actix-utils/src/timeout.rs +++ b/actix-utils/src/timeout.rs @@ -3,6 +3,7 @@ //! If the response does not complete within the specified timeout, the response //! will be aborted. use std::fmt; +use std::marker::PhantomData; use std::time::Duration; use actix_service::{NewTransform, Service, Transform}; @@ -12,8 +13,9 @@ use tokio_timer::{clock, Delay}; /// Applies a timeout to requests. #[derive(Debug, Clone)] -pub struct Timeout { +pub struct Timeout { timeout: Duration, + _t: PhantomData, } /// Timeout error @@ -54,20 +56,23 @@ impl PartialEq for TimeoutError { } } -impl Timeout { +impl Timeout { pub fn new(timeout: Duration) -> Self { - Timeout { timeout } + Timeout { + timeout, + _t: PhantomData, + } } } -impl NewTransform for Timeout +impl NewTransform for Timeout where S: Service, { type Request = S::Request; type Response = S::Response; type Error = TimeoutError; - type InitError = (); + type InitError = E; type Transform = TimeoutService; type Future = FutureResult;