[][src]Function tokio_tls_api::accept_async

pub fn accept_async<A, S>(acceptor: &A, stream: S) -> AcceptAsync<S> where
    S: Read + Write + Debug + Send + Sync + 'static,
    A: TlsAcceptor

Accepts a new client connection with the provided stream.

This function will internally call TlsAcceptor::accept to connect the stream and returns a future representing the resolution of the connection operation. The returned future will resolve to either TlsStream<S> or Error depending if it's successful or not.

This is typically used after a new socket has been accepted from a TcpListener. That socket is then passed to this function to perform the server half of accepting a client connection.

Compatibility notes

Note that this method currently requires S: Read + Write but it's highly recommended to ensure that the object implements the AsyncRead and AsyncWrite traits as well, otherwise this function will not work properly.