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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
use crate::errors::*; use colored::*; use strum_macros::{EnumString, AsRefStr, Display}; use serde::{Serialize, Deserialize}; use std::str::FromStr; pub mod api; pub mod config; pub mod errors; pub mod utils; #[derive(Debug, Clone, Copy, PartialEq, Display, EnumString, AsRefStr, Serialize, Deserialize)] #[strum(serialize_all = "kebab-case")] pub enum Distro { Debian, Archlinux, } #[derive(Debug, Serialize, Deserialize)] pub struct PkgRelease { pub name: String, pub version: String, pub status: Status, pub distro: String, pub suite: String, pub architecture: String, pub url: String, } #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum Status { Good, Bad, Unknown, } impl Status { pub fn fancy(&self) -> String { match self { Status::Good => "GOOD ".green().to_string(), Status::Bad => "BAD ".red().to_string(), Status::Unknown => "UNKWN".yellow().to_string(), } } } impl ToString for Status { fn to_string(&self) -> String { match self { Status::Good => "GOOD".to_string(), Status::Bad => "BAD".to_string(), Status::Unknown => "UNKWN".to_string(), } } } impl FromStr for Status { type Err = Error; fn from_str(s: &str) -> Result<Status> { match s { "GOOD" => Ok(Status::Good), "BAD" => Ok(Status::Bad), "UNKWN" => Ok(Status::Unknown), _ => bail!("Unknown status: {:?}", s), } } } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }