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