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