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§
Sourcefn bind_to(addr: Addr) -> impl Future<Output = Result<Self>> + Send
fn bind_to(addr: Addr) -> impl Future<Output = Result<Self>> + Send
Create a new AddrListener bound to the given address.
Sourcefn accept_stream(&self) -> impl Future<Output = Result<(Stream, Addr)>> + Send
fn accept_stream(&self) -> impl Future<Output = Result<(Stream, Addr)>> + Send
Accept an incoming connection, returning the stream and the remote address.
Sourcefn get_local_addr(&self) -> Result<Addr>
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
impl AddrListener<TcpStream, SocketAddr> for TcpListener
async fn bind_to(addr: IpSocketAddr) -> Result<Self>
async fn accept_stream(&self) -> Result<(TcpStream, IpSocketAddr)>
fn get_local_addr(&self) -> Result<IpSocketAddr>
Source§impl AddrListener<UnixStream, SocketAddr> for UnixListener
Available on Unix only.
impl AddrListener<UnixStream, SocketAddr> for UnixListener
Available on Unix only.