/// Variants of an op field in [Message](crate::v4::Message).
#[derive(Debug, PartialEq)]
#[repr(u8)]
pub enum Ops {
/// 1. Client sending a request to the server
Request,
/// 2. Server sending a reply to the client
Reply,
/// Not implemented
Other(u8),
}
// Encode
impl From<&Ops> for u8 {
fn from(op: &Ops) -> Self {
match op {
Ops::Request => 1,
Ops::Reply => 2,
Ops::Other(x) => *x,
}
}
}
// Decode
impl From<u8> for Ops {
fn from(byte: u8) -> Self {
match byte {
1 => Self::Request,
2 => Self::Reply,
_ => Self::Other(byte),
}
}
}