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