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§

source

type TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static

The type of TCP connections returned by Self::accept().

source

type Incoming: Stream<Item = IoResult<(Self::TcpStream, SocketAddr)>> + Send + Unpin

The type of [stream::Stream] returned by Self::incoming().

Required Methods§

source

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.

source

fn incoming(self) -> Self::Incoming

Wrap this listener into a new [stream::Stream] that yields TCP streams and addresses.

source

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.
§

type TcpStream = TcpStream

§

type Incoming = IncomingStreams

source§

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,

source§

fn incoming(self) -> IncomingStreams

source§

fn local_addr(&self) -> IoResult<SocketAddr>

Implementors§