+ pub fn from_proto(buf: &[u8]) -> Option<(Self, usize)> {
+ buf.utf8_chunks()
+ .next()
+ .and_then(|chunk| chunk.valid().chars().next())
+ .map(|c| match c as u32 {
+ 0x00 => (PacketType::Raw, 1),
+ 0x01 => (PacketType::Ax25, 1),
+ 0x02 => (PacketType::Aprs, 1),
+ 0x03 => (PacketType::SixLowPan, 1),
+ 0x04 => (PacketType::Ipv4, 1),
+ 0x05 => (PacketType::Sms, 1),
+ 0x06 => (PacketType::Winlink, 1),
+ _ => (PacketType::Other(c), c.len_utf8()),
+ })
+ }
+