1use clap::ValueEnum;
2
3#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
5pub enum ImageFormat {
6 Png,
8 Jpeg,
10 Bmp,
12}
13
14#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
16pub enum DictionaryFormat {
17 Toml,
19 Json,
21 Yaml,
23 Ron,
25}
26
27impl Default for ImageFormat {
28 fn default() -> Self {
29 Self::Png
30 }
31}
32
33impl Default for DictionaryFormat {
34 fn default() -> Self {
35 Self::Json
36 }
37}
38
39impl ImageFormat {
40 pub fn ext(&self) -> &str {
45 match self {
46 ImageFormat::Png => "png",
47 ImageFormat::Jpeg => "jpeg",
48 ImageFormat::Bmp => "bmp",
49 }
50 }
51
52 pub fn as_image_format(&self) -> image::ImageFormat {
54 match self {
55 ImageFormat::Png => image::ImageFormat::Png,
56 ImageFormat::Jpeg => image::ImageFormat::Jpeg,
57 ImageFormat::Bmp => image::ImageFormat::Bmp,
58 }
59 }
60}
61
62impl DictionaryFormat {
63 pub fn ext(&self) -> &str {
69 match self {
70 DictionaryFormat::Toml => "toml",
71 DictionaryFormat::Json => "json",
72 DictionaryFormat::Yaml => "yaml",
73 DictionaryFormat::Ron => "ron",
74 }
75 }
76}