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§
Required Methods§
sourcefn accept(&self) -> impl Future<Output = Result<(Self::Io, Self::Addr)>> + Send
fn accept(&self) -> impl Future<Output = Result<(Self::Io, Self::Addr)>> + Send
Accepts a new incoming connection from this listener.
sourcefn local_addr(&self) -> Result<Self::Addr>
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.
impl Listener for TcpListener
Available on crate features
http1
or http2
only.source§impl Listener for UnixListener
Available on Unix and crate feature unix-socket
only.
impl Listener for UnixListener
Available on Unix and crate feature
unix-socket
only.Implementors§
source§impl Listener for TlsListener<TcpListener, TlsAcceptor>
Available on crate feature native-tls
and (crate features native_tls
or rustls
) only.
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.
impl Listener for TlsListener<TcpListener, TlsAcceptor>
Available on crate feature
rustls
and (crate features native_tls
or rustls
) only.