1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00

rename trait

This commit is contained in:
Nikolay Kim 2019-01-29 10:34:27 -08:00
parent 9a4eb5a848
commit 3e6bdbd9ee
7 changed files with 15 additions and 18 deletions

View File

@ -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 }

View File

@ -18,7 +18,7 @@ pub(crate) enum ConnectionType<Io> {
H2(SendRequest<Bytes>),
}
pub trait RequestSender {
pub trait Connection {
type Future: Future<Item = ClientResponse, Error = SendRequestError>;
/// Close connection
@ -76,7 +76,7 @@ impl<T: AsyncRead + AsyncWrite + 'static> IoConnection<T> {
}
}
impl<T> RequestSender for IoConnection<T>
impl<T> Connection for IoConnection<T>
where
T: AsyncRead + AsyncWrite + 'static,
{
@ -112,7 +112,7 @@ pub(crate) enum EitherConnection<A, B> {
B(IoConnection<B>),
}
impl<A, B> RequestSender for EitherConnection<A, B>
impl<A, B> Connection for EitherConnection<A, B>
where
A: AsyncRead + AsyncWrite + 'static,
B: AsyncRead + AsyncWrite + 'static,

View File

@ -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<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
{
#[cfg(not(feature = "ssl"))]
{

View File

@ -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};

View File

@ -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<Connect, Response = I, Error = ConnectorError>,
I: RequestSender,
I: Connection,
{
let Self { head, body } = self;

View File

@ -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::*;

View File

@ -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<F: StreamServiceFactory>(
factory: F,
) -> TestServerRuntime<
impl Service<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone,
impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone,
> {
let (tx, rx) = mpsc::channel();
@ -89,7 +89,7 @@ impl TestServer {
}
fn new_connector(
) -> impl Service<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
{
#[cfg(feature = "ssl")]
{
@ -192,7 +192,7 @@ impl<T> TestServerRuntime<T> {
impl<T> TestServerRuntime<T>
where
T: Service<Connect, Error = ConnectorError> + Clone,
T::Response: RequestSender,
T::Response: Connection,
{
/// Connect to websocket server at a given path
pub fn ws_at(