nextcloud_ocs/query/
format.rs1use std::fmt;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
9pub enum OcsFormat {
10 #[default]
12 Json,
13 Xml,
15}
16
17impl OcsFormat {
18 pub const fn as_str(self) -> &'static str {
20 match self {
21 Self::Json => "json",
22 Self::Xml => "xml",
23 }
24 }
25
26 pub const PARAM: &'static str = "format";
28}
29
30impl fmt::Display for OcsFormat {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 f.write_str(self.as_str())
33 }
34}
35
36#[cfg(test)]
37mod tests {
38 use super::OcsFormat;
39
40 #[test]
41 fn json_is_the_default() {
42 assert_eq!(OcsFormat::default(), OcsFormat::Json);
43 assert_eq!(OcsFormat::Json.to_string(), "json");
44 assert_eq!(OcsFormat::Xml.to_string(), "xml");
45 }
46}