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