]> git.lizzy.rs Git - connect-rs.git/blob - src/tls/mod.rs
refactor to have datagram already serialized in memory
[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 use async_std::net::TcpStream;
16 use async_tls::server;
17 use std::net::SocketAddr;
18
19 pub use client::*;
20 pub use listener::*;
21
22 /// Used to differentiate between an outgoing connection ([Client](`TlsConnectionMetadata::Client`))
23 /// or incoming connection listener ([Listener](`TlsConnectionMetadata::Listener`)).
24 ///
25 /// The async TLS library used by this crate has two differing stream types based on whether the
26 /// connection being established is either a client or server. This is to aid with handling that
27 /// distinction during connection instantiation.
28 pub enum TlsConnectionMetadata {
29     Client {
30         local_addr: SocketAddr,
31         peer_addr: SocketAddr,
32         stream: async_tls::client::TlsStream<TcpStream>,
33     },
34     Listener {
35         local_addr: SocketAddr,
36         peer_addr: SocketAddr,
37         stream: server::TlsStream<TcpStream>,
38     },
39 }