magic_crypt/
secure_bit.rs1use core::convert::TryFrom;
2
3#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum SecureBit {
6 Bit64,
7 #[default]
8 Bit128,
9 Bit192,
10 Bit256,
11}
12
13impl TryFrom<u16> for SecureBit {
14 type Error = &'static str;
15
16 #[inline]
17 fn try_from(bit_number: u16) -> Result<Self, Self::Error> {
18 Ok(match bit_number {
19 64 => SecureBit::Bit64,
20 128 => SecureBit::Bit128,
21 192 => SecureBit::Bit192,
22 256 => SecureBit::Bit256,
23 _ => return Err("Unsupported number of bits."),
24 })
25 }
26}