[][src]Struct tls_async::TlsConnector

pub struct TlsConnector { /* fields omitted */ }

Examples

#![feature(async_await, await_macro, futures_api)]
use futures::io::{AsyncReadExt, AsyncWriteExt};
use tls_async::TlsConnector;
use std::io::{Read, Write};
use std::net::ToSocketAddrs;
use romio::TcpStream;

let connector = TlsConnector::new().unwrap();

let addr = "google.com:443".to_socket_addrs().unwrap().next().unwrap();
let stream = await!(TcpStream::connect(&addr)).unwrap();
let mut stream = await!(connector.connect("google.com", stream)).unwrap();

await!(stream.write_all(b"GET / HTTP/1.0\r\n\r\n")).unwrap();
let mut res = vec![];
await!(stream.read_to_end(&mut res)).unwrap();
println!("{}", String::from_utf8_lossy(&res));

Methods

impl TlsConnector[src]

pub fn new() -> Result<TlsConnector, Error>[src]

Returns a new connector with default settings.

pub fn builder() -> TlsConnectorBuilder[src]

Returns a new builder for a TlsConnector.

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

Connects the provided stream with this connector, assuming the provided domain.

This function will internally call TlsConnector::connect 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 for clients who have already established, for example, a TCP connection to a remote server. That stream is then provided here to perform the client half of a connection to a TLS-powered server.

Trait Implementations

impl Clone for TlsConnector[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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