use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Action {
OpticalStep,
Predict,
Match,
Diffuse,
Stutter,
}
impl Action {
pub const ALL: [Action; 5] = [
Action::OpticalStep,
Action::Predict,
Action::Match,
Action::Diffuse,
Action::Stutter,
];
pub const PRODUCTIVE: [Action; 4] = [
Action::OpticalStep,
Action::Predict,
Action::Match,
Action::Diffuse,
];
pub const PHI_CYCLE: [Action; 4] = [
Action::OpticalStep,
Action::Predict,
Action::Match,
Action::Diffuse,
];
pub fn symbol(&self) -> &'static str {
match self {
Action::OpticalStep => "O",
Action::Predict => "P",
Action::Match => "M",
Action::Diffuse => "D",
Action::Stutter => "S",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn action_has_exactly_five_variants() {
assert_eq!(Action::ALL.len(), 5);
assert_eq!(Action::PRODUCTIVE.len(), 4);
}
}