Skip to main content

TcpListenerTrait

Trait TcpListenerTrait 

Source
pub trait TcpListenerTrait:
    Send
    + Sync
    + 'static {
    type TcpStream: AsyncRead + AsyncWrite + Unpin + Send + 'static;

    // Required methods
    fn accept(
        &self,
    ) -> impl Future<Output = Result<(Self::TcpStream, String), Error>> + Send;
    fn local_addr(&self) -> Result<String, Error>;
}
Expand description

Trait for TCP listeners that can accept connections.

Required Associated Types§

Source

type TcpStream: AsyncRead + AsyncWrite + Unpin + Send + 'static

The TCP stream type that this listener produces.

Required Methods§

Source

fn accept( &self, ) -> impl Future<Output = Result<(Self::TcpStream, String), Error>> + Send

Accept a single incoming connection.

Source

fn local_addr(&self) -> Result<String, Error>

Get the local address this listener is bound to.

§Errors

Returns an io::Error if the local address cannot be retrieved from the underlying listener.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§