#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AlgorithmVariant {
Reference,
Avx2,
AesNi,
Avx2AesNi,
Neon,
}
impl AlgorithmVariant {
pub fn name(&self) -> &'static str {
match self {
AlgorithmVariant::Reference => "reference",
AlgorithmVariant::Avx2 => "avx2",
AlgorithmVariant::AesNi => "aesni",
AlgorithmVariant::Avx2AesNi => "avx2_aesni",
AlgorithmVariant::Neon => "neon",
}
}
pub fn is_optimized(&self) -> bool {
!matches!(self, AlgorithmVariant::Reference)
}
pub fn requires_x86(&self) -> bool {
matches!(
self,
AlgorithmVariant::Avx2 | AlgorithmVariant::AesNi | AlgorithmVariant::Avx2AesNi
)
}
pub fn requires_arm(&self) -> bool {
matches!(self, AlgorithmVariant::Neon)
}
}