panda/
enums.rs

1/// For fallible virt/phys memory R/W operations
2#[repr(i32)]
3#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
4pub enum MemRWStatus {
5    Unknown = -2,
6    GenericErrorRet = -1,
7    MemTxOk = panda_sys::MEMTX_OK as i32,
8    MemTxError = panda_sys::MEMTX_ERROR as i32,
9    MemTxDecodeError = panda_sys::MEMTX_DECODE_ERROR as i32,
10}
11
12impl From<i32> for MemRWStatus {
13    fn from(v: i32) -> Self {
14        match v {
15            x if x == MemRWStatus::GenericErrorRet as i32 => MemRWStatus::GenericErrorRet,
16            x if x == MemRWStatus::MemTxOk as i32 => MemRWStatus::MemTxOk,
17            x if x == MemRWStatus::MemTxError as i32 => MemRWStatus::MemTxError,
18            x if x == MemRWStatus::MemTxDecodeError as i32 => MemRWStatus::MemTxDecodeError,
19            _ => MemRWStatus::Unknown, // This means there is a bug in the C side of things
20        }
21    }
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
25pub enum Endian {
26    Big,
27    Little,
28}
29
30/// For fallible generic C functions
31#[repr(i32)]
32#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
33pub enum GenericRet {
34    Unknown = -2,
35    Error = -1,
36    Success = 0,
37}
38
39impl From<i32> for GenericRet {
40    fn from(v: i32) -> Self {
41        match v {
42            x if x == GenericRet::Error as i32 => GenericRet::Error,
43            x if x == GenericRet::Success as i32 => GenericRet::Success,
44            _ => GenericRet::Unknown, // This means there is a bug in the C side of things
45        }
46    }
47}
48
49pub(crate) mod arch {}