use crate::SocketAddr;
pub trait TcpConnect {
type Error: embedded_io_async::Error;
type Connection<'a>: embedded_io_async::Read<Error = Self::Error>
+ embedded_io_async::Write<Error = Self::Error>
where
Self: 'a;
async fn connect<'a>(&'a self, remote: SocketAddr)
-> Result<Self::Connection<'a>, Self::Error>;
}
impl<T: TcpConnect> TcpConnect for &T {
type Error = T::Error;
type Connection<'a> = T::Connection<'a> where Self: 'a;
async fn connect<'a>(
&'a self,
remote: SocketAddr,
) -> Result<Self::Connection<'a>, Self::Error> {
T::connect(self, remote).await
}
}