]> git.lizzy.rs Git - connect-rs.git/blob - src/tls/mod.rs
move tls into a feature and remove error dep on async-channel
[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 #[cfg(feature = "tls")]
16 #[doc(cfg(feature = "tls"))]
17 pub use async_tls;
18
19 pub use client::*;
20 pub use listener::*;
21
22 #[cfg(feature = "tls")]
23 #[doc(cfg(feature = "tls"))]
24 pub use rustls;
25
26 use async_std::net::TcpStream;
27 use async_tls::server;
28 use std::net::SocketAddr;
29
30 /// Used to differentiate between an outgoing connection ([`TlsConnectionMetadata::Client`]) or
31 /// incoming connection listener ([`TlsConnectionMetadata::Listener`]).
32 ///
33 /// The async TLS library used by this crate has two differing stream types based on whether the
34 /// connection being established is either a client or server. This is to aid with handling that
35 /// distinction during connection instantiation.
36 pub enum TlsConnectionMetadata {
37     Client {
38         local_addr: SocketAddr,
39         peer_addr: SocketAddr,
40         stream: async_tls::client::TlsStream<TcpStream>,
41     },
42     Listener {
43         local_addr: SocketAddr,
44         peer_addr: SocketAddr,
45         stream: server::TlsStream<TcpStream>,
46     },
47 }