pub trait Connector: 'static + Clone + Send + Sync {
    type Transport: 'static + AsyncRead + AsyncWrite + Unpin + Send + Sync;
    type Config: Debug + Default + Send + Sync + Clone;

    fn peer_addr(transport: &Self::Transport) -> Result<SocketAddr, Error>;
    fn connect<'life0, 'life1, 'async_trait>(
        url: &'life0 Url,
        config: &'life1 Self::Config
    ) -> Pin<Box<dyn Future<Output = Result<Self::Transport, Error>> + Send + 'async_trait, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn spawn<Fut>(future: Fut)
    where
        Fut: 'static + Future + Send,
        <Fut as Future>::Output: Send
; }
Expand description

Interface for runtime and tls adapters for the trillium client

See trillium_client for more information on usage.

Required Associated Types

The async read + write type for this connector, often a TcpStream or TlSStream

A type that can be used to configure this Connector. It will be passed into Connector::connect.

Required Methods

A SocketAddr representation of the other side of this connection

Initiate a connection to the provided url, using the configuration.

Async trait signature:

async fn connect(url: &Url, config: &Self::Config) -> std::io::Result<Self::Transport>;

Spawn and detach a task on the runtime. Although this may seem unrelated to the purpose of a tcp connector, it is required as a workaround for the absence of async drop in order to enable keepalive connection pooling. TLS implementations that wrap a runtime implementation should call through to the inner spawn.

Implementors