Skip to main content

nominal_api_conjure/conjure/objects/api/
property_comparison_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 PropertyComparisonOperator {
17    #[serde(rename = "EQ")]
18    Eq,
19    #[serde(rename = "NEQ")]
20    Neq,
21    #[serde(rename = "GT")]
22    Gt,
23    #[serde(rename = "GEQ")]
24    Geq,
25    #[serde(rename = "LT")]
26    Lt,
27    #[serde(rename = "LEQ")]
28    Leq,
29    /// An unknown variant.
30    #[serde(untagged)]
31    Unknown(Unknown),
32}
33impl PropertyComparisonOperator {
34    /// Returns the string representation of the enum.
35    #[inline]
36    pub fn as_str(&self) -> &str {
37        match self {
38            PropertyComparisonOperator::Eq => "EQ",
39            PropertyComparisonOperator::Neq => "NEQ",
40            PropertyComparisonOperator::Gt => "GT",
41            PropertyComparisonOperator::Geq => "GEQ",
42            PropertyComparisonOperator::Lt => "LT",
43            PropertyComparisonOperator::Leq => "LEQ",
44            PropertyComparisonOperator::Unknown(v) => &*v,
45        }
46    }
47}
48impl fmt::Display for PropertyComparisonOperator {
49    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
50        fmt::Display::fmt(self.as_str(), fmt)
51    }
52}
53impl conjure_object::Plain for PropertyComparisonOperator {
54    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
55        conjure_object::Plain::fmt(self.as_str(), fmt)
56    }
57}
58impl str::FromStr for PropertyComparisonOperator {
59    type Err = conjure_object::plain::ParseEnumError;
60    #[inline]
61    fn from_str(
62        v: &str,
63    ) -> Result<PropertyComparisonOperator, conjure_object::plain::ParseEnumError> {
64        match v {
65            "EQ" => Ok(PropertyComparisonOperator::Eq),
66            "NEQ" => Ok(PropertyComparisonOperator::Neq),
67            "GT" => Ok(PropertyComparisonOperator::Gt),
68            "GEQ" => Ok(PropertyComparisonOperator::Geq),
69            "LT" => Ok(PropertyComparisonOperator::Lt),
70            "LEQ" => Ok(PropertyComparisonOperator::Leq),
71            v => v.parse().map(|v| PropertyComparisonOperator::Unknown(Unknown(v))),
72        }
73    }
74}
75impl conjure_object::FromPlain for PropertyComparisonOperator {
76    type Err = conjure_object::plain::ParseEnumError;
77    #[inline]
78    fn from_plain(
79        v: &str,
80    ) -> Result<PropertyComparisonOperator, conjure_object::plain::ParseEnumError> {
81        v.parse()
82    }
83}
84///An unknown variant of the PropertyComparisonOperator enum.
85#[derive(
86    Debug,
87    Clone,
88    PartialEq,
89    Eq,
90    PartialOrd,
91    Ord,
92    Hash,
93    conjure_object::serde::Deserialize,
94    conjure_object::serde::Serialize,
95)]
96#[serde(crate = "conjure_object::serde", transparent)]
97pub struct Unknown(conjure_object::private::Variant);
98impl std::ops::Deref for Unknown {
99    type Target = str;
100    #[inline]
101    fn deref(&self) -> &str {
102        &self.0
103    }
104}
105impl fmt::Display for Unknown {
106    #[inline]
107    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
108        fmt::Display::fmt(&self.0, fmt)
109    }
110}