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
#[derive(Debug, Clone)]
pub enum Error {
UnclosedColumnSpec(String),
BadColumnSpec(String),
UnexpectedRightBrace,
UnexpectedCharacter(char),
}
impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::UnclosedColumnSpec(_) => "unclosed column specifier",
Error::BadColumnSpec(_) => "bad format specifier",
Error::UnexpectedRightBrace => "unexpected single '}' character",
Error::UnexpectedCharacter(_) => "unexpected character in column specifier",
}
}
}
impl ::std::fmt::Display for Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match *self {
Error::UnclosedColumnSpec(ref spec) => {
write!(f, "unclosed column specifier: {:?}", spec)
}
Error::BadColumnSpec(ref spec) => write!(f, "bad format specifier: {:?}", spec),
Error::UnexpectedRightBrace => f.write_str("unexpected single '}' character"),
Error::UnexpectedCharacter(c) => {
write!(f, "unexpected character in column specifier: {:?}", c)
}
}
}
}
pub type Result<T, E = Error> = ::std::result::Result<T, E>;