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