From 3e6bdbd9eee2b965eb97dea30e0e45c71ceffce6 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 29 Jan 2019 10:34:27 -0800 Subject: [PATCH] rename trait --- Cargo.toml | 2 +- src/client/connection.rs | 6 +++--- src/client/connector.rs | 4 ++-- src/client/mod.rs | 2 +- src/client/request.rs | 4 ++-- src/h1/decoder.rs | 5 +---- test-server/src/lib.rs | 10 +++++----- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 01aa1a0c..88a9ba88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ serde_urlencoded = "0.5.3" time = "0.1" tokio-timer = "0.2" tokio-current-thread = "0.1" -trust-dns-resolver = { version="0.11.0-alpha.1", default-features = false } +trust-dns-resolver = { version="0.11.0-alpha.2", default-features = false } # openssl openssl = { version="0.10", optional = true } diff --git a/src/client/connection.rs b/src/client/connection.rs index b192caae..683738e2 100644 --- a/src/client/connection.rs +++ b/src/client/connection.rs @@ -18,7 +18,7 @@ pub(crate) enum ConnectionType { H2(SendRequest), } -pub trait RequestSender { +pub trait Connection { type Future: Future; /// Close connection @@ -76,7 +76,7 @@ impl IoConnection { } } -impl RequestSender for IoConnection +impl Connection for IoConnection where T: AsyncRead + AsyncWrite + 'static, { @@ -112,7 +112,7 @@ pub(crate) enum EitherConnection { B(IoConnection), } -impl RequestSender for EitherConnection +impl Connection for EitherConnection where A: AsyncRead + AsyncWrite + 'static, B: AsyncRead + AsyncWrite + 'static, diff --git a/src/client/connector.rs b/src/client/connector.rs index 5b5356c7..05e24e51 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -7,7 +7,7 @@ use actix_utils::timeout::{TimeoutError, TimeoutService}; use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; use super::connect::Connect; -use super::connection::RequestSender; +use super::connection::Connection; use super::error::ConnectorError; use super::pool::{ConnectionPool, Protocol}; @@ -135,7 +135,7 @@ impl Connector { /// Finish configuration process and create connector service. pub fn service( self, - ) -> impl Service + Clone + ) -> impl Service + Clone { #[cfg(not(feature = "ssl"))] { diff --git a/src/client/mod.rs b/src/client/mod.rs index c6498f37..8d041827 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -10,7 +10,7 @@ mod request; mod response; pub use self::connect::Connect; -pub use self::connection::RequestSender; +pub use self::connection::Connection; pub use self::connector::Connector; pub use self::error::{ConnectorError, InvalidUrlKind, SendRequestError}; pub use self::request::{ClientRequest, ClientRequestBuilder}; diff --git a/src/client/request.rs b/src/client/request.rs index a2233a2f..b62ebaf3 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -17,7 +17,7 @@ use crate::http::{ }; use crate::message::{ConnectionType, Head, RequestHead}; -use super::connection::RequestSender; +use super::connection::Connection; use super::response::ClientResponse; use super::{Connect, ConnectorError, SendRequestError}; @@ -177,7 +177,7 @@ where where B: 'static, T: Service, - I: RequestSender, + I: Connection, { let Self { head, body } = self; diff --git a/src/h1/decoder.rs b/src/h1/decoder.rs index 48086478..74e1fb68 100644 --- a/src/h1/decoder.rs +++ b/src/h1/decoder.rs @@ -604,10 +604,7 @@ impl ChunkedState { #[cfg(test)] mod tests { - use std::{cmp, io}; - - use actix_codec::{AsyncRead, AsyncWrite}; - use bytes::{Buf, Bytes, BytesMut}; + use bytes::{Bytes, BytesMut}; use http::{Method, Version}; use super::*; diff --git a/test-server/src/lib.rs b/test-server/src/lib.rs index cd74d456..1ef45204 100644 --- a/test-server/src/lib.rs +++ b/test-server/src/lib.rs @@ -13,8 +13,8 @@ use net2::TcpBuilder; use actix_http::body::MessageBody; use actix_http::client::{ - ClientRequest, ClientRequestBuilder, ClientResponse, Connect, Connector, - ConnectorError, RequestSender, SendRequestError, + ClientRequest, ClientRequestBuilder, ClientResponse, Connect, Connection, Connector, + ConnectorError, SendRequestError, }; use actix_http::ws; @@ -57,7 +57,7 @@ impl TestServer { pub fn with_factory( factory: F, ) -> TestServerRuntime< - impl Service + Clone, + impl Service + Clone, > { let (tx, rx) = mpsc::channel(); @@ -89,7 +89,7 @@ impl TestServer { } fn new_connector( - ) -> impl Service + Clone + ) -> impl Service + Clone { #[cfg(feature = "ssl")] { @@ -192,7 +192,7 @@ impl TestServerRuntime { impl TestServerRuntime where T: Service + Clone, - T::Response: RequestSender, + T::Response: Connection, { /// Connect to websocket server at a given path pub fn ws_at(