1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ReturnCode {
SuccessWithValue { value: usize },
SUCCESS,
FAIL,
EBUSY,
EALREADY,
EOFF,
ERESERVE,
EINVAL,
ESIZE,
ECANCEL,
ENOMEM,
ENOSUPPORT,
ENODEVICE,
EUNINSTALLED,
ENOACK,
}
impl From<ReturnCode> for isize {
fn from(original: ReturnCode) -> isize {
match original {
ReturnCode::SuccessWithValue { value } => value as isize,
ReturnCode::SUCCESS => 0,
ReturnCode::FAIL => -1,
ReturnCode::EBUSY => -2,
ReturnCode::EALREADY => -3,
ReturnCode::EOFF => -4,
ReturnCode::ERESERVE => -5,
ReturnCode::EINVAL => -6,
ReturnCode::ESIZE => -7,
ReturnCode::ECANCEL => -8,
ReturnCode::ENOMEM => -9,
ReturnCode::ENOSUPPORT => -10,
ReturnCode::ENODEVICE => -11,
ReturnCode::EUNINSTALLED => -12,
ReturnCode::ENOACK => -13,
}
}
}
impl From<ReturnCode> for usize {
fn from(original: ReturnCode) -> usize {
isize::from(original) as usize
}
}