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