Skip to main content

nominal_api/conjure/objects/scout/datareview/api/
status.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4#[derive(
5    Debug,
6    Clone,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash,
12    conjure_object::serde::Deserialize,
13    conjure_object::serde::Serialize,
14)]
15#[serde(crate = "conjure_object::serde")]
16pub enum Status {
17    #[serde(rename = "PASS")]
18    Pass,
19    #[serde(rename = "FAIL")]
20    Fail,
21    /// An unknown variant.
22    #[serde(untagged)]
23    Unknown(Unknown),
24}
25impl Status {
26    /// Returns the string representation of the enum.
27    #[inline]
28    pub fn as_str(&self) -> &str {
29        match self {
30            Status::Pass => "PASS",
31            Status::Fail => "FAIL",
32            Status::Unknown(v) => &*v,
33        }
34    }
35}
36impl fmt::Display for Status {
37    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
38        fmt::Display::fmt(self.as_str(), fmt)
39    }
40}
41impl conjure_object::Plain for Status {
42    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
43        conjure_object::Plain::fmt(self.as_str(), fmt)
44    }
45}
46impl str::FromStr for Status {
47    type Err = conjure_object::plain::ParseEnumError;
48    #[inline]
49    fn from_str(v: &str) -> Result<Status, conjure_object::plain::ParseEnumError> {
50        match v {
51            "PASS" => Ok(Status::Pass),
52            "FAIL" => Ok(Status::Fail),
53            v => v.parse().map(|v| Status::Unknown(Unknown(v))),
54        }
55    }
56}
57impl conjure_object::FromPlain for Status {
58    type Err = conjure_object::plain::ParseEnumError;
59    #[inline]
60    fn from_plain(v: &str) -> Result<Status, conjure_object::plain::ParseEnumError> {
61        v.parse()
62    }
63}
64///An unknown variant of the Status enum.
65#[derive(
66    Debug,
67    Clone,
68    PartialEq,
69    Eq,
70    PartialOrd,
71    Ord,
72    Hash,
73    conjure_object::serde::Deserialize,
74    conjure_object::serde::Serialize,
75)]
76#[serde(crate = "conjure_object::serde", transparent)]
77pub struct Unknown(conjure_object::private::Variant);
78impl std::ops::Deref for Unknown {
79    type Target = str;
80    #[inline]
81    fn deref(&self) -> &str {
82        &self.0
83    }
84}
85impl fmt::Display for Unknown {
86    #[inline]
87    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
88        fmt::Display::fmt(&self.0, fmt)
89    }
90}