1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod acceptor;
mod async_to_sync_wrapper;
mod certificate;
mod connector;
mod error;
mod handshake;
mod stream;

#[cfg(test)]
mod test;

pub use acceptor::{TlsAcceptor, TlsAcceptorBuilder};
pub use certificate::Certificate;
pub use connector::{
    certs, TlsAnonymousConnector, TlsConnector, TlsConnectorBuilder, TlsDomainConnector,
};
pub use error::Error as TlsError;
pub use openssl::ssl::SslVerifyMode;
pub use stream::{AllTcpStream, TlsStream};

pub type DefaultServerTlsStream = TlsStream<crate::net::TcpStream>;
pub type DefaultClientTlsStream = TlsStream<crate::net::TcpStream>;

mod split {

    use async_net::TcpStream;
    use futures_util::AsyncReadExt;

    use super::*;
    use crate::net::{BoxReadConnection, BoxWriteConnection, SplitConnection};

    impl SplitConnection for TlsStream<TcpStream> {
        fn split_connection(self) -> (BoxWriteConnection, BoxReadConnection) {
            let (read, write) = self.split();
            (Box::new(write), Box::new(read))
        }
    }
}