use crate::error::DatError;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CryptoAlgorithm {
AES128GCMN,
AES256GCMN,
}
impl CryptoAlgorithm {
pub fn to_str(&self) -> &'static str {
match self {
CryptoAlgorithm::AES128GCMN => "AES128GCMN",
CryptoAlgorithm::AES256GCMN => "AES256GCMN",
}
}
pub fn from_str(s: &str) -> Result<CryptoAlgorithm, DatError> {
match s {
"AES128GCMN" => Ok(CryptoAlgorithm::AES128GCMN),
"AES256GCMN" => Ok(CryptoAlgorithm::AES256GCMN),
_ => Err(DatError::UnknownCryptoAlgorithm),
}
}
}