Struct async_tls::TlsConnector
source · pub struct TlsConnector { /* private fields */ }
Expand description
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§
source§impl TlsConnector
impl TlsConnector
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new TlsConnector with default configuration.
This is the same as calling TlsConnector::default()
.
sourcepub fn connect<'a, IO>(
&self,
domain: impl AsRef<str>,
stream: IO
) -> Connect<IO> ⓘ
pub fn connect<'a, IO>( &self, domain: impl AsRef<str>, stream: IO ) -> Connect<IO> ⓘ
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§
source§impl Clone for TlsConnector
impl Clone for TlsConnector
source§fn clone(&self) -> TlsConnector
fn clone(&self) -> TlsConnector
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more