1use std::error;
2use std::fmt;
3use std::result;
4use std::string::String;
5
6#[derive(Debug, Clone, PartialEq)]
7pub enum Alignment {
8 Unspecified, Left,
10 Center,
11 Right,
12 Equal,
13}
14
15#[derive(Debug, Clone, PartialEq)]
16pub enum Sign {
17 Unspecified,
18 Plus,
19 Minus,
20 Space,
21}
22
23impl Sign {
24 pub fn is_unspecified(&self) -> bool {
25 match *self {
26 Sign::Unspecified => false,
27 _ => true,
28 }
29 }
30}
31
32pub type Result<T> = result::Result<T, FmtError>;
33
34#[derive(Debug, PartialEq)]
36pub enum FmtError {
37 Invalid(String), KeyError(String), TypeError(String), }
41
42impl fmt::Display for FmtError {
43 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
44 match *self {
45 FmtError::Invalid(ref s) => write!(f, "Invalid({})", s),
46 FmtError::KeyError(ref s) => write!(f, "KeyError({})", s),
47 FmtError::TypeError(ref s) => write!(f, "TypeError({})", s),
48 }
49 }
50}
51
52impl error::Error for FmtError {
53 fn description(&self) -> &str {
54 match *self {
55 FmtError::Invalid(_) => "invalid format string",
56 FmtError::KeyError(_) => "invalid key",
57 FmtError::TypeError(_) => "error during type resolution",
58 }
59 }
60
61 fn cause(&self) -> Option<&dyn error::Error> {
62 None
63 }
64}
65
66