AddrListener

Trait AddrListener 

Source
pub trait AddrListener<Stream, Addr: Address>: Sized {
    // Required methods
    fn bind_to(addr: Addr) -> impl Future<Output = Result<Self>> + Send;
    fn accept_stream(
        &self,
    ) -> impl Future<Output = Result<(Stream, Addr)>> + Send;
    fn get_local_addr(&self) -> Result<Addr>;
}
Expand description

A trait to abstract over a listener that can accept an incoming connection of different types and can be created from an address.

Required Methods§

Source

fn bind_to(addr: Addr) -> impl Future<Output = Result<Self>> + Send

Create a new AddrListener bound to the given address.

Source

fn accept_stream(&self) -> impl Future<Output = Result<(Stream, Addr)>> + Send

Accept an incoming connection, returning the stream and the remote address.

Source

fn get_local_addr(&self) -> Result<Addr>

Get the address we’re listening on.

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 AddrListener<TcpStream, SocketAddr> for TcpListener

Source§

impl AddrListener<UnixStream, SocketAddr> for UnixListener

Available on Unix only.

Implementors§