#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Overwrite {
Allow,
Preserve,
}
impl Overwrite {
pub fn as_bool(self) -> bool {
matches!(self, Overwrite::Allow)
}
}
impl From<bool> for Overwrite {
fn from(value: bool) -> Self {
if value {
Overwrite::Allow
} else {
Overwrite::Preserve
}
}
}
impl From<Overwrite> for bool {
fn from(value: Overwrite) -> Self {
value.as_bool()
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum RefreshStrategy {
Force,
UseCache,
}
impl RefreshStrategy {
pub fn is_force(self) -> bool {
matches!(self, RefreshStrategy::Force)
}
}
impl From<bool> for RefreshStrategy {
fn from(value: bool) -> Self {
if value {
RefreshStrategy::Force
} else {
RefreshStrategy::UseCache
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum CacheMode {
Enabled,
#[default]
Disabled,
}
impl CacheMode {
pub fn is_enabled(self) -> bool {
matches!(self, CacheMode::Enabled)
}
}
impl From<bool> for CacheMode {
fn from(value: bool) -> Self {
if value {
CacheMode::Enabled
} else {
CacheMode::Disabled
}
}
}
impl From<CacheMode> for bool {
fn from(value: CacheMode) -> Self {
value.is_enabled()
}
}