pub const SCHEMA_VERSION: u64 = 1;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Outcome {
Hit,
ZeroHit,
Ambiguous,
FallbackAdvised,
}
impl Outcome {
pub const ALL: [Outcome; 4] = [
Outcome::Hit,
Outcome::ZeroHit,
Outcome::Ambiguous,
Outcome::FallbackAdvised,
];
pub fn as_str(self) -> &'static str {
match self {
Outcome::Hit => "hit",
Outcome::ZeroHit => "zero-hit",
Outcome::Ambiguous => "ambiguous",
Outcome::FallbackAdvised => "fallback-advised",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_outcome_word_is_one_of_the_closed_vocabulary() {
const EXPECTED: &[&str] = &["hit", "zero-hit", "ambiguous", "fallback-advised"];
let words: Vec<&str> = Outcome::ALL.iter().map(|o| o.as_str()).collect();
for word in &words {
assert!(
EXPECTED.contains(word),
"{word} is not in the closed outcome vocabulary"
);
}
assert_eq!(
words.len(),
EXPECTED.len(),
"ALL must name every vocabulary word exactly once"
);
}
}