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
#![allow(stable_features)]

mod client;
mod error;
mod server;
mod stream;

pub use client::{
    TlsConnector, TlsStream as ClientTlsStream, TlsStreamReadHalf as ClientTlsStreamReadHalf,
    TlsStreamWriteHalf as ClientTlsStreamWriteHalf,
};
pub use error::TlsError;
pub use server::{
    TlsAcceptor, TlsStream as ServerTlsStream, TlsStreamReadHalf as ServerTlsStreamReadHalf,
    TlsStreamWriteHalf as ServerTlsStreamWriteHalf,
};

/// A wrapper around an underlying raw stream which implements the TLS protocol.
pub type TlsStream<IO> = stream::Stream<IO, rustls::Connection>;

impl<IO> From<ClientTlsStream<IO>> for TlsStream<IO> {
    fn from(value: ClientTlsStream<IO>) -> Self {
        value.map_conn(|c| c.into())
    }
}

impl<IO> From<ServerTlsStream<IO>> for TlsStream<IO> {
    fn from(value: ServerTlsStream<IO>) -> Self {
        value.map_conn(|c| c.into())
    }
}