The moods the site shows: a subset of the app's (whiskers_pet::Mood), which pet maps to.
The word the page and its signals use.
The core's mood of the same name. An exhaustive match: a mood added here is not drawn until the core has it.
30 pub fn pet(self) -> whiskers_pet::Mood { 31 match self { 32 Mood::Idle => whiskers_pet::Mood::Idle, 33 Mood::Listening => whiskers_pet::Mood::Listening, 34 Mood::Thinking => whiskers_pet::Mood::Thinking, 35 Mood::Speaking => whiskers_pet::Mood::Speaking, 36 Mood::Dizzy => whiskers_pet::Mood::Dizzy, 37 Mood::Sleeping => whiskers_pet::Mood::Sleeping, 38 } 39 }
41 pub fn parse(name: &str) -> Option<Mood> { 42 Mood::ALL.into_iter().find(|mood| mood.name() == name) 43 } 44} 45 46#[cfg(test)] 47mod tests { 48 use super::*; 49 50 #[test] 51 fn names_round_trip() { 52 for mood in Mood::ALL { 53 assert_eq!(Mood::parse(mood.name()), Some(mood)); 54 } 55 assert_eq!(Mood::parse("Idle"), None); 56 assert_eq!(Mood::parse(""), None); 57 } 58}