use core::fmt;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum PayloadCodec {
#[default]
Cbor = 0,
Protobuf = 1,
FlatBuffers = 2,
}
impl PayloadCodec {
pub const fn as_u8(self) -> u8 {
self as u8
}
pub fn from_u8(v: u8) -> Option<Self> {
match v {
0 => Some(Self::Cbor),
1 => Some(Self::Protobuf),
2 => Some(Self::FlatBuffers),
_ => None,
}
}
}
impl fmt::Display for PayloadCodec {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Self::Cbor => "cbor",
Self::Protobuf => "protobuf",
Self::FlatBuffers => "flatbuffers",
})
}
}