use std::fmt;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum OcsFormat {
#[default]
Json,
Xml,
}
impl OcsFormat {
pub const fn as_str(self) -> &'static str {
match self {
Self::Json => "json",
Self::Xml => "xml",
}
}
pub const PARAM: &'static str = "format";
}
impl fmt::Display for OcsFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(test)]
mod tests {
use super::OcsFormat;
#[test]
fn json_is_the_default() {
assert_eq!(OcsFormat::default(), OcsFormat::Json);
assert_eq!(OcsFormat::Json.to_string(), "json");
assert_eq!(OcsFormat::Xml.to_string(), "xml");
}
}