pub trait TcpConnect {
    type Error: Error;
    type Connection<'a>: Read<Error = Self::Error> + Write<Error = Self::Error>
       where Self: 'a;

    // Required method
    async fn connect<'a>(
        &'a self,
        remote: SocketAddr
    ) -> Result<Self::Connection<'a>, Self::Error>;
}
Expand description

This trait is implemented by TCP/IP stacks. The trait allows the underlying driver to construct multiple connections that implement the I/O traits from embedded-io-async.

The associated connection type should close the connection when dropped.

Required Associated Types§

source

type Error: Error

Error type returned on connect failure.

source

type Connection<'a>: Read<Error = Self::Error> + Write<Error = Self::Error> where Self: 'a

Type holding state of a TCP connection. Should close the connection when dropped.

Required Methods§

source

async fn connect<'a>( &'a self, remote: SocketAddr ) -> Result<Self::Connection<'a>, Self::Error>

Connect to the given remote host and port.

Returns Ok if the connection was successful.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: TcpConnect> TcpConnect for &T

§

type Error = <T as TcpConnect>::Error

§

type Connection<'a> = <T as TcpConnect>::Connection<'a> where Self: 'a

source§

async fn connect<'a>( &'a self, remote: SocketAddr ) -> Result<Self::Connection<'a>, Self::Error>

Implementors§