1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum Encoding {
6 Text,
8
9 TextZip,
11
12 BinaryZip,
14
15 Binary,
17}
18
19impl Encoding {
20 pub fn as_str(&self) -> &'static str {
21 match self {
22 Encoding::Text => "text",
23 Encoding::TextZip => "textzip",
24 Encoding::BinaryZip => "binzip",
25 Encoding::Binary => "binary",
26 }
27 }
28
29 pub fn is_binary(&self) -> bool {
30 matches!(self, Encoding::BinaryZip | Encoding::Binary)
31 }
32
33 pub fn is_text(&self) -> bool {
34 matches!(self, Encoding::TextZip | Encoding::Text)
35 }
36
37 pub fn is_zip(&self) -> bool {
38 matches!(self, Encoding::BinaryZip | Encoding::TextZip)
39 }
40}
41
42impl fmt::Display for Encoding {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 write!(f, "{}", self.as_str())
45 }
46}