use conjure_object::serde::{ser, de};
use conjure_object::serde::ser::SerializeMap as SerializeMap_;
use conjure_object::private::{UnionField_, UnionTypeField_};
use std::fmt;
#[derive(Debug, Clone, conjure_object::private::DeriveWith)]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum NumericSeriesNode {
Constant(super::ConstantNumericSeriesNode),
Arithmetic(super::ArithmeticSeriesNode),
BitOperation(super::BitOperationSeriesNode),
CountDuplicate(super::EnumCountDuplicateSeriesNode),
CumulativeSum(super::CumulativeSumSeriesNode),
Derivative(super::DerivativeSeriesNode),
Integral(super::IntegralSeriesNode),
Max(super::MaxSeriesNode),
Mean(super::MeanSeriesNode),
Min(super::MinSeriesNode),
Offset(super::OffsetSeriesNode),
Product(super::ProductSeriesNode),
OldestPoints(super::SelectOldestPointsSeriesNode),
Raw(super::RawNumericSeriesNode),
Resample(super::NumericResampleSeriesNode),
RollingOperation(super::RollingOperationSeriesNode),
Aggregate(super::AggregateNumericSeriesNode),
SignalFilter(super::SignalFilterSeriesNode),
Sum(super::SumSeriesNode),
Scale(super::ScaleSeriesNode),
TimeDifference(super::TimeDifferenceSeriesNode),
TimeRangeFilter(super::NumericTimeRangeFilterSeriesNode),
Union(super::NumericUnionSeriesNode),
UnitConversion(super::UnitConversionSeriesNode),
ValueDifference(super::ValueDifferenceSeriesNode),
FilterTransformation(super::NumericFilterTransformationSeriesNode),
ThresholdFilter(super::NumericThresholdFilterSeriesNode),
DropNan(super::NumericNanFilterNode),
ArraySelect(super::SelectIndexFromNumericArraySeriesNode),
AbsoluteTimestamp(super::AbsoluteTimestampSeriesNode),
NewestPoints(super::SelectNewestPointsSeriesNode),
RangesNumericAggregationToNumeric(
super::RangesNumericAggregationToNumericSeriesNode,
),
FilterByExpression(super::FilterByExpressionSeriesNode),
ScalarUdf(super::ScalarUdfSeriesNode),
EnumToNumeric(super::EnumToNumericSeriesNode),
Refprop(super::RefpropSeriesNode),
ExtractFromStruct(super::ExtractNumericFromStructSeriesNode),
ZScore(super::ZscoreSeriesNode),
TagByIntervals(super::TagByIntervalsSeriesNode),
GenericTransform(Box<super::GenericTransformNode>),
Unknown(Unknown),
}
impl ser::Serialize for NumericSeriesNode {
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
S: ser::Serializer,
{
let mut map = s.serialize_map(Some(2))?;
match self {
NumericSeriesNode::Constant(value) => {
map.serialize_entry(&"type", &"constant")?;
map.serialize_entry(&"constant", value)?;
}
NumericSeriesNode::Arithmetic(value) => {
map.serialize_entry(&"type", &"arithmetic")?;
map.serialize_entry(&"arithmetic", value)?;
}
NumericSeriesNode::BitOperation(value) => {
map.serialize_entry(&"type", &"bitOperation")?;
map.serialize_entry(&"bitOperation", value)?;
}
NumericSeriesNode::CountDuplicate(value) => {
map.serialize_entry(&"type", &"countDuplicate")?;
map.serialize_entry(&"countDuplicate", value)?;
}
NumericSeriesNode::CumulativeSum(value) => {
map.serialize_entry(&"type", &"cumulativeSum")?;
map.serialize_entry(&"cumulativeSum", value)?;
}
NumericSeriesNode::Derivative(value) => {
map.serialize_entry(&"type", &"derivative")?;
map.serialize_entry(&"derivative", value)?;
}
NumericSeriesNode::Integral(value) => {
map.serialize_entry(&"type", &"integral")?;
map.serialize_entry(&"integral", value)?;
}
NumericSeriesNode::Max(value) => {
map.serialize_entry(&"type", &"max")?;
map.serialize_entry(&"max", value)?;
}
NumericSeriesNode::Mean(value) => {
map.serialize_entry(&"type", &"mean")?;
map.serialize_entry(&"mean", value)?;
}
NumericSeriesNode::Min(value) => {
map.serialize_entry(&"type", &"min")?;
map.serialize_entry(&"min", value)?;
}
NumericSeriesNode::Offset(value) => {
map.serialize_entry(&"type", &"offset")?;
map.serialize_entry(&"offset", value)?;
}
NumericSeriesNode::Product(value) => {
map.serialize_entry(&"type", &"product")?;
map.serialize_entry(&"product", value)?;
}
NumericSeriesNode::OldestPoints(value) => {
map.serialize_entry(&"type", &"oldestPoints")?;
map.serialize_entry(&"oldestPoints", value)?;
}
NumericSeriesNode::Raw(value) => {
map.serialize_entry(&"type", &"raw")?;
map.serialize_entry(&"raw", value)?;
}
NumericSeriesNode::Resample(value) => {
map.serialize_entry(&"type", &"resample")?;
map.serialize_entry(&"resample", value)?;
}
NumericSeriesNode::RollingOperation(value) => {
map.serialize_entry(&"type", &"rollingOperation")?;
map.serialize_entry(&"rollingOperation", value)?;
}
NumericSeriesNode::Aggregate(value) => {
map.serialize_entry(&"type", &"aggregate")?;
map.serialize_entry(&"aggregate", value)?;
}
NumericSeriesNode::SignalFilter(value) => {
map.serialize_entry(&"type", &"signalFilter")?;
map.serialize_entry(&"signalFilter", value)?;
}
NumericSeriesNode::Sum(value) => {
map.serialize_entry(&"type", &"sum")?;
map.serialize_entry(&"sum", value)?;
}
NumericSeriesNode::Scale(value) => {
map.serialize_entry(&"type", &"scale")?;
map.serialize_entry(&"scale", value)?;
}
NumericSeriesNode::TimeDifference(value) => {
map.serialize_entry(&"type", &"timeDifference")?;
map.serialize_entry(&"timeDifference", value)?;
}
NumericSeriesNode::TimeRangeFilter(value) => {
map.serialize_entry(&"type", &"timeRangeFilter")?;
map.serialize_entry(&"timeRangeFilter", value)?;
}
NumericSeriesNode::Union(value) => {
map.serialize_entry(&"type", &"union")?;
map.serialize_entry(&"union", value)?;
}
NumericSeriesNode::UnitConversion(value) => {
map.serialize_entry(&"type", &"unitConversion")?;
map.serialize_entry(&"unitConversion", value)?;
}
NumericSeriesNode::ValueDifference(value) => {
map.serialize_entry(&"type", &"valueDifference")?;
map.serialize_entry(&"valueDifference", value)?;
}
NumericSeriesNode::FilterTransformation(value) => {
map.serialize_entry(&"type", &"filterTransformation")?;
map.serialize_entry(&"filterTransformation", value)?;
}
NumericSeriesNode::ThresholdFilter(value) => {
map.serialize_entry(&"type", &"thresholdFilter")?;
map.serialize_entry(&"thresholdFilter", value)?;
}
NumericSeriesNode::DropNan(value) => {
map.serialize_entry(&"type", &"dropNan")?;
map.serialize_entry(&"dropNan", value)?;
}
NumericSeriesNode::ArraySelect(value) => {
map.serialize_entry(&"type", &"arraySelect")?;
map.serialize_entry(&"arraySelect", value)?;
}
NumericSeriesNode::AbsoluteTimestamp(value) => {
map.serialize_entry(&"type", &"absoluteTimestamp")?;
map.serialize_entry(&"absoluteTimestamp", value)?;
}
NumericSeriesNode::NewestPoints(value) => {
map.serialize_entry(&"type", &"newestPoints")?;
map.serialize_entry(&"newestPoints", value)?;
}
NumericSeriesNode::RangesNumericAggregationToNumeric(value) => {
map.serialize_entry(&"type", &"rangesNumericAggregationToNumeric")?;
map.serialize_entry(&"rangesNumericAggregationToNumeric", value)?;
}
NumericSeriesNode::FilterByExpression(value) => {
map.serialize_entry(&"type", &"filterByExpression")?;
map.serialize_entry(&"filterByExpression", value)?;
}
NumericSeriesNode::ScalarUdf(value) => {
map.serialize_entry(&"type", &"scalarUdf")?;
map.serialize_entry(&"scalarUdf", value)?;
}
NumericSeriesNode::EnumToNumeric(value) => {
map.serialize_entry(&"type", &"enumToNumeric")?;
map.serialize_entry(&"enumToNumeric", value)?;
}
NumericSeriesNode::Refprop(value) => {
map.serialize_entry(&"type", &"refprop")?;
map.serialize_entry(&"refprop", value)?;
}
NumericSeriesNode::ExtractFromStruct(value) => {
map.serialize_entry(&"type", &"extractFromStruct")?;
map.serialize_entry(&"extractFromStruct", value)?;
}
NumericSeriesNode::ZScore(value) => {
map.serialize_entry(&"type", &"zScore")?;
map.serialize_entry(&"zScore", value)?;
}
NumericSeriesNode::TagByIntervals(value) => {
map.serialize_entry(&"type", &"tagByIntervals")?;
map.serialize_entry(&"tagByIntervals", value)?;
}
NumericSeriesNode::GenericTransform(value) => {
map.serialize_entry(&"type", &"genericTransform")?;
map.serialize_entry(&"genericTransform", value)?;
}
NumericSeriesNode::Unknown(value) => {
map.serialize_entry(&"type", &value.type_)?;
map.serialize_entry(&value.type_, &value.value)?;
}
}
map.end()
}
}
impl<'de> de::Deserialize<'de> for NumericSeriesNode {
fn deserialize<D>(d: D) -> Result<NumericSeriesNode, D::Error>
where
D: de::Deserializer<'de>,
{
d.deserialize_map(Visitor_)
}
}
struct Visitor_;
impl<'de> de::Visitor<'de> for Visitor_ {
type Value = NumericSeriesNode;
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str("union NumericSeriesNode")
}
fn visit_map<A>(self, mut map: A) -> Result<NumericSeriesNode, A::Error>
where
A: de::MapAccess<'de>,
{
let v = match map.next_key::<UnionField_<Variant_>>()? {
Some(UnionField_::Type) => {
let variant = map.next_value()?;
let key = map.next_key()?;
match (variant, key) {
(Variant_::Constant, Some(Variant_::Constant)) => {
let value = map.next_value()?;
NumericSeriesNode::Constant(value)
}
(Variant_::Arithmetic, Some(Variant_::Arithmetic)) => {
let value = map.next_value()?;
NumericSeriesNode::Arithmetic(value)
}
(Variant_::BitOperation, Some(Variant_::BitOperation)) => {
let value = map.next_value()?;
NumericSeriesNode::BitOperation(value)
}
(Variant_::CountDuplicate, Some(Variant_::CountDuplicate)) => {
let value = map.next_value()?;
NumericSeriesNode::CountDuplicate(value)
}
(Variant_::CumulativeSum, Some(Variant_::CumulativeSum)) => {
let value = map.next_value()?;
NumericSeriesNode::CumulativeSum(value)
}
(Variant_::Derivative, Some(Variant_::Derivative)) => {
let value = map.next_value()?;
NumericSeriesNode::Derivative(value)
}
(Variant_::Integral, Some(Variant_::Integral)) => {
let value = map.next_value()?;
NumericSeriesNode::Integral(value)
}
(Variant_::Max, Some(Variant_::Max)) => {
let value = map.next_value()?;
NumericSeriesNode::Max(value)
}
(Variant_::Mean, Some(Variant_::Mean)) => {
let value = map.next_value()?;
NumericSeriesNode::Mean(value)
}
(Variant_::Min, Some(Variant_::Min)) => {
let value = map.next_value()?;
NumericSeriesNode::Min(value)
}
(Variant_::Offset, Some(Variant_::Offset)) => {
let value = map.next_value()?;
NumericSeriesNode::Offset(value)
}
(Variant_::Product, Some(Variant_::Product)) => {
let value = map.next_value()?;
NumericSeriesNode::Product(value)
}
(Variant_::OldestPoints, Some(Variant_::OldestPoints)) => {
let value = map.next_value()?;
NumericSeriesNode::OldestPoints(value)
}
(Variant_::Raw, Some(Variant_::Raw)) => {
let value = map.next_value()?;
NumericSeriesNode::Raw(value)
}
(Variant_::Resample, Some(Variant_::Resample)) => {
let value = map.next_value()?;
NumericSeriesNode::Resample(value)
}
(Variant_::RollingOperation, Some(Variant_::RollingOperation)) => {
let value = map.next_value()?;
NumericSeriesNode::RollingOperation(value)
}
(Variant_::Aggregate, Some(Variant_::Aggregate)) => {
let value = map.next_value()?;
NumericSeriesNode::Aggregate(value)
}
(Variant_::SignalFilter, Some(Variant_::SignalFilter)) => {
let value = map.next_value()?;
NumericSeriesNode::SignalFilter(value)
}
(Variant_::Sum, Some(Variant_::Sum)) => {
let value = map.next_value()?;
NumericSeriesNode::Sum(value)
}
(Variant_::Scale, Some(Variant_::Scale)) => {
let value = map.next_value()?;
NumericSeriesNode::Scale(value)
}
(Variant_::TimeDifference, Some(Variant_::TimeDifference)) => {
let value = map.next_value()?;
NumericSeriesNode::TimeDifference(value)
}
(Variant_::TimeRangeFilter, Some(Variant_::TimeRangeFilter)) => {
let value = map.next_value()?;
NumericSeriesNode::TimeRangeFilter(value)
}
(Variant_::Union, Some(Variant_::Union)) => {
let value = map.next_value()?;
NumericSeriesNode::Union(value)
}
(Variant_::UnitConversion, Some(Variant_::UnitConversion)) => {
let value = map.next_value()?;
NumericSeriesNode::UnitConversion(value)
}
(Variant_::ValueDifference, Some(Variant_::ValueDifference)) => {
let value = map.next_value()?;
NumericSeriesNode::ValueDifference(value)
}
(
Variant_::FilterTransformation,
Some(Variant_::FilterTransformation),
) => {
let value = map.next_value()?;
NumericSeriesNode::FilterTransformation(value)
}
(Variant_::ThresholdFilter, Some(Variant_::ThresholdFilter)) => {
let value = map.next_value()?;
NumericSeriesNode::ThresholdFilter(value)
}
(Variant_::DropNan, Some(Variant_::DropNan)) => {
let value = map.next_value()?;
NumericSeriesNode::DropNan(value)
}
(Variant_::ArraySelect, Some(Variant_::ArraySelect)) => {
let value = map.next_value()?;
NumericSeriesNode::ArraySelect(value)
}
(Variant_::AbsoluteTimestamp, Some(Variant_::AbsoluteTimestamp)) => {
let value = map.next_value()?;
NumericSeriesNode::AbsoluteTimestamp(value)
}
(Variant_::NewestPoints, Some(Variant_::NewestPoints)) => {
let value = map.next_value()?;
NumericSeriesNode::NewestPoints(value)
}
(
Variant_::RangesNumericAggregationToNumeric,
Some(Variant_::RangesNumericAggregationToNumeric),
) => {
let value = map.next_value()?;
NumericSeriesNode::RangesNumericAggregationToNumeric(value)
}
(
Variant_::FilterByExpression,
Some(Variant_::FilterByExpression),
) => {
let value = map.next_value()?;
NumericSeriesNode::FilterByExpression(value)
}
(Variant_::ScalarUdf, Some(Variant_::ScalarUdf)) => {
let value = map.next_value()?;
NumericSeriesNode::ScalarUdf(value)
}
(Variant_::EnumToNumeric, Some(Variant_::EnumToNumeric)) => {
let value = map.next_value()?;
NumericSeriesNode::EnumToNumeric(value)
}
(Variant_::Refprop, Some(Variant_::Refprop)) => {
let value = map.next_value()?;
NumericSeriesNode::Refprop(value)
}
(Variant_::ExtractFromStruct, Some(Variant_::ExtractFromStruct)) => {
let value = map.next_value()?;
NumericSeriesNode::ExtractFromStruct(value)
}
(Variant_::ZScore, Some(Variant_::ZScore)) => {
let value = map.next_value()?;
NumericSeriesNode::ZScore(value)
}
(Variant_::TagByIntervals, Some(Variant_::TagByIntervals)) => {
let value = map.next_value()?;
NumericSeriesNode::TagByIntervals(value)
}
(Variant_::GenericTransform, Some(Variant_::GenericTransform)) => {
let value = map.next_value()?;
NumericSeriesNode::GenericTransform(value)
}
(Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
if type_ == b {
let value = map.next_value()?;
NumericSeriesNode::Unknown(Unknown { type_, value })
} else {
return Err(
de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
)
}
}
(variant, Some(key)) => {
return Err(
de::Error::invalid_value(
de::Unexpected::Str(key.as_str()),
&variant.as_str(),
),
);
}
(variant, None) => {
return Err(de::Error::missing_field(variant.as_str()));
}
}
}
Some(UnionField_::Value(variant)) => {
let value = match &variant {
Variant_::Constant => {
let value = map.next_value()?;
NumericSeriesNode::Constant(value)
}
Variant_::Arithmetic => {
let value = map.next_value()?;
NumericSeriesNode::Arithmetic(value)
}
Variant_::BitOperation => {
let value = map.next_value()?;
NumericSeriesNode::BitOperation(value)
}
Variant_::CountDuplicate => {
let value = map.next_value()?;
NumericSeriesNode::CountDuplicate(value)
}
Variant_::CumulativeSum => {
let value = map.next_value()?;
NumericSeriesNode::CumulativeSum(value)
}
Variant_::Derivative => {
let value = map.next_value()?;
NumericSeriesNode::Derivative(value)
}
Variant_::Integral => {
let value = map.next_value()?;
NumericSeriesNode::Integral(value)
}
Variant_::Max => {
let value = map.next_value()?;
NumericSeriesNode::Max(value)
}
Variant_::Mean => {
let value = map.next_value()?;
NumericSeriesNode::Mean(value)
}
Variant_::Min => {
let value = map.next_value()?;
NumericSeriesNode::Min(value)
}
Variant_::Offset => {
let value = map.next_value()?;
NumericSeriesNode::Offset(value)
}
Variant_::Product => {
let value = map.next_value()?;
NumericSeriesNode::Product(value)
}
Variant_::OldestPoints => {
let value = map.next_value()?;
NumericSeriesNode::OldestPoints(value)
}
Variant_::Raw => {
let value = map.next_value()?;
NumericSeriesNode::Raw(value)
}
Variant_::Resample => {
let value = map.next_value()?;
NumericSeriesNode::Resample(value)
}
Variant_::RollingOperation => {
let value = map.next_value()?;
NumericSeriesNode::RollingOperation(value)
}
Variant_::Aggregate => {
let value = map.next_value()?;
NumericSeriesNode::Aggregate(value)
}
Variant_::SignalFilter => {
let value = map.next_value()?;
NumericSeriesNode::SignalFilter(value)
}
Variant_::Sum => {
let value = map.next_value()?;
NumericSeriesNode::Sum(value)
}
Variant_::Scale => {
let value = map.next_value()?;
NumericSeriesNode::Scale(value)
}
Variant_::TimeDifference => {
let value = map.next_value()?;
NumericSeriesNode::TimeDifference(value)
}
Variant_::TimeRangeFilter => {
let value = map.next_value()?;
NumericSeriesNode::TimeRangeFilter(value)
}
Variant_::Union => {
let value = map.next_value()?;
NumericSeriesNode::Union(value)
}
Variant_::UnitConversion => {
let value = map.next_value()?;
NumericSeriesNode::UnitConversion(value)
}
Variant_::ValueDifference => {
let value = map.next_value()?;
NumericSeriesNode::ValueDifference(value)
}
Variant_::FilterTransformation => {
let value = map.next_value()?;
NumericSeriesNode::FilterTransformation(value)
}
Variant_::ThresholdFilter => {
let value = map.next_value()?;
NumericSeriesNode::ThresholdFilter(value)
}
Variant_::DropNan => {
let value = map.next_value()?;
NumericSeriesNode::DropNan(value)
}
Variant_::ArraySelect => {
let value = map.next_value()?;
NumericSeriesNode::ArraySelect(value)
}
Variant_::AbsoluteTimestamp => {
let value = map.next_value()?;
NumericSeriesNode::AbsoluteTimestamp(value)
}
Variant_::NewestPoints => {
let value = map.next_value()?;
NumericSeriesNode::NewestPoints(value)
}
Variant_::RangesNumericAggregationToNumeric => {
let value = map.next_value()?;
NumericSeriesNode::RangesNumericAggregationToNumeric(value)
}
Variant_::FilterByExpression => {
let value = map.next_value()?;
NumericSeriesNode::FilterByExpression(value)
}
Variant_::ScalarUdf => {
let value = map.next_value()?;
NumericSeriesNode::ScalarUdf(value)
}
Variant_::EnumToNumeric => {
let value = map.next_value()?;
NumericSeriesNode::EnumToNumeric(value)
}
Variant_::Refprop => {
let value = map.next_value()?;
NumericSeriesNode::Refprop(value)
}
Variant_::ExtractFromStruct => {
let value = map.next_value()?;
NumericSeriesNode::ExtractFromStruct(value)
}
Variant_::ZScore => {
let value = map.next_value()?;
NumericSeriesNode::ZScore(value)
}
Variant_::TagByIntervals => {
let value = map.next_value()?;
NumericSeriesNode::TagByIntervals(value)
}
Variant_::GenericTransform => {
let value = map.next_value()?;
NumericSeriesNode::GenericTransform(value)
}
Variant_::Unknown(type_) => {
let value = map.next_value()?;
NumericSeriesNode::Unknown(Unknown {
type_: type_.clone(),
value,
})
}
};
if map.next_key::<UnionTypeField_>()?.is_none() {
return Err(de::Error::missing_field("type"));
}
let type_variant = map.next_value::<Variant_>()?;
if variant != type_variant {
return Err(
de::Error::invalid_value(
de::Unexpected::Str(type_variant.as_str()),
&variant.as_str(),
),
);
}
value
}
None => return Err(de::Error::missing_field("type")),
};
if map.next_key::<UnionField_<Variant_>>()?.is_some() {
return Err(de::Error::invalid_length(3, &"type and value fields"));
}
Ok(v)
}
}
#[derive(PartialEq)]
enum Variant_ {
Constant,
Arithmetic,
BitOperation,
CountDuplicate,
CumulativeSum,
Derivative,
Integral,
Max,
Mean,
Min,
Offset,
Product,
OldestPoints,
Raw,
Resample,
RollingOperation,
Aggregate,
SignalFilter,
Sum,
Scale,
TimeDifference,
TimeRangeFilter,
Union,
UnitConversion,
ValueDifference,
FilterTransformation,
ThresholdFilter,
DropNan,
ArraySelect,
AbsoluteTimestamp,
NewestPoints,
RangesNumericAggregationToNumeric,
FilterByExpression,
ScalarUdf,
EnumToNumeric,
Refprop,
ExtractFromStruct,
ZScore,
TagByIntervals,
GenericTransform,
Unknown(Box<str>),
}
impl Variant_ {
fn as_str(&self) -> &'static str {
match *self {
Variant_::Constant => "constant",
Variant_::Arithmetic => "arithmetic",
Variant_::BitOperation => "bitOperation",
Variant_::CountDuplicate => "countDuplicate",
Variant_::CumulativeSum => "cumulativeSum",
Variant_::Derivative => "derivative",
Variant_::Integral => "integral",
Variant_::Max => "max",
Variant_::Mean => "mean",
Variant_::Min => "min",
Variant_::Offset => "offset",
Variant_::Product => "product",
Variant_::OldestPoints => "oldestPoints",
Variant_::Raw => "raw",
Variant_::Resample => "resample",
Variant_::RollingOperation => "rollingOperation",
Variant_::Aggregate => "aggregate",
Variant_::SignalFilter => "signalFilter",
Variant_::Sum => "sum",
Variant_::Scale => "scale",
Variant_::TimeDifference => "timeDifference",
Variant_::TimeRangeFilter => "timeRangeFilter",
Variant_::Union => "union",
Variant_::UnitConversion => "unitConversion",
Variant_::ValueDifference => "valueDifference",
Variant_::FilterTransformation => "filterTransformation",
Variant_::ThresholdFilter => "thresholdFilter",
Variant_::DropNan => "dropNan",
Variant_::ArraySelect => "arraySelect",
Variant_::AbsoluteTimestamp => "absoluteTimestamp",
Variant_::NewestPoints => "newestPoints",
Variant_::RangesNumericAggregationToNumeric => {
"rangesNumericAggregationToNumeric"
}
Variant_::FilterByExpression => "filterByExpression",
Variant_::ScalarUdf => "scalarUdf",
Variant_::EnumToNumeric => "enumToNumeric",
Variant_::Refprop => "refprop",
Variant_::ExtractFromStruct => "extractFromStruct",
Variant_::ZScore => "zScore",
Variant_::TagByIntervals => "tagByIntervals",
Variant_::GenericTransform => "genericTransform",
Variant_::Unknown(_) => "unknown variant",
}
}
}
impl<'de> de::Deserialize<'de> for Variant_ {
fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
where
D: de::Deserializer<'de>,
{
d.deserialize_str(VariantVisitor_)
}
}
struct VariantVisitor_;
impl<'de> de::Visitor<'de> for VariantVisitor_ {
type Value = Variant_;
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str("string")
}
fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
where
E: de::Error,
{
let v = match value {
"constant" => Variant_::Constant,
"arithmetic" => Variant_::Arithmetic,
"bitOperation" => Variant_::BitOperation,
"countDuplicate" => Variant_::CountDuplicate,
"cumulativeSum" => Variant_::CumulativeSum,
"derivative" => Variant_::Derivative,
"integral" => Variant_::Integral,
"max" => Variant_::Max,
"mean" => Variant_::Mean,
"min" => Variant_::Min,
"offset" => Variant_::Offset,
"product" => Variant_::Product,
"oldestPoints" => Variant_::OldestPoints,
"raw" => Variant_::Raw,
"resample" => Variant_::Resample,
"rollingOperation" => Variant_::RollingOperation,
"aggregate" => Variant_::Aggregate,
"signalFilter" => Variant_::SignalFilter,
"sum" => Variant_::Sum,
"scale" => Variant_::Scale,
"timeDifference" => Variant_::TimeDifference,
"timeRangeFilter" => Variant_::TimeRangeFilter,
"union" => Variant_::Union,
"unitConversion" => Variant_::UnitConversion,
"valueDifference" => Variant_::ValueDifference,
"filterTransformation" => Variant_::FilterTransformation,
"thresholdFilter" => Variant_::ThresholdFilter,
"dropNan" => Variant_::DropNan,
"arraySelect" => Variant_::ArraySelect,
"absoluteTimestamp" => Variant_::AbsoluteTimestamp,
"newestPoints" => Variant_::NewestPoints,
"rangesNumericAggregationToNumeric" => {
Variant_::RangesNumericAggregationToNumeric
}
"filterByExpression" => Variant_::FilterByExpression,
"scalarUdf" => Variant_::ScalarUdf,
"enumToNumeric" => Variant_::EnumToNumeric,
"refprop" => Variant_::Refprop,
"extractFromStruct" => Variant_::ExtractFromStruct,
"zScore" => Variant_::ZScore,
"tagByIntervals" => Variant_::TagByIntervals,
"genericTransform" => Variant_::GenericTransform,
value => Variant_::Unknown(value.to_string().into_boxed_str()),
};
Ok(v)
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Unknown {
type_: Box<str>,
value: conjure_object::Any,
}
impl Unknown {
#[inline]
pub fn type_(&self) -> &str {
&self.type_
}
}