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