1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 07:30:36 +02:00

cleanup Unpin constraint; simplify Framed impl

This commit is contained in:
Nikolay Kim
2019-11-19 14:51:40 +06:00
parent 617e40a7e9
commit 3bf83c1d98
30 changed files with 493 additions and 1252 deletions

View File

@ -18,7 +18,7 @@ pub struct ConnectServiceFactory<T> {
resolver: ResolverFactory<T>,
}
impl<T: Unpin> ConnectServiceFactory<T> {
impl<T> ConnectServiceFactory<T> {
/// Construct new ConnectService factory
pub fn new() -> Self {
ConnectServiceFactory {
@ -70,7 +70,7 @@ impl<T> Clone for ConnectServiceFactory<T> {
}
}
impl<T: Address + Unpin> ServiceFactory for ConnectServiceFactory<T> {
impl<T: Address> ServiceFactory for ConnectServiceFactory<T> {
type Request = Connect<T>;
type Response = Connection<T, TcpStream>;
type Error = ConnectError;
@ -90,7 +90,7 @@ pub struct ConnectService<T> {
resolver: Resolver<T>,
}
impl<T: Address + Unpin> Service for ConnectService<T> {
impl<T: Address> Service for ConnectService<T> {
type Request = Connect<T>;
type Response = Connection<T, TcpStream>;
type Error = ConnectError;
@ -108,12 +108,12 @@ impl<T: Address + Unpin> Service for ConnectService<T> {
}
}
enum ConnectState<T: Address + Unpin> {
enum ConnectState<T: Address> {
Resolve(<Resolver<T> as Service>::Future),
Connect(<TcpConnector<T> as Service>::Future),
}
impl<T: Address + Unpin> ConnectState<T> {
impl<T: Address> ConnectState<T> {
fn poll(
&mut self,
cx: &mut Context,
@ -129,12 +129,12 @@ impl<T: Address + Unpin> ConnectState<T> {
}
}
pub struct ConnectServiceResponse<T: Address + Unpin> {
pub struct ConnectServiceResponse<T: Address> {
state: ConnectState<T>,
tcp: TcpConnector<T>,
}
impl<T: Address + Unpin> Future for ConnectServiceResponse<T> {
impl<T: Address> Future for ConnectServiceResponse<T> {
type Output = Result<Connection<T, TcpStream>, ConnectError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
@ -159,7 +159,7 @@ pub struct TcpConnectService<T> {
resolver: Resolver<T>,
}
impl<T: Address + Unpin + 'static> Service for TcpConnectService<T> {
impl<T: Address + 'static> Service for TcpConnectService<T> {
type Request = Connect<T>;
type Response = TcpStream;
type Error = ConnectError;
@ -177,12 +177,12 @@ impl<T: Address + Unpin + 'static> Service for TcpConnectService<T> {
}
}
enum TcpConnectState<T: Address + Unpin> {
enum TcpConnectState<T: Address> {
Resolve(<Resolver<T> as Service>::Future),
Connect(<TcpConnector<T> as Service>::Future),
}
impl<T: Address + Unpin> TcpConnectState<T> {
impl<T: Address> TcpConnectState<T> {
fn poll(
&mut self,
cx: &mut Context,
@ -206,12 +206,12 @@ impl<T: Address + Unpin> TcpConnectState<T> {
}
}
pub struct TcpConnectServiceResponse<T: Address + Unpin> {
pub struct TcpConnectServiceResponse<T: Address> {
state: TcpConnectState<T>,
tcp: TcpConnector<T>,
}
impl<T: Address + Unpin> Future for TcpConnectServiceResponse<T> {
impl<T: Address> Future for TcpConnectServiceResponse<T> {
type Output = Result<TcpStream, ConnectError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {

View File

@ -33,7 +33,7 @@ impl<T, U> OpensslConnector<T, U> {
impl<T, U> OpensslConnector<T, U>
where
T: Address + Unpin + 'static,
T: Address + 'static,
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug + 'static,
{
pub fn service(connector: SslConnector) -> OpensslConnectorService<T, U> {
@ -154,7 +154,7 @@ pub struct OpensslConnectServiceFactory<T> {
openssl: OpensslConnector<T, TcpStream>,
}
impl<T: Unpin> OpensslConnectServiceFactory<T> {
impl<T> OpensslConnectServiceFactory<T> {
/// Construct new OpensslConnectService factory
pub fn new(connector: SslConnector) -> Self {
OpensslConnectServiceFactory {

View File

@ -30,7 +30,7 @@ impl<T, U> RustlsConnector<T, U> {
impl<T, U> RustlsConnector<T, U>
where
T: Address + Unpin,
T: Address,
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug,
{
pub fn service(connector: Arc<ClientConfig>) -> RustlsConnectorService<T, U> {
@ -50,7 +50,7 @@ impl<T, U> Clone for RustlsConnector<T, U> {
}
}
impl<T: Address + Unpin, U> ServiceFactory for RustlsConnector<T, U>
impl<T: Address, U> ServiceFactory for RustlsConnector<T, U>
where
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug,
{
@ -84,7 +84,7 @@ impl<T, U> Clone for RustlsConnectorService<T, U> {
}
}
impl<T: Address + Unpin, U> Service for RustlsConnectorService<T, U>
impl<T: Address, U> Service for RustlsConnectorService<T, U>
where
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug,
{
@ -114,7 +114,7 @@ pub struct ConnectAsyncExt<T, U> {
stream: Option<Connection<T, ()>>,
}
impl<T: Address + Unpin, U> Future for ConnectAsyncExt<T, U>
impl<T: Address, U> Future for ConnectAsyncExt<T, U>
where
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug,
{