Skip to main content

nominal_api/conjure/objects/api/
set_operator.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 SetOperator {
17    #[serde(rename = "AND")]
18    And,
19    #[serde(rename = "OR")]
20    Or,
21    /// An unknown variant.
22    #[serde(untagged)]
23    Unknown(Unknown),
24}
25impl SetOperator {
26    /// Returns the string representation of the enum.
27    #[inline]
28    pub fn as_str(&self) -> &str {
29        match self {
30            SetOperator::And => "AND",
31            SetOperator::Or => "OR",
32            SetOperator::Unknown(v) => &*v,
33        }
34    }
35}
36impl fmt::Display for SetOperator {
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 SetOperator {
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 SetOperator {
47    type Err = conjure_object::plain::ParseEnumError;
48    #[inline]
49    fn from_str(v: &str) -> Result<SetOperator, conjure_object::plain::ParseEnumError> {
50        match v {
51            "AND" => Ok(SetOperator::And),
52            "OR" => Ok(SetOperator::Or),
53            v => v.parse().map(|v| SetOperator::Unknown(Unknown(v))),
54        }
55    }
56}
57impl conjure_object::FromPlain for SetOperator {
58    type Err = conjure_object::plain::ParseEnumError;
59    #[inline]
60    fn from_plain(
61        v: &str,
62    ) -> Result<SetOperator, conjure_object::plain::ParseEnumError> {
63        v.parse()
64    }
65}
66///An unknown variant of the SetOperator enum.
67#[derive(
68    Debug,
69    Clone,
70    PartialEq,
71    Eq,
72    PartialOrd,
73    Ord,
74    Hash,
75    conjure_object::serde::Deserialize,
76    conjure_object::serde::Serialize,
77)]
78#[serde(crate = "conjure_object::serde", transparent)]
79pub struct Unknown(conjure_object::private::Variant);
80impl std::ops::Deref for Unknown {
81    type Target = str;
82    #[inline]
83    fn deref(&self) -> &str {
84        &self.0
85    }
86}
87impl fmt::Display for Unknown {
88    #[inline]
89    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
90        fmt::Display::fmt(&self.0, fmt)
91    }
92}