#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum RuntimeState {
#[default]
Booting,
Running,
Stopping,
Emergency,
}
impl RuntimeState {
#[inline]
#[must_use]
pub const fn is_running(&self) -> bool {
matches!(self, Self::Running)
}
#[inline]
#[must_use]
pub const fn is_shutting_down(&self) -> bool {
matches!(self, Self::Stopping | Self::Emergency)
}
#[inline]
#[must_use]
pub const fn can_accept_work(&self) -> bool {
self.is_running()
}
#[inline]
#[must_use]
pub const fn is_terminal(&self) -> bool {
matches!(self, Self::Stopping | Self::Emergency)
}
}
impl std::fmt::Display for RuntimeState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Booting => write!(f, "Booting"),
Self::Running => write!(f, "Running"),
Self::Stopping => write!(f, "Stopping"),
Self::Emergency => write!(f, "Emergency"),
}
}
}