toe_beans/v4/message/op.rs
1/// Variants of an op field in [Message](crate::v4::Message).
2#[derive(Debug, PartialEq)]
3#[repr(u8)]
4pub enum Ops {
5 /// 1. Client sending a request to the server
6 Request,
7 /// 2. Server sending a reply to the client
8 Reply,
9 /// Not implemented
10 Other(u8),
11}
12
13// Encode
14impl From<&Ops> for u8 {
15 fn from(op: &Ops) -> Self {
16 match op {
17 Ops::Request => 1,
18 Ops::Reply => 2,
19 Ops::Other(x) => *x,
20 }
21 }
22}
23
24// Decode
25impl From<u8> for Ops {
26 fn from(byte: u8) -> Self {
27 match byte {
28 1 => Self::Request,
29 2 => Self::Reply,
30 _ => Self::Other(byte),
31 }
32 }
33}