1use crate::enums::ProtocolVersion;
2use crate::tls12::Tls12CipherSuite;
3use crate::tls13::Tls13CipherSuite;
4
5#[non_exhaustive]
11#[derive(Debug)]
12pub enum SupportedProtocolVersion {
13 TLS12(&'static Tls12Version),
15 TLS13(&'static Tls13Version),
17}
18
19impl SupportedProtocolVersion {
20 pub const fn version(&self) -> ProtocolVersion {
22 match self {
23 Self::TLS12(_) => ProtocolVersion::TLSv1_2,
24 Self::TLS13(_) => ProtocolVersion::TLSv1_3,
25 }
26 }
27}
28
29impl PartialEq for SupportedProtocolVersion {
30 fn eq(&self, other: &Self) -> bool {
31 matches!(
32 (self, other),
33 (Self::TLS12(_), Self::TLS12(_)) | (Self::TLS13(_), Self::TLS13(_))
34 )
35 }
36}
37
38impl Eq for SupportedProtocolVersion {}
39
40pub static TLS12: SupportedProtocolVersion = SupportedProtocolVersion::TLS12(TLS12_VERSION);
42
43pub static TLS13: SupportedProtocolVersion = SupportedProtocolVersion::TLS13(TLS13_VERSION);
45
46pub static ALL_VERSIONS: &[&SupportedProtocolVersion] = &[&TLS13, &TLS12];
48
49pub static DEFAULT_VERSIONS: &[&SupportedProtocolVersion] = ALL_VERSIONS;
55
56pub static TLS12_VERSION: &Tls12Version = &Tls12Version {
62 client: crate::client::TLS12_HANDLER,
63 server: crate::server::TLS12_HANDLER,
64};
65
66pub static TLS13_VERSION: &Tls13Version = &Tls13Version {
72 client: crate::client::TLS13_HANDLER,
73 server: crate::server::TLS13_HANDLER,
74};
75
76#[non_exhaustive]
80#[derive(Debug)]
81pub struct Tls12Version {
82 pub(crate) client: &'static dyn crate::client::ClientHandler<Tls12CipherSuite>,
83 pub(crate) server: &'static dyn crate::server::ServerHandler<Tls12CipherSuite>,
84}
85
86#[non_exhaustive]
90#[derive(Debug)]
91pub struct Tls13Version {
92 pub(crate) client: &'static dyn crate::client::ClientHandler<Tls13CipherSuite>,
93 pub(crate) server: &'static dyn crate::server::ServerHandler<Tls13CipherSuite>,
94}