async_native_tls/
connector.rs1use std::fmt;
2use std::marker::Unpin;
3
4use native_tls::Error;
5
6use crate::handshake::handshake;
7use crate::runtime::{AsyncRead, AsyncWrite};
8use crate::TlsStream;
9
10#[derive(Clone)]
13pub(crate) struct TlsConnector(native_tls::TlsConnector);
14
15impl TlsConnector {
16 pub(crate) async fn connect<S>(&self, domain: &str, stream: S) -> Result<TlsStream<S>, Error>
18 where
19 S: AsyncRead + AsyncWrite + Unpin,
20 {
21 handshake(move |s| self.0.connect(domain, s), stream).await
22 }
23}
24
25impl fmt::Debug for TlsConnector {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 f.debug_struct("TlsConnector").finish()
28 }
29}
30
31impl From<native_tls::TlsConnector> for TlsConnector {
32 fn from(inner: native_tls::TlsConnector) -> TlsConnector {
33 TlsConnector(inner)
34 }
35}