Skip to main content

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

1/// A user-defined numeric aggregation. The aggregation builder controls grouping/windowing.
2/// Supported Rust entrypoints accept grouped value vectors, optionally with leading sample timestamps,
3/// and return either one numeric value or timestamped numeric point(s), e.g.
4/// `fn rms(values: Vec<f64>) -> f64`,
5/// `fn energy(timestamp_ns: Vec<i64>, values: Vec<f64>) -> f64`,
6/// `fn first(timestamp_ns: Vec<i64>, values: Vec<f64>) -> (i64, f64)`, or
7/// `fn passthrough(timestamp_ns: Vec<i64>, values: Vec<f64>) -> Vec<(i64, f64)>`.
8#[derive(
9    Debug,
10    Clone,
11    conjure_object::serde::Serialize,
12    conjure_object::serde::Deserialize,
13    PartialEq,
14    Eq,
15    PartialOrd,
16    Ord,
17    Hash
18)]
19#[serde(crate = "conjure_object::serde")]
20#[conjure_object::private::staged_builder::staged_builder]
21#[builder(crate = conjure_object::private::staged_builder, update, inline)]
22pub struct NumericAggregationUdf {
23    #[builder(custom(type = super::UdfSource, convert = Box::new))]
24    #[serde(rename = "source")]
25    source: Box<super::UdfSource>,
26}
27impl NumericAggregationUdf {
28    /// Constructs a new instance of the type.
29    #[inline]
30    pub fn new(source: super::UdfSource) -> Self {
31        Self::builder().source(source).build()
32    }
33    #[inline]
34    pub fn source(&self) -> &super::UdfSource {
35        &*self.source
36    }
37}