embedded_nal_async

Trait TcpConnect

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: TcpConnect> TcpConnect for &T

Source§

type Error = <T as TcpConnect>::Error

Source§

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§