Skip to main content

Listener

Trait Listener 

Source
pub trait Listener: Send + 'static {
    type Io: AsyncRead + AsyncWrite + Unpin + Send + 'static;
    type Addr: Send;

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

Types that can listen for connections.

Required Associated Types§

Source

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

The listener’s IO type.

Source

type Addr: Send

The listener’s address type.

Required Methods§

Source

fn accept(&mut self) -> impl Future<Output = (Self::Io, Self::Addr)> + Send

Accept a new incoming connection to this listener.

If the underlying accept call can return an error, this function must take care of logging and retrying.

Source

fn local_addr(&self) -> Result<Self::Addr, Error>

Returns the local address that this listener is bound to.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Listener for TcpListener

Available on non-WebAssembly only.
Source§

type Io = TcpStream

Source§

type Addr = SocketAddr

Source§

async fn accept( &mut self, ) -> (<TcpListener as Listener>::Io, <TcpListener as Listener>::Addr)

Source§

fn local_addr(&self) -> Result<<TcpListener as Listener>::Addr, Error>

Source§

impl Listener for UnixListener

Available on Unix only.
Source§

type Io = UnixStream

Source§

type Addr = SocketAddr

Source§

async fn accept( &mut self, ) -> (<UnixListener as Listener>::Io, <UnixListener as Listener>::Addr)

Source§

fn local_addr(&self) -> Result<<UnixListener as Listener>::Addr, Error>

Implementors§

Source§

impl<L, F> Listener for TapIo<L, F>
where L: Listener, F: FnMut(&mut <L as Listener>::Io) + Send + 'static,

Source§

type Io = <L as Listener>::Io

Source§

type Addr = <L as Listener>::Addr

Source§

impl<T> Listener for ConnLimiter<T>
where T: Listener,