#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Outcome {
Valid {
rehashed: Option<String>,
},
Invalid,
}
impl Outcome {
#[must_use]
pub const fn is_valid(&self) -> bool {
matches!(self, Outcome::Valid { .. })
}
#[must_use]
pub const fn needs_rehash(&self) -> bool {
matches!(self, Outcome::Valid { rehashed: Some(_) })
}
#[must_use]
pub fn rehashed(&self) -> Option<&str> {
match self {
Outcome::Valid { rehashed: Some(p) } => Some(p.as_str()),
_ => None,
}
}
#[must_use]
pub fn into_rehashed(self) -> Option<String> {
match self {
Outcome::Valid { rehashed } => rehashed,
Outcome::Invalid => None,
}
}
}