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
use super::GNVerifyError;
use strum_macros::Display;
#[derive(Debug, Display, Clone)]
pub enum Format {
CSV,
Compact,
Pretty,
}
impl Default for Format {
fn default() -> Self {
Format::CSV
}
}
impl Format {
pub fn new(f: &str) -> Result<Self, GNVerifyError> {
match f {
"pretty" => Ok(Format::Pretty),
"compact" => Ok(Format::Compact),
"csv" => Ok(Format::CSV),
_ => Err(GNVerifyError::InvalidFormatString {
format: f.to_owned(),
}),
}
}
}
#[test]
fn format_as_str() {
assert_eq!(Format::CSV.to_string(), "CSV")
}