s2n_quic_tls/
lib.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4use s2n_quic_core::application::ServerName;
5
6/// Ensure memory is correctly managed in tests
7#[cfg(test)]
8#[global_allocator]
9static ALLOCATOR: checkers::Allocator = checkers::Allocator::system();
10
11#[cfg(s2n_quic_enable_pq_tls)]
12static DEFAULT_POLICY: &s2n_tls::security::Policy = &s2n_tls::security::DEFAULT_PQ;
13#[cfg(not(s2n_quic_enable_pq_tls))]
14static DEFAULT_POLICY: &s2n_tls::security::Policy = &s2n_tls::security::DEFAULT_TLS13;
15
16#[non_exhaustive]
17pub struct ConnectionContext<'a> {
18    pub server_name: Option<&'a ServerName>,
19}
20
21/// Loads a config for a given connection
22///
23/// This trait can be implemented to override the default config loading for a QUIC endpoint
24pub trait ConfigLoader: 'static + Send {
25    fn load(&mut self, cx: ConnectionContext) -> config::Config;
26}
27
28impl ConfigLoader for config::Config {
29    #[inline]
30    fn load(&mut self, _cx: ConnectionContext) -> config::Config {
31        self.clone()
32    }
33}
34
35impl<T: FnMut(ConnectionContext) -> config::Config + Send + 'static> ConfigLoader for T {
36    #[inline]
37    fn load(&mut self, cx: ConnectionContext) -> config::Config {
38        (self)(cx)
39    }
40}
41
42impl ConfigLoader for Box<dyn ConfigLoader> {
43    #[inline]
44    fn load(&mut self, cx: ConnectionContext) -> config::Config {
45        (**self).load(cx)
46    }
47}
48
49mod callback;
50mod keylog;
51mod params;
52mod session;
53
54pub mod certificate;
55pub mod client;
56pub mod server;
57
58pub use client::Client;
59pub use s2n_tls::*;
60pub use server::Server;
61
62#[cfg(test)]
63mod tests;