Trait tor_rtcompat::TcpListener
source · pub trait TcpListener {
type TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static;
type Incoming: Stream<Item = IoResult<(Self::TcpStream, SocketAddr)>> + Send + Unpin;
// Required methods
fn accept<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = IoResult<(Self::TcpStream, SocketAddr)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn incoming(self) -> Self::Incoming;
fn local_addr(&self) -> IoResult<SocketAddr>;
}
Expand description
Trait for a local socket that accepts incoming TCP streams.
These objects are returned by instances of TcpProvider
. To use
one, either call accept
to accept a single connection, or
use incoming
to wrap this object as a [stream::Stream
].
Required Associated Types§
sourcetype TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static
type TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static
The type of TCP connections returned by Self::accept()
.
sourcetype Incoming: Stream<Item = IoResult<(Self::TcpStream, SocketAddr)>> + Send + Unpin
type Incoming: Stream<Item = IoResult<(Self::TcpStream, SocketAddr)>> + Send + Unpin
The type of [stream::Stream
] returned by Self::incoming()
.
Required Methods§
sourcefn accept<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = IoResult<(Self::TcpStream, SocketAddr)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn accept<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = IoResult<(Self::TcpStream, SocketAddr)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Wait for an incoming stream; return it along with its address.
sourcefn incoming(self) -> Self::Incoming
fn incoming(self) -> Self::Incoming
Wrap this listener into a new [stream::Stream
] that yields
TCP streams and addresses.
sourcefn local_addr(&self) -> IoResult<SocketAddr>
fn local_addr(&self) -> IoResult<SocketAddr>
Return the local address that this listener is bound to.
Implementations on Foreign Types§
source§impl TcpListener for TcpListener
Available on (crate features native-tls
or rustls
) and (crate features async-std
or tokio
) and crate feature async-std
only.
impl TcpListener for TcpListener
Available on (crate features
native-tls
or rustls
) and (crate features async-std
or tokio
) and crate feature async-std
only.