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