Skip to main content

nominal_api/conjure/objects/scout/compute/api/
numeric_union_operation.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4/// DEPRECATED: apply aggregations as a separate step over the unioned output.
5#[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    /// Combines multiple points by taking the minimum value
19    #[serde(rename = "MIN")]
20    Min,
21    /// Combines multiple points by taking the maximum value
22    #[serde(rename = "MAX")]
23    Max,
24    /// Combines multiple points by taking the mean of the values
25    #[serde(rename = "MEAN")]
26    Mean,
27    /// Combines multiple points by taking the sum of the values
28    #[serde(rename = "SUM")]
29    Sum,
30    /// Combines multiple points by taking the count of the values
31    #[serde(rename = "COUNT")]
32    Count,
33    /// Combines multiple points by taking the standard deviation of the values
34    #[serde(rename = "STANDARD_DEVIATION")]
35    StandardDeviation,
36    /// Combines multiple points by taking the root mean square of the values
37    #[serde(rename = "ROOT_MEAN_SQUARE")]
38    RootMeanSquare,
39    /// Throws a DuplicateTimestamp error if two series contain points with a duplicate timestamp.
40    #[serde(rename = "THROW")]
41    Throw,
42    /// An unknown variant.
43    #[serde(untagged)]
44    Unknown(Unknown),
45}
46impl NumericUnionOperation {
47    /// Returns the string representation of the enum.
48    #[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///An unknown variant of the NumericUnionOperation enum.
102#[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}