#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FollowMode {
Follow,
Disabled,
Memory,
}
impl FollowMode {
pub const fn from_bool(value: bool) -> Self {
if value { Self::Follow } else { Self::Disabled }
}
pub fn parse(value: &str) -> Option<Self> {
match value.trim().to_ascii_lowercase().as_str() {
"true" | "1" => Some(Self::Follow),
"false" | "0" => Some(Self::Disabled),
"mem" => Some(Self::Memory),
_ => None,
}
}
pub const fn as_str(self) -> &'static str {
match self {
Self::Follow => "true",
Self::Disabled => "false",
Self::Memory => "mem",
}
}
pub const fn follows(self) -> bool {
!matches!(self, Self::Disabled)
}
pub const fn is_memory(self) -> bool {
matches!(self, Self::Memory)
}
}