]> git.lizzy.rs Git - connect-rs.git/blob - src/tls/mod.rs
renamed server to listener and add thorough documentation
[connect-rs.git] / src / tls / mod.rs
1 //! TLS transport client and listener implementations.
2 //!
3 //! <br/>
4 //!
5 //! This module primarily exposes the TLS client implementation over a [`Connection`] type and the
6 //! TLS listener implementation as [`TlsListener`].
7 //!
8
9 #[allow(unused_imports)]
10 pub(crate) use crate::Connection;
11
12 pub(crate) mod client;
13 pub(crate) mod listener;
14
15 pub use async_tls;
16 pub use client::*;
17 pub use listener::*;
18 pub use rustls;
19
20 use async_std::net::TcpStream;
21 use async_tls::server;
22 use std::net::SocketAddr;
23
24 /// Used to differentiate between an outgoing connection ([`TlsConnectionMetadata::Client`]) or
25 /// incoming connection listener ([`TlsConnectionMetadata::Listener`]).
26 ///
27 /// The async TLS library used by this crate has two differing stream types based on whether the
28 /// connection being established is either a client or server. This is to aid with handling that
29 /// distinction during connection instantiation.
30 pub enum TlsConnectionMetadata {
31     Client {
32         local_addr: SocketAddr,
33         peer_addr: SocketAddr,
34         stream: async_tls::client::TlsStream<TcpStream>,
35     },
36     Listener {
37         local_addr: SocketAddr,
38         peer_addr: SocketAddr,
39         stream: server::TlsStream<TcpStream>,
40     },
41 }