use std::fmt;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ParticipantKind {
Person,
Agent,
}
impl ParticipantKind {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Person => "person",
Self::Agent => "agent",
}
}
}
impl fmt::Display for ParticipantKind {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_str())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn both_kinds_name_themselves() {
assert_eq!(ParticipantKind::Person.to_string(), "person");
assert_eq!(ParticipantKind::Agent.to_string(), "agent");
}
}