diff --git a/citadel_types/src/crypto/mod.rs b/citadel_types/src/crypto/mod.rs index de1849e4d..d76410a22 100644 --- a/citadel_types/src/crypto/mod.rs +++ b/citadel_types/src/crypto/mod.rs @@ -67,6 +67,21 @@ pub enum SecrecyMode { BestEffort, } +impl TryFrom for SecrecyMode { + type Error = crate::errors::Error; + + fn try_from(value: u8) -> Result { + match value { + 0 => Ok(Self::Perfect), + 1 => Ok(Self::BestEffort), + _ => Err(Self::Error::Other(format!( + "Cannot cast `{}` into SecrecyMode", + value + ))), + } + } +} + impl Default for SecrecyMode { fn default() -> Self { Self::BestEffort