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