use crate::enums::ProtocolVersion;
use crate::tls12::Tls12CipherSuite;
use crate::tls13::Tls13CipherSuite;
#[non_exhaustive]
#[derive(Debug)]
pub enum SupportedProtocolVersion {
TLS12(&'static Tls12Version),
TLS13(&'static Tls13Version),
}
impl SupportedProtocolVersion {
pub const fn version(&self) -> ProtocolVersion {
match self {
Self::TLS12(_) => ProtocolVersion::TLSv1_2,
Self::TLS13(_) => ProtocolVersion::TLSv1_3,
}
}
}
impl PartialEq for SupportedProtocolVersion {
fn eq(&self, other: &Self) -> bool {
matches!(
(self, other),
(Self::TLS12(_), Self::TLS12(_)) | (Self::TLS13(_), Self::TLS13(_))
)
}
}
impl Eq for SupportedProtocolVersion {}
pub static TLS12: SupportedProtocolVersion = SupportedProtocolVersion::TLS12(TLS12_VERSION);
pub static TLS13: SupportedProtocolVersion = SupportedProtocolVersion::TLS13(TLS13_VERSION);
pub static ALL_VERSIONS: &[&SupportedProtocolVersion] = &[&TLS13, &TLS12];
pub static DEFAULT_VERSIONS: &[&SupportedProtocolVersion] = ALL_VERSIONS;
pub static TLS12_VERSION: &Tls12Version = &Tls12Version {
client: crate::client::TLS12_HANDLER,
server: crate::server::TLS12_HANDLER,
};
pub static TLS13_VERSION: &Tls13Version = &Tls13Version {
client: crate::client::TLS13_HANDLER,
server: crate::server::TLS13_HANDLER,
};
#[non_exhaustive]
#[derive(Debug)]
pub struct Tls12Version {
pub(crate) client: &'static dyn crate::client::ClientHandler<Tls12CipherSuite>,
pub(crate) server: &'static dyn crate::server::ServerHandler<Tls12CipherSuite>,
}
#[non_exhaustive]
#[derive(Debug)]
pub struct Tls13Version {
pub(crate) client: &'static dyn crate::client::ClientHandler<Tls13CipherSuite>,
pub(crate) server: &'static dyn crate::server::ServerHandler<Tls13CipherSuite>,
}