[−][src]Struct tls_async::TlsConnector
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]
&'a self,
domain: &'a str,
stream: S
) -> PendingTlsStream<S> where
S: AsyncRead + AsyncWrite + Unpin,
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(&self) -> TlsConnector
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl Send for TlsConnector
impl Sync for TlsConnector
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,