nautilus_binance/common/sbe/spot/
cancel_replace_status.rs

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