Trait viz::Listener

source ·
pub trait Listener {
    type Io;
    type Addr;

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

A trait for a listener: TcpListener and UnixListener.

Required Associated Types§

source

type Io

The stream’s type of this listener.

source

type Addr

The socket address type of this listener.

Required Methods§

source

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

Accepts a new incoming connection from this listener.

source

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

Returns the local address that this listener is bound to.

§Errors

An error will return if got the socket address of the local half of this connection is failed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Listener for TcpListener

Available on crate features http1 or http2 only.
§

type Io = TcpStream

§

type Addr = SocketAddr

source§

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

source§

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

source§

impl Listener for UnixListener

Available on Unix and crate feature unix-socket only.
§

type Io = UnixStream

§

type Addr = SocketAddr

source§

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

source§

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

Implementors§

source§

impl Listener for TlsListener<TcpListener, TlsAcceptor>

Available on crate feature native-tls and (crate features native_tls or rustls) only.
source§

impl Listener for TlsListener<TcpListener, TlsAcceptor>

Available on crate feature rustls and (crate features native_tls or rustls) only.