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
use core::fmt;
use arrayvec::ArrayString;
use crate::constants::MAX_ERR_LEN;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
pub enum ErrorKind {
C {
msg: ArrayString<[u8; MAX_ERR_LEN]>,
},
Capacity {
len: usize,
cap: usize,
},
Other {
msg: ArrayString<[u8; MAX_ERR_LEN]>,
},
ParseLocale {
input: ArrayString<[u8; MAX_ERR_LEN]>,
},
}
impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::ErrorKind::*;
match self {
C { msg } => write!(f, "received unexpected return value from C: {}", msg),
Capacity { len, cap } => write!(
f,
"attempted to write input of length {} bytes into buffer with capacity {} bytes.",
len, cap
),
Other { msg } => write!(f, "miscellaneous error: {}", msg),
ParseLocale { input } => {
write!(f, "failed to parse input into a Locale. input: {}", input)
}
}
}
}