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
#![forbid(unsafe_code)] use std::str::FromStr; #[derive(Debug, Eq, PartialEq, Hash, Clone, Copy)] pub enum OutputFormat { Human, #[cfg(feature = "serde1")] Json, } impl OutputFormat { pub fn variants() -> &'static [&'static str] { &[ "human", #[cfg(feature = "serde1")] "json", ] } } impl FromStr for OutputFormat { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { let s_lc = s.to_ascii_lowercase(); Ok(match s_lc.as_str() { "human" => OutputFormat::Human, #[cfg(feature = "serde1")] "json" => OutputFormat::Json, _ => return Err(format!("Invalid output format: '{}'", s)), }) } } pub mod pack; pub mod repository;