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