Skip to main content

nominal_api/conjure/objects/scout/compute/resolved/api/
numeric_series_node.rs

1use conjure_object::serde::{ser, de};
2use conjure_object::serde::ser::SerializeMap as SerializeMap_;
3use conjure_object::private::{UnionField_, UnionTypeField_};
4use std::fmt;
5#[derive(Debug, Clone, conjure_object::private::DeriveWith)]
6#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum NumericSeriesNode {
8    Constant(super::ConstantNumericSeriesNode),
9    Arithmetic(super::ArithmeticSeriesNode),
10    BitOperation(super::BitOperationSeriesNode),
11    CountDuplicate(super::EnumCountDuplicateSeriesNode),
12    CumulativeSum(super::CumulativeSumSeriesNode),
13    Derivative(super::DerivativeSeriesNode),
14    Integral(super::IntegralSeriesNode),
15    Max(super::MaxSeriesNode),
16    Mean(super::MeanSeriesNode),
17    Min(super::MinSeriesNode),
18    Offset(super::OffsetSeriesNode),
19    Product(super::ProductSeriesNode),
20    OldestPoints(super::SelectOldestPointsSeriesNode),
21    Raw(super::RawNumericSeriesNode),
22    Resample(super::NumericResampleSeriesNode),
23    NthPointDownsample(super::NumericNthPointDownsampleSeriesNode),
24    RollingOperation(super::RollingOperationSeriesNode),
25    RollingPointOperation(super::RollingPointOperationSeriesNode),
26    Aggregate(super::AggregateNumericSeriesNode),
27    SignalFilter(super::SignalFilterSeriesNode),
28    Sum(super::SumSeriesNode),
29    Scale(super::ScaleSeriesNode),
30    TimeDifference(super::TimeDifferenceSeriesNode),
31    TimeRangeFilter(super::NumericTimeRangeFilterSeriesNode),
32    Union(super::NumericUnionSeriesNode),
33    UnitConversion(super::UnitConversionSeriesNode),
34    ValueDifference(super::ValueDifferenceSeriesNode),
35    FilterTransformation(super::NumericFilterTransformationSeriesNode),
36    ThresholdFilter(super::NumericThresholdFilterSeriesNode),
37    DropNan(super::NumericNanFilterNode),
38    ArraySelect(super::SelectIndexFromNumericArraySeriesNode),
39    AbsoluteTimestamp(super::AbsoluteTimestampSeriesNode),
40    NewestPoints(super::SelectNewestPointsSeriesNode),
41    RangesNumericAggregationToNumeric(
42        super::RangesNumericAggregationToNumericSeriesNode,
43    ),
44    FilterByExpression(super::FilterByExpressionSeriesNode),
45    ScalarUdf(super::ScalarUdfSeriesNode),
46    EnumToNumeric(super::EnumToNumericSeriesNode),
47    Refprop(super::RefpropSeriesNode),
48    ExtractFromStruct(super::ExtractNumericFromStructSeriesNode),
49    ZScore(super::ZscoreSeriesNode),
50    TagByIntervals(super::TagByIntervalsSeriesNode),
51    GenericTransform(Box<super::GenericTransformNode>),
52    /// An unknown variant.
53    Unknown(Unknown),
54}
55impl ser::Serialize for NumericSeriesNode {
56    fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
57    where
58        S: ser::Serializer,
59    {
60        let mut map = s.serialize_map(Some(2))?;
61        match self {
62            NumericSeriesNode::Constant(value) => {
63                map.serialize_entry(&"type", &"constant")?;
64                map.serialize_entry(&"constant", value)?;
65            }
66            NumericSeriesNode::Arithmetic(value) => {
67                map.serialize_entry(&"type", &"arithmetic")?;
68                map.serialize_entry(&"arithmetic", value)?;
69            }
70            NumericSeriesNode::BitOperation(value) => {
71                map.serialize_entry(&"type", &"bitOperation")?;
72                map.serialize_entry(&"bitOperation", value)?;
73            }
74            NumericSeriesNode::CountDuplicate(value) => {
75                map.serialize_entry(&"type", &"countDuplicate")?;
76                map.serialize_entry(&"countDuplicate", value)?;
77            }
78            NumericSeriesNode::CumulativeSum(value) => {
79                map.serialize_entry(&"type", &"cumulativeSum")?;
80                map.serialize_entry(&"cumulativeSum", value)?;
81            }
82            NumericSeriesNode::Derivative(value) => {
83                map.serialize_entry(&"type", &"derivative")?;
84                map.serialize_entry(&"derivative", value)?;
85            }
86            NumericSeriesNode::Integral(value) => {
87                map.serialize_entry(&"type", &"integral")?;
88                map.serialize_entry(&"integral", value)?;
89            }
90            NumericSeriesNode::Max(value) => {
91                map.serialize_entry(&"type", &"max")?;
92                map.serialize_entry(&"max", value)?;
93            }
94            NumericSeriesNode::Mean(value) => {
95                map.serialize_entry(&"type", &"mean")?;
96                map.serialize_entry(&"mean", value)?;
97            }
98            NumericSeriesNode::Min(value) => {
99                map.serialize_entry(&"type", &"min")?;
100                map.serialize_entry(&"min", value)?;
101            }
102            NumericSeriesNode::Offset(value) => {
103                map.serialize_entry(&"type", &"offset")?;
104                map.serialize_entry(&"offset", value)?;
105            }
106            NumericSeriesNode::Product(value) => {
107                map.serialize_entry(&"type", &"product")?;
108                map.serialize_entry(&"product", value)?;
109            }
110            NumericSeriesNode::OldestPoints(value) => {
111                map.serialize_entry(&"type", &"oldestPoints")?;
112                map.serialize_entry(&"oldestPoints", value)?;
113            }
114            NumericSeriesNode::Raw(value) => {
115                map.serialize_entry(&"type", &"raw")?;
116                map.serialize_entry(&"raw", value)?;
117            }
118            NumericSeriesNode::Resample(value) => {
119                map.serialize_entry(&"type", &"resample")?;
120                map.serialize_entry(&"resample", value)?;
121            }
122            NumericSeriesNode::NthPointDownsample(value) => {
123                map.serialize_entry(&"type", &"nthPointDownsample")?;
124                map.serialize_entry(&"nthPointDownsample", value)?;
125            }
126            NumericSeriesNode::RollingOperation(value) => {
127                map.serialize_entry(&"type", &"rollingOperation")?;
128                map.serialize_entry(&"rollingOperation", value)?;
129            }
130            NumericSeriesNode::RollingPointOperation(value) => {
131                map.serialize_entry(&"type", &"rollingPointOperation")?;
132                map.serialize_entry(&"rollingPointOperation", value)?;
133            }
134            NumericSeriesNode::Aggregate(value) => {
135                map.serialize_entry(&"type", &"aggregate")?;
136                map.serialize_entry(&"aggregate", value)?;
137            }
138            NumericSeriesNode::SignalFilter(value) => {
139                map.serialize_entry(&"type", &"signalFilter")?;
140                map.serialize_entry(&"signalFilter", value)?;
141            }
142            NumericSeriesNode::Sum(value) => {
143                map.serialize_entry(&"type", &"sum")?;
144                map.serialize_entry(&"sum", value)?;
145            }
146            NumericSeriesNode::Scale(value) => {
147                map.serialize_entry(&"type", &"scale")?;
148                map.serialize_entry(&"scale", value)?;
149            }
150            NumericSeriesNode::TimeDifference(value) => {
151                map.serialize_entry(&"type", &"timeDifference")?;
152                map.serialize_entry(&"timeDifference", value)?;
153            }
154            NumericSeriesNode::TimeRangeFilter(value) => {
155                map.serialize_entry(&"type", &"timeRangeFilter")?;
156                map.serialize_entry(&"timeRangeFilter", value)?;
157            }
158            NumericSeriesNode::Union(value) => {
159                map.serialize_entry(&"type", &"union")?;
160                map.serialize_entry(&"union", value)?;
161            }
162            NumericSeriesNode::UnitConversion(value) => {
163                map.serialize_entry(&"type", &"unitConversion")?;
164                map.serialize_entry(&"unitConversion", value)?;
165            }
166            NumericSeriesNode::ValueDifference(value) => {
167                map.serialize_entry(&"type", &"valueDifference")?;
168                map.serialize_entry(&"valueDifference", value)?;
169            }
170            NumericSeriesNode::FilterTransformation(value) => {
171                map.serialize_entry(&"type", &"filterTransformation")?;
172                map.serialize_entry(&"filterTransformation", value)?;
173            }
174            NumericSeriesNode::ThresholdFilter(value) => {
175                map.serialize_entry(&"type", &"thresholdFilter")?;
176                map.serialize_entry(&"thresholdFilter", value)?;
177            }
178            NumericSeriesNode::DropNan(value) => {
179                map.serialize_entry(&"type", &"dropNan")?;
180                map.serialize_entry(&"dropNan", value)?;
181            }
182            NumericSeriesNode::ArraySelect(value) => {
183                map.serialize_entry(&"type", &"arraySelect")?;
184                map.serialize_entry(&"arraySelect", value)?;
185            }
186            NumericSeriesNode::AbsoluteTimestamp(value) => {
187                map.serialize_entry(&"type", &"absoluteTimestamp")?;
188                map.serialize_entry(&"absoluteTimestamp", value)?;
189            }
190            NumericSeriesNode::NewestPoints(value) => {
191                map.serialize_entry(&"type", &"newestPoints")?;
192                map.serialize_entry(&"newestPoints", value)?;
193            }
194            NumericSeriesNode::RangesNumericAggregationToNumeric(value) => {
195                map.serialize_entry(&"type", &"rangesNumericAggregationToNumeric")?;
196                map.serialize_entry(&"rangesNumericAggregationToNumeric", value)?;
197            }
198            NumericSeriesNode::FilterByExpression(value) => {
199                map.serialize_entry(&"type", &"filterByExpression")?;
200                map.serialize_entry(&"filterByExpression", value)?;
201            }
202            NumericSeriesNode::ScalarUdf(value) => {
203                map.serialize_entry(&"type", &"scalarUdf")?;
204                map.serialize_entry(&"scalarUdf", value)?;
205            }
206            NumericSeriesNode::EnumToNumeric(value) => {
207                map.serialize_entry(&"type", &"enumToNumeric")?;
208                map.serialize_entry(&"enumToNumeric", value)?;
209            }
210            NumericSeriesNode::Refprop(value) => {
211                map.serialize_entry(&"type", &"refprop")?;
212                map.serialize_entry(&"refprop", value)?;
213            }
214            NumericSeriesNode::ExtractFromStruct(value) => {
215                map.serialize_entry(&"type", &"extractFromStruct")?;
216                map.serialize_entry(&"extractFromStruct", value)?;
217            }
218            NumericSeriesNode::ZScore(value) => {
219                map.serialize_entry(&"type", &"zScore")?;
220                map.serialize_entry(&"zScore", value)?;
221            }
222            NumericSeriesNode::TagByIntervals(value) => {
223                map.serialize_entry(&"type", &"tagByIntervals")?;
224                map.serialize_entry(&"tagByIntervals", value)?;
225            }
226            NumericSeriesNode::GenericTransform(value) => {
227                map.serialize_entry(&"type", &"genericTransform")?;
228                map.serialize_entry(&"genericTransform", value)?;
229            }
230            NumericSeriesNode::Unknown(value) => {
231                map.serialize_entry(&"type", &value.type_)?;
232                map.serialize_entry(&value.type_, &value.value)?;
233            }
234        }
235        map.end()
236    }
237}
238impl<'de> de::Deserialize<'de> for NumericSeriesNode {
239    fn deserialize<D>(d: D) -> Result<NumericSeriesNode, D::Error>
240    where
241        D: de::Deserializer<'de>,
242    {
243        d.deserialize_map(Visitor_)
244    }
245}
246struct Visitor_;
247impl<'de> de::Visitor<'de> for Visitor_ {
248    type Value = NumericSeriesNode;
249    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
250        fmt.write_str("union NumericSeriesNode")
251    }
252    fn visit_map<A>(self, mut map: A) -> Result<NumericSeriesNode, A::Error>
253    where
254        A: de::MapAccess<'de>,
255    {
256        let v = match map.next_key::<UnionField_<Variant_>>()? {
257            Some(UnionField_::Type) => {
258                let variant = map.next_value()?;
259                let key = map.next_key()?;
260                match (variant, key) {
261                    (Variant_::Constant, Some(Variant_::Constant)) => {
262                        let value = map.next_value()?;
263                        NumericSeriesNode::Constant(value)
264                    }
265                    (Variant_::Arithmetic, Some(Variant_::Arithmetic)) => {
266                        let value = map.next_value()?;
267                        NumericSeriesNode::Arithmetic(value)
268                    }
269                    (Variant_::BitOperation, Some(Variant_::BitOperation)) => {
270                        let value = map.next_value()?;
271                        NumericSeriesNode::BitOperation(value)
272                    }
273                    (Variant_::CountDuplicate, Some(Variant_::CountDuplicate)) => {
274                        let value = map.next_value()?;
275                        NumericSeriesNode::CountDuplicate(value)
276                    }
277                    (Variant_::CumulativeSum, Some(Variant_::CumulativeSum)) => {
278                        let value = map.next_value()?;
279                        NumericSeriesNode::CumulativeSum(value)
280                    }
281                    (Variant_::Derivative, Some(Variant_::Derivative)) => {
282                        let value = map.next_value()?;
283                        NumericSeriesNode::Derivative(value)
284                    }
285                    (Variant_::Integral, Some(Variant_::Integral)) => {
286                        let value = map.next_value()?;
287                        NumericSeriesNode::Integral(value)
288                    }
289                    (Variant_::Max, Some(Variant_::Max)) => {
290                        let value = map.next_value()?;
291                        NumericSeriesNode::Max(value)
292                    }
293                    (Variant_::Mean, Some(Variant_::Mean)) => {
294                        let value = map.next_value()?;
295                        NumericSeriesNode::Mean(value)
296                    }
297                    (Variant_::Min, Some(Variant_::Min)) => {
298                        let value = map.next_value()?;
299                        NumericSeriesNode::Min(value)
300                    }
301                    (Variant_::Offset, Some(Variant_::Offset)) => {
302                        let value = map.next_value()?;
303                        NumericSeriesNode::Offset(value)
304                    }
305                    (Variant_::Product, Some(Variant_::Product)) => {
306                        let value = map.next_value()?;
307                        NumericSeriesNode::Product(value)
308                    }
309                    (Variant_::OldestPoints, Some(Variant_::OldestPoints)) => {
310                        let value = map.next_value()?;
311                        NumericSeriesNode::OldestPoints(value)
312                    }
313                    (Variant_::Raw, Some(Variant_::Raw)) => {
314                        let value = map.next_value()?;
315                        NumericSeriesNode::Raw(value)
316                    }
317                    (Variant_::Resample, Some(Variant_::Resample)) => {
318                        let value = map.next_value()?;
319                        NumericSeriesNode::Resample(value)
320                    }
321                    (
322                        Variant_::NthPointDownsample,
323                        Some(Variant_::NthPointDownsample),
324                    ) => {
325                        let value = map.next_value()?;
326                        NumericSeriesNode::NthPointDownsample(value)
327                    }
328                    (Variant_::RollingOperation, Some(Variant_::RollingOperation)) => {
329                        let value = map.next_value()?;
330                        NumericSeriesNode::RollingOperation(value)
331                    }
332                    (
333                        Variant_::RollingPointOperation,
334                        Some(Variant_::RollingPointOperation),
335                    ) => {
336                        let value = map.next_value()?;
337                        NumericSeriesNode::RollingPointOperation(value)
338                    }
339                    (Variant_::Aggregate, Some(Variant_::Aggregate)) => {
340                        let value = map.next_value()?;
341                        NumericSeriesNode::Aggregate(value)
342                    }
343                    (Variant_::SignalFilter, Some(Variant_::SignalFilter)) => {
344                        let value = map.next_value()?;
345                        NumericSeriesNode::SignalFilter(value)
346                    }
347                    (Variant_::Sum, Some(Variant_::Sum)) => {
348                        let value = map.next_value()?;
349                        NumericSeriesNode::Sum(value)
350                    }
351                    (Variant_::Scale, Some(Variant_::Scale)) => {
352                        let value = map.next_value()?;
353                        NumericSeriesNode::Scale(value)
354                    }
355                    (Variant_::TimeDifference, Some(Variant_::TimeDifference)) => {
356                        let value = map.next_value()?;
357                        NumericSeriesNode::TimeDifference(value)
358                    }
359                    (Variant_::TimeRangeFilter, Some(Variant_::TimeRangeFilter)) => {
360                        let value = map.next_value()?;
361                        NumericSeriesNode::TimeRangeFilter(value)
362                    }
363                    (Variant_::Union, Some(Variant_::Union)) => {
364                        let value = map.next_value()?;
365                        NumericSeriesNode::Union(value)
366                    }
367                    (Variant_::UnitConversion, Some(Variant_::UnitConversion)) => {
368                        let value = map.next_value()?;
369                        NumericSeriesNode::UnitConversion(value)
370                    }
371                    (Variant_::ValueDifference, Some(Variant_::ValueDifference)) => {
372                        let value = map.next_value()?;
373                        NumericSeriesNode::ValueDifference(value)
374                    }
375                    (
376                        Variant_::FilterTransformation,
377                        Some(Variant_::FilterTransformation),
378                    ) => {
379                        let value = map.next_value()?;
380                        NumericSeriesNode::FilterTransformation(value)
381                    }
382                    (Variant_::ThresholdFilter, Some(Variant_::ThresholdFilter)) => {
383                        let value = map.next_value()?;
384                        NumericSeriesNode::ThresholdFilter(value)
385                    }
386                    (Variant_::DropNan, Some(Variant_::DropNan)) => {
387                        let value = map.next_value()?;
388                        NumericSeriesNode::DropNan(value)
389                    }
390                    (Variant_::ArraySelect, Some(Variant_::ArraySelect)) => {
391                        let value = map.next_value()?;
392                        NumericSeriesNode::ArraySelect(value)
393                    }
394                    (Variant_::AbsoluteTimestamp, Some(Variant_::AbsoluteTimestamp)) => {
395                        let value = map.next_value()?;
396                        NumericSeriesNode::AbsoluteTimestamp(value)
397                    }
398                    (Variant_::NewestPoints, Some(Variant_::NewestPoints)) => {
399                        let value = map.next_value()?;
400                        NumericSeriesNode::NewestPoints(value)
401                    }
402                    (
403                        Variant_::RangesNumericAggregationToNumeric,
404                        Some(Variant_::RangesNumericAggregationToNumeric),
405                    ) => {
406                        let value = map.next_value()?;
407                        NumericSeriesNode::RangesNumericAggregationToNumeric(value)
408                    }
409                    (
410                        Variant_::FilterByExpression,
411                        Some(Variant_::FilterByExpression),
412                    ) => {
413                        let value = map.next_value()?;
414                        NumericSeriesNode::FilterByExpression(value)
415                    }
416                    (Variant_::ScalarUdf, Some(Variant_::ScalarUdf)) => {
417                        let value = map.next_value()?;
418                        NumericSeriesNode::ScalarUdf(value)
419                    }
420                    (Variant_::EnumToNumeric, Some(Variant_::EnumToNumeric)) => {
421                        let value = map.next_value()?;
422                        NumericSeriesNode::EnumToNumeric(value)
423                    }
424                    (Variant_::Refprop, Some(Variant_::Refprop)) => {
425                        let value = map.next_value()?;
426                        NumericSeriesNode::Refprop(value)
427                    }
428                    (Variant_::ExtractFromStruct, Some(Variant_::ExtractFromStruct)) => {
429                        let value = map.next_value()?;
430                        NumericSeriesNode::ExtractFromStruct(value)
431                    }
432                    (Variant_::ZScore, Some(Variant_::ZScore)) => {
433                        let value = map.next_value()?;
434                        NumericSeriesNode::ZScore(value)
435                    }
436                    (Variant_::TagByIntervals, Some(Variant_::TagByIntervals)) => {
437                        let value = map.next_value()?;
438                        NumericSeriesNode::TagByIntervals(value)
439                    }
440                    (Variant_::GenericTransform, Some(Variant_::GenericTransform)) => {
441                        let value = map.next_value()?;
442                        NumericSeriesNode::GenericTransform(value)
443                    }
444                    (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
445                        if type_ == b {
446                            let value = map.next_value()?;
447                            NumericSeriesNode::Unknown(Unknown { type_, value })
448                        } else {
449                            return Err(
450                                de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
451                            )
452                        }
453                    }
454                    (variant, Some(key)) => {
455                        return Err(
456                            de::Error::invalid_value(
457                                de::Unexpected::Str(key.as_str()),
458                                &variant.as_str(),
459                            ),
460                        );
461                    }
462                    (variant, None) => {
463                        return Err(de::Error::missing_field(variant.as_str()));
464                    }
465                }
466            }
467            Some(UnionField_::Value(variant)) => {
468                let value = match &variant {
469                    Variant_::Constant => {
470                        let value = map.next_value()?;
471                        NumericSeriesNode::Constant(value)
472                    }
473                    Variant_::Arithmetic => {
474                        let value = map.next_value()?;
475                        NumericSeriesNode::Arithmetic(value)
476                    }
477                    Variant_::BitOperation => {
478                        let value = map.next_value()?;
479                        NumericSeriesNode::BitOperation(value)
480                    }
481                    Variant_::CountDuplicate => {
482                        let value = map.next_value()?;
483                        NumericSeriesNode::CountDuplicate(value)
484                    }
485                    Variant_::CumulativeSum => {
486                        let value = map.next_value()?;
487                        NumericSeriesNode::CumulativeSum(value)
488                    }
489                    Variant_::Derivative => {
490                        let value = map.next_value()?;
491                        NumericSeriesNode::Derivative(value)
492                    }
493                    Variant_::Integral => {
494                        let value = map.next_value()?;
495                        NumericSeriesNode::Integral(value)
496                    }
497                    Variant_::Max => {
498                        let value = map.next_value()?;
499                        NumericSeriesNode::Max(value)
500                    }
501                    Variant_::Mean => {
502                        let value = map.next_value()?;
503                        NumericSeriesNode::Mean(value)
504                    }
505                    Variant_::Min => {
506                        let value = map.next_value()?;
507                        NumericSeriesNode::Min(value)
508                    }
509                    Variant_::Offset => {
510                        let value = map.next_value()?;
511                        NumericSeriesNode::Offset(value)
512                    }
513                    Variant_::Product => {
514                        let value = map.next_value()?;
515                        NumericSeriesNode::Product(value)
516                    }
517                    Variant_::OldestPoints => {
518                        let value = map.next_value()?;
519                        NumericSeriesNode::OldestPoints(value)
520                    }
521                    Variant_::Raw => {
522                        let value = map.next_value()?;
523                        NumericSeriesNode::Raw(value)
524                    }
525                    Variant_::Resample => {
526                        let value = map.next_value()?;
527                        NumericSeriesNode::Resample(value)
528                    }
529                    Variant_::NthPointDownsample => {
530                        let value = map.next_value()?;
531                        NumericSeriesNode::NthPointDownsample(value)
532                    }
533                    Variant_::RollingOperation => {
534                        let value = map.next_value()?;
535                        NumericSeriesNode::RollingOperation(value)
536                    }
537                    Variant_::RollingPointOperation => {
538                        let value = map.next_value()?;
539                        NumericSeriesNode::RollingPointOperation(value)
540                    }
541                    Variant_::Aggregate => {
542                        let value = map.next_value()?;
543                        NumericSeriesNode::Aggregate(value)
544                    }
545                    Variant_::SignalFilter => {
546                        let value = map.next_value()?;
547                        NumericSeriesNode::SignalFilter(value)
548                    }
549                    Variant_::Sum => {
550                        let value = map.next_value()?;
551                        NumericSeriesNode::Sum(value)
552                    }
553                    Variant_::Scale => {
554                        let value = map.next_value()?;
555                        NumericSeriesNode::Scale(value)
556                    }
557                    Variant_::TimeDifference => {
558                        let value = map.next_value()?;
559                        NumericSeriesNode::TimeDifference(value)
560                    }
561                    Variant_::TimeRangeFilter => {
562                        let value = map.next_value()?;
563                        NumericSeriesNode::TimeRangeFilter(value)
564                    }
565                    Variant_::Union => {
566                        let value = map.next_value()?;
567                        NumericSeriesNode::Union(value)
568                    }
569                    Variant_::UnitConversion => {
570                        let value = map.next_value()?;
571                        NumericSeriesNode::UnitConversion(value)
572                    }
573                    Variant_::ValueDifference => {
574                        let value = map.next_value()?;
575                        NumericSeriesNode::ValueDifference(value)
576                    }
577                    Variant_::FilterTransformation => {
578                        let value = map.next_value()?;
579                        NumericSeriesNode::FilterTransformation(value)
580                    }
581                    Variant_::ThresholdFilter => {
582                        let value = map.next_value()?;
583                        NumericSeriesNode::ThresholdFilter(value)
584                    }
585                    Variant_::DropNan => {
586                        let value = map.next_value()?;
587                        NumericSeriesNode::DropNan(value)
588                    }
589                    Variant_::ArraySelect => {
590                        let value = map.next_value()?;
591                        NumericSeriesNode::ArraySelect(value)
592                    }
593                    Variant_::AbsoluteTimestamp => {
594                        let value = map.next_value()?;
595                        NumericSeriesNode::AbsoluteTimestamp(value)
596                    }
597                    Variant_::NewestPoints => {
598                        let value = map.next_value()?;
599                        NumericSeriesNode::NewestPoints(value)
600                    }
601                    Variant_::RangesNumericAggregationToNumeric => {
602                        let value = map.next_value()?;
603                        NumericSeriesNode::RangesNumericAggregationToNumeric(value)
604                    }
605                    Variant_::FilterByExpression => {
606                        let value = map.next_value()?;
607                        NumericSeriesNode::FilterByExpression(value)
608                    }
609                    Variant_::ScalarUdf => {
610                        let value = map.next_value()?;
611                        NumericSeriesNode::ScalarUdf(value)
612                    }
613                    Variant_::EnumToNumeric => {
614                        let value = map.next_value()?;
615                        NumericSeriesNode::EnumToNumeric(value)
616                    }
617                    Variant_::Refprop => {
618                        let value = map.next_value()?;
619                        NumericSeriesNode::Refprop(value)
620                    }
621                    Variant_::ExtractFromStruct => {
622                        let value = map.next_value()?;
623                        NumericSeriesNode::ExtractFromStruct(value)
624                    }
625                    Variant_::ZScore => {
626                        let value = map.next_value()?;
627                        NumericSeriesNode::ZScore(value)
628                    }
629                    Variant_::TagByIntervals => {
630                        let value = map.next_value()?;
631                        NumericSeriesNode::TagByIntervals(value)
632                    }
633                    Variant_::GenericTransform => {
634                        let value = map.next_value()?;
635                        NumericSeriesNode::GenericTransform(value)
636                    }
637                    Variant_::Unknown(type_) => {
638                        let value = map.next_value()?;
639                        NumericSeriesNode::Unknown(Unknown {
640                            type_: type_.clone(),
641                            value,
642                        })
643                    }
644                };
645                if map.next_key::<UnionTypeField_>()?.is_none() {
646                    return Err(de::Error::missing_field("type"));
647                }
648                let type_variant = map.next_value::<Variant_>()?;
649                if variant != type_variant {
650                    return Err(
651                        de::Error::invalid_value(
652                            de::Unexpected::Str(type_variant.as_str()),
653                            &variant.as_str(),
654                        ),
655                    );
656                }
657                value
658            }
659            None => return Err(de::Error::missing_field("type")),
660        };
661        if map.next_key::<UnionField_<Variant_>>()?.is_some() {
662            return Err(de::Error::invalid_length(3, &"type and value fields"));
663        }
664        Ok(v)
665    }
666}
667#[derive(PartialEq)]
668enum Variant_ {
669    Constant,
670    Arithmetic,
671    BitOperation,
672    CountDuplicate,
673    CumulativeSum,
674    Derivative,
675    Integral,
676    Max,
677    Mean,
678    Min,
679    Offset,
680    Product,
681    OldestPoints,
682    Raw,
683    Resample,
684    NthPointDownsample,
685    RollingOperation,
686    RollingPointOperation,
687    Aggregate,
688    SignalFilter,
689    Sum,
690    Scale,
691    TimeDifference,
692    TimeRangeFilter,
693    Union,
694    UnitConversion,
695    ValueDifference,
696    FilterTransformation,
697    ThresholdFilter,
698    DropNan,
699    ArraySelect,
700    AbsoluteTimestamp,
701    NewestPoints,
702    RangesNumericAggregationToNumeric,
703    FilterByExpression,
704    ScalarUdf,
705    EnumToNumeric,
706    Refprop,
707    ExtractFromStruct,
708    ZScore,
709    TagByIntervals,
710    GenericTransform,
711    Unknown(Box<str>),
712}
713impl Variant_ {
714    fn as_str(&self) -> &'static str {
715        match *self {
716            Variant_::Constant => "constant",
717            Variant_::Arithmetic => "arithmetic",
718            Variant_::BitOperation => "bitOperation",
719            Variant_::CountDuplicate => "countDuplicate",
720            Variant_::CumulativeSum => "cumulativeSum",
721            Variant_::Derivative => "derivative",
722            Variant_::Integral => "integral",
723            Variant_::Max => "max",
724            Variant_::Mean => "mean",
725            Variant_::Min => "min",
726            Variant_::Offset => "offset",
727            Variant_::Product => "product",
728            Variant_::OldestPoints => "oldestPoints",
729            Variant_::Raw => "raw",
730            Variant_::Resample => "resample",
731            Variant_::NthPointDownsample => "nthPointDownsample",
732            Variant_::RollingOperation => "rollingOperation",
733            Variant_::RollingPointOperation => "rollingPointOperation",
734            Variant_::Aggregate => "aggregate",
735            Variant_::SignalFilter => "signalFilter",
736            Variant_::Sum => "sum",
737            Variant_::Scale => "scale",
738            Variant_::TimeDifference => "timeDifference",
739            Variant_::TimeRangeFilter => "timeRangeFilter",
740            Variant_::Union => "union",
741            Variant_::UnitConversion => "unitConversion",
742            Variant_::ValueDifference => "valueDifference",
743            Variant_::FilterTransformation => "filterTransformation",
744            Variant_::ThresholdFilter => "thresholdFilter",
745            Variant_::DropNan => "dropNan",
746            Variant_::ArraySelect => "arraySelect",
747            Variant_::AbsoluteTimestamp => "absoluteTimestamp",
748            Variant_::NewestPoints => "newestPoints",
749            Variant_::RangesNumericAggregationToNumeric => {
750                "rangesNumericAggregationToNumeric"
751            }
752            Variant_::FilterByExpression => "filterByExpression",
753            Variant_::ScalarUdf => "scalarUdf",
754            Variant_::EnumToNumeric => "enumToNumeric",
755            Variant_::Refprop => "refprop",
756            Variant_::ExtractFromStruct => "extractFromStruct",
757            Variant_::ZScore => "zScore",
758            Variant_::TagByIntervals => "tagByIntervals",
759            Variant_::GenericTransform => "genericTransform",
760            Variant_::Unknown(_) => "unknown variant",
761        }
762    }
763}
764impl<'de> de::Deserialize<'de> for Variant_ {
765    fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
766    where
767        D: de::Deserializer<'de>,
768    {
769        d.deserialize_str(VariantVisitor_)
770    }
771}
772struct VariantVisitor_;
773impl<'de> de::Visitor<'de> for VariantVisitor_ {
774    type Value = Variant_;
775    fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
776        fmt.write_str("string")
777    }
778    fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
779    where
780        E: de::Error,
781    {
782        let v = match value {
783            "constant" => Variant_::Constant,
784            "arithmetic" => Variant_::Arithmetic,
785            "bitOperation" => Variant_::BitOperation,
786            "countDuplicate" => Variant_::CountDuplicate,
787            "cumulativeSum" => Variant_::CumulativeSum,
788            "derivative" => Variant_::Derivative,
789            "integral" => Variant_::Integral,
790            "max" => Variant_::Max,
791            "mean" => Variant_::Mean,
792            "min" => Variant_::Min,
793            "offset" => Variant_::Offset,
794            "product" => Variant_::Product,
795            "oldestPoints" => Variant_::OldestPoints,
796            "raw" => Variant_::Raw,
797            "resample" => Variant_::Resample,
798            "nthPointDownsample" => Variant_::NthPointDownsample,
799            "rollingOperation" => Variant_::RollingOperation,
800            "rollingPointOperation" => Variant_::RollingPointOperation,
801            "aggregate" => Variant_::Aggregate,
802            "signalFilter" => Variant_::SignalFilter,
803            "sum" => Variant_::Sum,
804            "scale" => Variant_::Scale,
805            "timeDifference" => Variant_::TimeDifference,
806            "timeRangeFilter" => Variant_::TimeRangeFilter,
807            "union" => Variant_::Union,
808            "unitConversion" => Variant_::UnitConversion,
809            "valueDifference" => Variant_::ValueDifference,
810            "filterTransformation" => Variant_::FilterTransformation,
811            "thresholdFilter" => Variant_::ThresholdFilter,
812            "dropNan" => Variant_::DropNan,
813            "arraySelect" => Variant_::ArraySelect,
814            "absoluteTimestamp" => Variant_::AbsoluteTimestamp,
815            "newestPoints" => Variant_::NewestPoints,
816            "rangesNumericAggregationToNumeric" => {
817                Variant_::RangesNumericAggregationToNumeric
818            }
819            "filterByExpression" => Variant_::FilterByExpression,
820            "scalarUdf" => Variant_::ScalarUdf,
821            "enumToNumeric" => Variant_::EnumToNumeric,
822            "refprop" => Variant_::Refprop,
823            "extractFromStruct" => Variant_::ExtractFromStruct,
824            "zScore" => Variant_::ZScore,
825            "tagByIntervals" => Variant_::TagByIntervals,
826            "genericTransform" => Variant_::GenericTransform,
827            value => Variant_::Unknown(value.to_string().into_boxed_str()),
828        };
829        Ok(v)
830    }
831}
832///An unknown variant of the NumericSeriesNode union.
833#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
834pub struct Unknown {
835    type_: Box<str>,
836    value: conjure_object::Any,
837}
838impl Unknown {
839    /// Returns the unknown variant's type name.
840    #[inline]
841    pub fn type_(&self) -> &str {
842        &self.type_
843    }
844}