use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum FormationKind {
Static,
Scored,
Deliberated,
OpenClaw,
}
impl std::fmt::Display for FormationKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Static => write!(f, "static"),
Self::Scored => write!(f, "scored"),
Self::Deliberated => write!(f, "deliberated"),
Self::OpenClaw => write!(f, "open_claw"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn formation_kind_display() {
assert_eq!(FormationKind::Static.to_string(), "static");
assert_eq!(FormationKind::Scored.to_string(), "scored");
assert_eq!(FormationKind::Deliberated.to_string(), "deliberated");
assert_eq!(FormationKind::OpenClaw.to_string(), "open_claw");
}
#[test]
fn formation_kind_serde_roundtrip() {
for kind in [
FormationKind::Static,
FormationKind::Scored,
FormationKind::Deliberated,
FormationKind::OpenClaw,
] {
let json = serde_json::to_string(&kind).unwrap();
let back: FormationKind = serde_json::from_str(&json).unwrap();
assert_eq!(back, kind);
}
}
}