mirror of
https://github.com/fafhrd91/actix-net
synced 2025-06-28 20:10:35 +02:00
Use associated type for NewService config
This commit is contained in:
@ -30,6 +30,7 @@ impl<T: Address> NewService for TcpConnectorFactory<T> {
|
||||
type Request = Connect<T>;
|
||||
type Response = Connection<T, TcpStream>;
|
||||
type Error = ConnectError;
|
||||
type Config = ();
|
||||
type Service = TcpConnector<T>;
|
||||
type InitError = ();
|
||||
type Future = FutureResult<Self::Service, Self::InitError>;
|
||||
|
@ -31,17 +31,6 @@ pub use self::resolver::{Resolver, ResolverFactory};
|
||||
use actix_service::{NewService, Service, ServiceExt};
|
||||
use tokio_tcp::TcpStream;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(since = "0.1.2", note = "please use `actix_connect::TcpConnector`")]
|
||||
pub type Connector<T> = TcpConnector<T>;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(
|
||||
since = "0.1.2",
|
||||
note = "please use `actix_connect::TcpConnectorFactory`"
|
||||
)]
|
||||
pub type ConnectorFactory<T> = TcpConnectorFactory<T>;
|
||||
|
||||
pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver {
|
||||
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
||||
tokio_current_thread::spawn(bg);
|
||||
@ -90,6 +79,7 @@ pub fn new_connector<T: Address>(
|
||||
pub fn new_connector_factory<T: Address>(
|
||||
resolver: AsyncResolver,
|
||||
) -> impl NewService<
|
||||
Config = (),
|
||||
Request = Connect<T>,
|
||||
Response = Connection<T, TcpStream>,
|
||||
Error = ConnectError,
|
||||
@ -107,6 +97,7 @@ pub fn default_connector<T: Address>(
|
||||
|
||||
/// Create connector service factory with default parameters
|
||||
pub fn default_connector_factory<T: Address>() -> impl NewService<
|
||||
Config = (),
|
||||
Request = Connect<T>,
|
||||
Response = Connection<T, TcpStream>,
|
||||
Error = ConnectError,
|
||||
|
@ -50,6 +50,7 @@ impl<T: Address> NewService for ResolverFactory<T> {
|
||||
type Request = Connect<T>;
|
||||
type Response = Connect<T>;
|
||||
type Error = ConnectError;
|
||||
type Config = ();
|
||||
type Service = Resolver<T>;
|
||||
type InitError = ();
|
||||
type Future = FutureResult<Self::Service, Self::InitError>;
|
||||
|
@ -52,13 +52,14 @@ impl<T, U> Clone for OpensslConnector<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Address, U> NewService<()> for OpensslConnector<T, U>
|
||||
impl<T: Address, U> NewService for OpensslConnector<T, U>
|
||||
where
|
||||
U: AsyncRead + AsyncWrite + fmt::Debug,
|
||||
{
|
||||
type Request = Connection<T, U>;
|
||||
type Response = Connection<T, SslStream<U>>;
|
||||
type Error = HandshakeError<U>;
|
||||
type Config = ();
|
||||
type Service = OpensslConnectorService<T, U>;
|
||||
type InitError = ();
|
||||
type Future = FutureResult<Self::Service, Self::InitError>;
|
||||
|
Reference in New Issue
Block a user