[][src]Struct async_tls::TlsConnector

pub struct TlsConnector { /* fields omitted */ }

The TLS connecting part. The acceptor drives the client side of the TLS handshake process. It works on any asynchronous stream.

It provides a simple interface (connect), returning a future that will resolve when the handshake process completed. On success, it will hand you an async TlsStream.

To create a TlsConnector with a non-default configuation, create a rusttls::ClientConfig and call .into() on it.

Example

use async_tls::TlsConnector;

async_std::task::block_on(async {
    let connector = TlsConnector::default();
    let tcp_stream = async_std::net::TcpStream::connect("example.com").await?;
    let encrypted_stream = connector.connect("example.com", tcp_stream).await?;

    Ok(()) as async_std::io::Result<()>
});

Implementations

impl TlsConnector[src]

pub fn new() -> Self[src]

Create a new TlsConnector with default configuration.

This is the same as calling TlsConnector::default().

pub fn connect<'a, IO>(
    &self,
    domain: impl AsRef<str>,
    stream: IO
) -> Connect<IO> where
    IO: AsyncRead + AsyncWrite + Unpin
[src]

Connect to a server. stream can be any type implementing AsyncRead and AsyncWrite, such as TcpStreams or Unix domain sockets.

The function will return a Connect Future, representing the connecting part of a Tls handshake. It will resolve when the handshake is over.

Trait Implementations

impl Clone for TlsConnector[src]

impl Default for TlsConnector[src]

impl From<Arc<ClientConfig>> for TlsConnector[src]

impl From<ClientConfig> for TlsConnector[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.