tokio_util::net

Trait Listener

Source
pub trait Listener {
    type Io: AsyncRead + AsyncWrite;
    type Addr;

    // Required methods
    fn poll_accept(
        &mut self,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(Self::Io, Self::Addr)>>;
    fn local_addr(&self) -> Result<Self::Addr>;

    // Provided method
    fn accept(&mut self) -> ListenerAcceptFut<'_, Self> 
       where Self: Sized { ... }
}
Available on crate features net and codec only.
Expand description

A trait for a listener: TcpListener and UnixListener.

Required Associated Types§

Source

type Io: AsyncRead + AsyncWrite

The stream’s type of this listener.

Source

type Addr

The socket address type of this listener.

Required Methods§

Source

fn poll_accept( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::Io, Self::Addr)>>

Polls to accept a new incoming connection to this listener.

Source

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

Returns the local address that this listener is bound to.

Provided Methods§

Source

fn accept(&mut self) -> ListenerAcceptFut<'_, Self>
where Self: Sized,

Accepts a new incoming connection from this listener.

Implementations on Foreign Types§

Source§

impl Listener for TcpListener

Source§

type Io = TcpStream

Source§

type Addr = SocketAddr

Source§

fn poll_accept( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::Io, Self::Addr)>>

Source§

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

Source§

impl Listener for UnixListener

Source§

type Io = UnixStream

Source§

type Addr = SocketAddr

Source§

fn poll_accept( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::Io, Self::Addr)>>

Source§

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

Implementors§