From e37d0f7981949e200a71db27e51007efedd53eff Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sat, 2 Jan 2021 12:39:44 +0900 Subject: [PATCH 1/2] Remove dependency on `hyper`'s `http1` and `tcp` features --- Cargo.toml | 3 ++- src/lib.rs | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f898bd0..2272c3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,13 @@ readme = "README.md" [dependencies] bytes = "1.0.0" -hyper = { version = "0.14", default-features = false, features = ["client", "http1", "tcp"] } +hyper = { version = "0.14.2", features = ["client"] } pin-project-lite = "0.2" tokio = "1.0.0" tokio-io-timeout = "1.0.1" [dev-dependencies] +hyper = { version = "0.14", features = ["client", "http1", "tcp"] } #FIXME enable when https://github.com/hyperium/hyper-tls/pull/79 lands #hyper-tls = "0.4" tokio = { version = "1.0.0", features = ["io-std", "io-util", "macros"] } diff --git a/src/lib.rs b/src/lib.rs index 6b9f49e..c2e4285 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::timeout; use tokio_io_timeout::TimeoutStream; -use hyper::client::connect::{Connect, Connected, Connection}; +use hyper::client::connect::{Connected, Connection}; use hyper::{service::Service, Uri}; mod stream; @@ -30,7 +30,13 @@ pub struct TimeoutConnector { write_timeout: Option, } -impl TimeoutConnector { +impl TimeoutConnector +where + T: Service + Send, + T::Response: AsyncRead + AsyncWrite + Send + Unpin, + T::Future: Send + 'static, + T::Error: Into, +{ /// Construct a new TimeoutConnector with a given connector implementing the `Connect` trait pub fn new(connector: T) -> Self { TimeoutConnector { @@ -116,9 +122,12 @@ impl TimeoutConnector { } } -impl Connection for TimeoutConnector +impl Connection for TimeoutConnector where - T: AsyncRead + AsyncWrite + Connection + Unpin, + T: AsyncRead + AsyncWrite + Connection + Service + Send + Unpin, + T::Response: AsyncRead + AsyncWrite + Send + Unpin, + T::Future: Send + 'static, + T::Error: Into, { fn connected(&self) -> Connected { self.connector.connected() From 69f5d452b10c44ce81625435a08e209aa21f473d Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sat, 2 Jan 2021 12:40:55 +0900 Subject: [PATCH 2/2] Remove `bytes` dependency --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2272c3f..d56c916 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ repository = "https://github.com/hjr3/hyper-timeout" readme = "README.md" [dependencies] -bytes = "1.0.0" hyper = { version = "0.14.2", features = ["client"] } pin-project-lite = "0.2" tokio = "1.0.0"