#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Lifetime {
Singleton,
Scoped,
#[default]
Transient,
}
impl Lifetime {
pub fn is_singleton(&self) -> bool {
matches!(self, Lifetime::Singleton)
}
pub fn is_scoped(&self) -> bool {
matches!(self, Lifetime::Scoped)
}
pub fn is_transient(&self) -> bool {
matches!(self, Lifetime::Transient)
}
}
impl std::fmt::Display for Lifetime {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Lifetime::Singleton => write!(f, "Singleton"),
Lifetime::Scoped => write!(f, "Scoped"),
Lifetime::Transient => write!(f, "Transient"),
}
}
}