use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter, Result};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ResourceStatus {
Missing,
Downloaded,
Built,
Running,
}
impl ResourceStatus {
#[must_use]
pub const fn is_missing(&self) -> bool {
matches!(self, Self::Missing)
}
#[must_use]
pub const fn is_available(&self) -> bool {
matches!(self, Self::Downloaded | Self::Built | Self::Running)
}
#[must_use]
pub const fn is_built(&self) -> bool {
matches!(self, Self::Built | Self::Running)
}
#[must_use]
pub const fn is_running(&self) -> bool {
matches!(self, Self::Running)
}
}
impl Display for ResourceStatus {
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
match self {
Self::Missing => write!(fmt, "Missing"),
Self::Downloaded => write!(fmt, "Downloaded"),
Self::Built => write!(fmt, "Built"),
Self::Running => write!(fmt, "Running"),
}
}
}