1use crate::enums::ProtocolVersion;
2
3#[non_exhaustive]
9#[derive(Debug)]
10pub enum SupportedProtocolVersion {
11 TLS12(&'static Tls12Version),
13 TLS13(&'static Tls13Version),
15}
16
17impl SupportedProtocolVersion {
18 pub const fn version(&self) -> ProtocolVersion {
20 match self {
21 Self::TLS12(_) => ProtocolVersion::TLSv1_2,
22 Self::TLS13(_) => ProtocolVersion::TLSv1_3,
23 }
24 }
25}
26
27impl PartialEq for SupportedProtocolVersion {
28 fn eq(&self, other: &Self) -> bool {
29 matches!(
30 (self, other),
31 (Self::TLS12(_), Self::TLS12(_)) | (Self::TLS13(_), Self::TLS13(_))
32 )
33 }
34}
35
36impl Eq for SupportedProtocolVersion {}
37
38pub static TLS12: SupportedProtocolVersion = SupportedProtocolVersion::TLS12(TLS12_VERSION);
40
41pub static TLS13: SupportedProtocolVersion = SupportedProtocolVersion::TLS13(TLS13_VERSION);
43
44pub static ALL_VERSIONS: &[&SupportedProtocolVersion] = &[&TLS13, &TLS12];
46
47pub static DEFAULT_VERSIONS: &[&SupportedProtocolVersion] = ALL_VERSIONS;
53
54pub static TLS12_VERSION: &Tls12Version = &Tls12Version {
60 client: crate::client::TLS12_HANDLER,
61 server: crate::server::TLS12_HANDLER,
62};
63
64pub static TLS13_VERSION: &Tls13Version = &Tls13Version {
70 client: crate::client::TLS13_HANDLER,
71 server: crate::server::TLS13_HANDLER,
72};
73
74#[non_exhaustive]
78#[derive(Debug)]
79pub struct Tls12Version {
80 pub(crate) client: &'static dyn crate::client::Tls12Handler,
81 pub(crate) server: &'static dyn crate::server::Tls12Handler,
82}
83
84#[non_exhaustive]
88#[derive(Debug)]
89pub struct Tls13Version {
90 pub(crate) client: &'static dyn crate::client::Tls13Handler,
91 pub(crate) server: &'static dyn crate::server::Tls13Handler,
92}