nautilus_binance/common/sbe/spot/
floor.rs1#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2#[repr(u8)]
3pub enum Floor {
4 Exchange = 0x1_u8,
5 Broker = 0x2_u8,
6 Sor = 0x3_u8,
7 NonRepresentable = 0xfe_u8,
8 #[default]
9 NullVal = 0xff_u8,
10}
11impl From<u8> for Floor {
12 #[inline]
13 fn from(v: u8) -> Self {
14 match v {
15 0x1_u8 => Self::Exchange,
16 0x2_u8 => Self::Broker,
17 0x3_u8 => Self::Sor,
18 0xfe_u8 => Self::NonRepresentable,
19 _ => Self::NullVal,
20 }
21 }
22}
23impl From<Floor> for u8 {
24 #[inline]
25 fn from(v: Floor) -> Self {
26 match v {
27 Floor::Exchange => 0x1_u8,
28 Floor::Broker => 0x2_u8,
29 Floor::Sor => 0x3_u8,
30 Floor::NonRepresentable => 0xfe_u8,
31 Floor::NullVal => 0xff_u8,
32 }
33 }
34}
35impl core::str::FromStr for Floor {
36 type Err = ();
37
38 #[inline]
39 fn from_str(v: &str) -> core::result::Result<Self, Self::Err> {
40 match v {
41 "Exchange" => Ok(Self::Exchange),
42 "Broker" => Ok(Self::Broker),
43 "Sor" => Ok(Self::Sor),
44 "NonRepresentable" => Ok(Self::NonRepresentable),
45 _ => Ok(Self::NullVal),
46 }
47 }
48}
49impl core::fmt::Display for Floor {
50 #[inline]
51 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52 match self {
53 Self::Exchange => write!(f, "Exchange"),
54 Self::Broker => write!(f, "Broker"),
55 Self::Sor => write!(f, "Sor"),
56 Self::NonRepresentable => write!(f, "NonRepresentable"),
57 Self::NullVal => write!(f, "NullVal"),
58 }
59 }
60}