-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconstants.rs
38 lines (35 loc) · 1.07 KB
/
constants.rs
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
use colored::*;
use std::fmt;
// PartialEq is added for the sake of Test case that uses assert_eq
#[derive(Debug, PartialEq)]
pub enum Message {
BadOption,
SOURCE1,
SOURCE2,
JSON1,
JSON2,
UnknownError,
NoMismatch,
RootMismatch,
LeftExtra,
RightExtra,
Mismatch,
}
impl fmt::Display for Message {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let message = match self {
Message::BadOption => "Invalid option.",
Message::SOURCE1 => "Could not read source1.",
Message::SOURCE2 => "Could not read source2.",
Message::JSON1 => "Could not parse source1.",
Message::JSON2 => "Could not parse source2.",
Message::UnknownError => "",
Message::NoMismatch => "No mismatch was found.",
Message::RootMismatch => "Mismatch at root.",
Message::LeftExtra => "Extra on left",
Message::RightExtra => "Extra on right",
Message::Mismatch => "Mismatched",
};
write!(f, "{}", message.bold())
}
}