TransportListener

Trait TransportListener 

Source
pub trait TransportListener: Send + Sync {
    type Transport: Transport;
    type Error: Error + Send + Sync + 'static;

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

Listener trait for server-side transports.

Transport listeners accept incoming connections and produce transport instances for each connection.

Implementations include WebSocketListener and UnixListener (Unix only).

Required Associated Types§

Source

type Transport: Transport

The type of transport produced by this listener.

Source

type Error: Error + Send + Sync + 'static

The error type for listener operations.

Required Methods§

Source

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

Accept an incoming connection.

This method blocks until a new connection is available.

§Errors

Returns an error if accepting the connection failed.

Source

fn local_addr(&self) -> Option<String>

Get the local address the listener is bound to, if available.

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.

Implementors§