mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
rename trait
This commit is contained in:
parent
9a4eb5a848
commit
3e6bdbd9ee
@ -70,7 +70,7 @@ serde_urlencoded = "0.5.3"
|
|||||||
time = "0.1"
|
time = "0.1"
|
||||||
tokio-timer = "0.2"
|
tokio-timer = "0.2"
|
||||||
tokio-current-thread = "0.1"
|
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
|
||||||
openssl = { version="0.10", optional = true }
|
openssl = { version="0.10", optional = true }
|
||||||
|
@ -18,7 +18,7 @@ pub(crate) enum ConnectionType<Io> {
|
|||||||
H2(SendRequest<Bytes>),
|
H2(SendRequest<Bytes>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait RequestSender {
|
pub trait Connection {
|
||||||
type Future: Future<Item = ClientResponse, Error = SendRequestError>;
|
type Future: Future<Item = ClientResponse, Error = SendRequestError>;
|
||||||
|
|
||||||
/// Close connection
|
/// 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
|
where
|
||||||
T: AsyncRead + AsyncWrite + 'static,
|
T: AsyncRead + AsyncWrite + 'static,
|
||||||
{
|
{
|
||||||
@ -112,7 +112,7 @@ pub(crate) enum EitherConnection<A, B> {
|
|||||||
B(IoConnection<B>),
|
B(IoConnection<B>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B> RequestSender for EitherConnection<A, B>
|
impl<A, B> Connection for EitherConnection<A, B>
|
||||||
where
|
where
|
||||||
A: AsyncRead + AsyncWrite + 'static,
|
A: AsyncRead + AsyncWrite + 'static,
|
||||||
B: AsyncRead + AsyncWrite + 'static,
|
B: AsyncRead + AsyncWrite + 'static,
|
||||||
|
@ -7,7 +7,7 @@ use actix_utils::timeout::{TimeoutError, TimeoutService};
|
|||||||
use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
|
use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
|
||||||
|
|
||||||
use super::connect::Connect;
|
use super::connect::Connect;
|
||||||
use super::connection::RequestSender;
|
use super::connection::Connection;
|
||||||
use super::error::ConnectorError;
|
use super::error::ConnectorError;
|
||||||
use super::pool::{ConnectionPool, Protocol};
|
use super::pool::{ConnectionPool, Protocol};
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ impl Connector {
|
|||||||
/// Finish configuration process and create connector service.
|
/// Finish configuration process and create connector service.
|
||||||
pub fn service(
|
pub fn service(
|
||||||
self,
|
self,
|
||||||
) -> impl Service<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone
|
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
|
||||||
{
|
{
|
||||||
#[cfg(not(feature = "ssl"))]
|
#[cfg(not(feature = "ssl"))]
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ mod request;
|
|||||||
mod response;
|
mod response;
|
||||||
|
|
||||||
pub use self::connect::Connect;
|
pub use self::connect::Connect;
|
||||||
pub use self::connection::RequestSender;
|
pub use self::connection::Connection;
|
||||||
pub use self::connector::Connector;
|
pub use self::connector::Connector;
|
||||||
pub use self::error::{ConnectorError, InvalidUrlKind, SendRequestError};
|
pub use self::error::{ConnectorError, InvalidUrlKind, SendRequestError};
|
||||||
pub use self::request::{ClientRequest, ClientRequestBuilder};
|
pub use self::request::{ClientRequest, ClientRequestBuilder};
|
||||||
|
@ -17,7 +17,7 @@ use crate::http::{
|
|||||||
};
|
};
|
||||||
use crate::message::{ConnectionType, Head, RequestHead};
|
use crate::message::{ConnectionType, Head, RequestHead};
|
||||||
|
|
||||||
use super::connection::RequestSender;
|
use super::connection::Connection;
|
||||||
use super::response::ClientResponse;
|
use super::response::ClientResponse;
|
||||||
use super::{Connect, ConnectorError, SendRequestError};
|
use super::{Connect, ConnectorError, SendRequestError};
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ where
|
|||||||
where
|
where
|
||||||
B: 'static,
|
B: 'static,
|
||||||
T: Service<Connect, Response = I, Error = ConnectorError>,
|
T: Service<Connect, Response = I, Error = ConnectorError>,
|
||||||
I: RequestSender,
|
I: Connection,
|
||||||
{
|
{
|
||||||
let Self { head, body } = self;
|
let Self { head, body } = self;
|
||||||
|
|
||||||
|
@ -604,10 +604,7 @@ impl ChunkedState {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{cmp, io};
|
use bytes::{Bytes, BytesMut};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite};
|
|
||||||
use bytes::{Buf, Bytes, BytesMut};
|
|
||||||
use http::{Method, Version};
|
use http::{Method, Version};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -13,8 +13,8 @@ use net2::TcpBuilder;
|
|||||||
|
|
||||||
use actix_http::body::MessageBody;
|
use actix_http::body::MessageBody;
|
||||||
use actix_http::client::{
|
use actix_http::client::{
|
||||||
ClientRequest, ClientRequestBuilder, ClientResponse, Connect, Connector,
|
ClientRequest, ClientRequestBuilder, ClientResponse, Connect, Connection, Connector,
|
||||||
ConnectorError, RequestSender, SendRequestError,
|
ConnectorError, SendRequestError,
|
||||||
};
|
};
|
||||||
use actix_http::ws;
|
use actix_http::ws;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ impl TestServer {
|
|||||||
pub fn with_factory<F: StreamServiceFactory>(
|
pub fn with_factory<F: StreamServiceFactory>(
|
||||||
factory: F,
|
factory: F,
|
||||||
) -> TestServerRuntime<
|
) -> TestServerRuntime<
|
||||||
impl Service<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone,
|
impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone,
|
||||||
> {
|
> {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ impl TestServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn new_connector(
|
fn new_connector(
|
||||||
) -> impl Service<Connect, Response = impl RequestSender, Error = ConnectorError> + Clone
|
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
|
||||||
{
|
{
|
||||||
#[cfg(feature = "ssl")]
|
#[cfg(feature = "ssl")]
|
||||||
{
|
{
|
||||||
@ -192,7 +192,7 @@ impl<T> TestServerRuntime<T> {
|
|||||||
impl<T> TestServerRuntime<T>
|
impl<T> TestServerRuntime<T>
|
||||||
where
|
where
|
||||||
T: Service<Connect, Error = ConnectorError> + Clone,
|
T: Service<Connect, Error = ConnectorError> + Clone,
|
||||||
T::Response: RequestSender,
|
T::Response: Connection,
|
||||||
{
|
{
|
||||||
/// Connect to websocket server at a given path
|
/// Connect to websocket server at a given path
|
||||||
pub fn ws_at(
|
pub fn ws_at(
|
||||||
|
Loading…
Reference in New Issue
Block a user