m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-17 09:33:38 -05:00
Many many many changes, honestly just read the release notes
This commit is contained in:
Sergio
2025-02-28 20:43:49 +02:00
committed by GitHub
parent b12acba745
commit 0f9c5d1466
141 changed files with 4527 additions and 5848 deletions

42
src/structs/status.rs Normal file
View File

@@ -0,0 +1,42 @@
use std::fmt::Display;
/// Enum for image status
#[derive(Ord, Eq, PartialEq, PartialOrd, Clone, Debug)]
pub enum Status {
UpdateMajor,
UpdateMinor,
UpdatePatch,
UpdateAvailable,
UpToDate,
Unknown(String),
}
impl Display for Status {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match &self {
Self::UpToDate => "Up to date",
Self::UpdateAvailable => "Update available",
Self::UpdateMajor => "Major update",
Self::UpdateMinor => "Minor update",
Self::UpdatePatch => "Patch update",
Self::Unknown(_) => "Unknown",
})
}
}
impl Status {
// Converts the Status into an Option<bool> (useful for JSON serialization)
pub fn to_option_bool(&self) -> Option<bool> {
match &self {
Self::UpToDate => Some(false),
Self::Unknown(_) => None,
_ => Some(true),
}
}
}
impl Default for Status {
fn default() -> Self {
Self::Unknown("".to_string())
}
}