libsignal_rust/
base_key_type.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
2#[repr(u8)]
3pub enum BaseKeyType {
4 Ours = 1,
5 Theirs = 2,
6}
7
8impl TryFrom<u8> for BaseKeyType {
9 type Error = String;
10
11 fn try_from(value: u8) -> Result<Self, Self::Error> {
12 match value {
13 1 => Ok(BaseKeyType::Ours),
14 2 => Ok(BaseKeyType::Theirs),
15 _ => Err(format!("Invalid BaseKeyType value: {}", value)),
16 }
17 }
18}
19
20
21impl From<BaseKeyType> for u8 {
22 fn from(value: BaseKeyType) -> Self {
23 value as u8
24 }
25}