pim_protocol/
frame_type.rs1use pim_core::PimError;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[repr(u8)]
8pub enum FrameType {
9 Handshake = 0x01,
11 Data = 0x02,
13 RouteUpdate = 0x03,
15 Heartbeat = 0x04,
17 Control = 0x05,
19 Fragment = 0x06,
21}
22
23impl FrameType {
24 pub fn from_u8(value: u8) -> Result<Self, PimError> {
26 match value {
27 0x01 => Ok(Self::Handshake),
28 0x02 => Ok(Self::Data),
29 0x03 => Ok(Self::RouteUpdate),
30 0x04 => Ok(Self::Heartbeat),
31 0x05 => Ok(Self::Control),
32 0x06 => Ok(Self::Fragment),
33 other => Err(PimError::Protocol(format!(
34 "unknown frame type: 0x{other:02x}"
35 ))),
36 }
37 }
38}