#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Provider(ProviderKind);
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ProviderKind {
#[cfg(feature = "aws-lc-rs")]
AwsLcRs,
#[cfg(feature = "boring")]
Boring,
#[cfg(feature = "ring")]
Ring,
#[cfg(feature = "rustcrypto")]
RustCrypto,
}
impl Provider {
#[cfg(feature = "aws-lc-rs")]
pub const AWS_LC_RS: Self = Self(ProviderKind::AwsLcRs);
#[cfg(feature = "boring")]
pub const BORING: Self = Self(ProviderKind::Boring);
#[cfg(feature = "ring")]
pub const RING: Self = Self(ProviderKind::Ring);
#[cfg(feature = "rustcrypto")]
pub const RUSTCRYPTO: Self = Self(ProviderKind::RustCrypto);
pub const COMPILED: &'static [Self] = &[
#[cfg(feature = "aws-lc-rs")]
Self::AWS_LC_RS,
#[cfg(feature = "boring")]
Self::BORING,
#[cfg(feature = "ring")]
Self::RING,
#[cfg(feature = "rustcrypto")]
Self::RUSTCRYPTO,
];
#[must_use]
pub const fn build_default() -> Option<Self> {
if Self::COMPILED.len() == 1 {
Some(Self::COMPILED[0])
} else {
None
}
}
#[must_use]
pub const fn name(self) -> &'static str {
match self.0 {
#[cfg(feature = "aws-lc-rs")]
ProviderKind::AwsLcRs => "aws-lc-rs",
#[cfg(feature = "boring")]
ProviderKind::Boring => "boring",
#[cfg(feature = "ring")]
ProviderKind::Ring => "ring",
#[cfg(feature = "rustcrypto")]
ProviderKind::RustCrypto => "rustcrypto",
}
}
pub(crate) const fn kind(self) -> ProviderKind {
self.0
}
}