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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#[repr(C)]
#[derive(PartialEq, Clone, Debug)]
#[allow(dead_code)]
pub enum BrpcError {
NOERROR = 0,
ENOSERVICE = 1001,
ENOMETHOD = 1002,
EREQUEST = 1003,
ERPCAUTH = 1004,
ETOOMANYFAILS = 1005,
EPCHANFINISH = 1006,
EBACKUPREQUEST = 1007,
ERPCTIMEDOUT = 1008,
EFAILEDSOCKET = 1009,
EHTTP = 1010,
EOVERCROWDED = 1011,
ERTMPPUBLISHABLE = 1012,
ERTMPCREATESTREAM = 1013,
EEOF = 1014,
EUNUSED = 1015,
ESSL = 1016,
EH2RUNOUTSTREAMS = 1017,
EREJECT = 1018,
EINTERNAL = 2001,
ERESPONSE = 2002,
ELOGOFF = 2003,
ELIMIT = 2004,
ECLOSE = 2005,
EITP = 2006,
ESERIALIZE = 3001,
EDESERIALIZE = 3002,
EFFI = 3003,
UNKNOWN = 0xffff,
}
#[doc(hidden)]
impl From<i32> for BrpcError {
fn from(e: i32) -> BrpcError {
match e {
0 => BrpcError::NOERROR,
1001 => BrpcError::ENOSERVICE,
1002 => BrpcError::ENOMETHOD,
1003 => BrpcError::EREQUEST,
1004 => BrpcError::ERPCAUTH,
1005 => BrpcError::ETOOMANYFAILS,
1006 => BrpcError::EPCHANFINISH,
1007 => BrpcError::EBACKUPREQUEST,
1008 => BrpcError::ERPCTIMEDOUT,
1009 => BrpcError::EFAILEDSOCKET,
1010 => BrpcError::EHTTP,
1011 => BrpcError::EOVERCROWDED,
1012 => BrpcError::ERTMPPUBLISHABLE,
1013 => BrpcError::ERTMPCREATESTREAM,
1014 => BrpcError::EEOF,
1015 => BrpcError::EUNUSED,
1016 => BrpcError::ESSL,
1017 => BrpcError::EH2RUNOUTSTREAMS,
1018 => BrpcError::EREJECT,
2001 => BrpcError::EINTERNAL,
2002 => BrpcError::ERESPONSE,
2003 => BrpcError::ELOGOFF,
2004 => BrpcError::ELIMIT,
2005 => BrpcError::ECLOSE,
2006 => BrpcError::EITP,
3001 => BrpcError::ESERIALIZE,
3002 => BrpcError::EDESERIALIZE,
3003 => BrpcError::EFFI,
_ => BrpcError::UNKNOWN,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn from_i32() {
assert_eq!(BrpcError::from(0), BrpcError::NOERROR);
assert_eq!(BrpcError::from(1001), BrpcError::ENOSERVICE);
assert_eq!(BrpcError::from(1002), BrpcError::ENOMETHOD);
assert_eq!(BrpcError::from(1003), BrpcError::EREQUEST);
assert_eq!(BrpcError::from(1004), BrpcError::ERPCAUTH);
assert_eq!(BrpcError::from(1005), BrpcError::ETOOMANYFAILS);
assert_eq!(BrpcError::from(1006), BrpcError::EPCHANFINISH);
assert_eq!(BrpcError::from(1007), BrpcError::EBACKUPREQUEST);
assert_eq!(BrpcError::from(1008), BrpcError::ERPCTIMEDOUT);
assert_eq!(BrpcError::from(1009), BrpcError::EFAILEDSOCKET);
assert_eq!(BrpcError::from(1010), BrpcError::EHTTP);
assert_eq!(BrpcError::from(1011), BrpcError::EOVERCROWDED);
assert_eq!(BrpcError::from(1012), BrpcError::ERTMPPUBLISHABLE);
assert_eq!(BrpcError::from(1013), BrpcError::ERTMPCREATESTREAM);
assert_eq!(BrpcError::from(1014), BrpcError::EEOF);
assert_eq!(BrpcError::from(1015), BrpcError::EUNUSED);
assert_eq!(BrpcError::from(1016), BrpcError::ESSL);
assert_eq!(BrpcError::from(1017), BrpcError::EH2RUNOUTSTREAMS);
assert_eq!(BrpcError::from(1018), BrpcError::EREJECT);
assert_eq!(BrpcError::from(2001), BrpcError::EINTERNAL);
assert_eq!(BrpcError::from(2002), BrpcError::ERESPONSE);
assert_eq!(BrpcError::from(2003), BrpcError::ELOGOFF);
assert_eq!(BrpcError::from(2004), BrpcError::ELIMIT);
assert_eq!(BrpcError::from(2005), BrpcError::ECLOSE);
assert_eq!(BrpcError::from(2006), BrpcError::EITP);
assert_eq!(BrpcError::from(3001), BrpcError::ESERIALIZE);
assert_eq!(BrpcError::from(3002), BrpcError::EDESERIALIZE);
assert_eq!(BrpcError::from(3003), BrpcError::EFFI);
assert_eq!(BrpcError::from(5678), BrpcError::UNKNOWN);
}
}