pub trait TcpProvider {
    type TcpStream: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static;
    type TcpListener: TcpListener<TcpStream = Self::TcpStream> + Send + Sync + Unpin + 'static;
    fn connect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        addr: &'life1 SocketAddr
    ) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpStream>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn listen<'life0, 'life1, 'async_trait>(
        &'life0 self,
        addr: &'life1 SocketAddr
    ) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpListener>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

Trait for a runtime that can create and accept TCP connections.

(In Arti we use the [AsyncRead] and [AsyncWrite] traits from [futures::io] as more standard, even though the ones from Tokio can be a bit more efficient. Let’s hope that they converge in the future.)

Associated Types

The type for the TCP connections returned by Self::connect().

The type for the TCP listeners returned by Self::listen().

Required methods

Launch a TCP connection to a given socket address.

Note that unlike std::net:TcpStream::connect, we do not accept any types other than a single SocketAddr. We do this because, as a Tor implementation, we most be absolutely sure not to perform unnecessary DNS lookups.

Open a TCP listener on a given socket address.

Implementors