Skip to main content

nominal_api_conjure/conjure/objects/scout/compute/api/
threshold_ranges_v2.rs

1/// Produces ranges where a numeric input satisfies a threshold comparison.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct ThresholdRangesV2 {
14    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
15    #[serde(rename = "input")]
16    input: Box<super::NumericSeries>,
17    #[builder(
18        default,
19        custom(
20            type = impl
21            Into<Option<super::IntegerConstant>>,
22            convert = |v|v.into().map(Box::new)
23        )
24    )]
25    #[serde(rename = "minPoints", skip_serializing_if = "Option::is_none", default)]
26    min_points: Option<Box<super::IntegerConstant>>,
27    #[builder(
28        default,
29        custom(
30            type = impl
31            Into<Option<super::Duration>>,
32            convert = |v|v.into().map(Box::new)
33        )
34    )]
35    #[serde(rename = "minDuration", skip_serializing_if = "Option::is_none", default)]
36    min_duration: Option<Box<super::Duration>>,
37    #[builder(default, into)]
38    #[serde(rename = "rangeStart", skip_serializing_if = "Option::is_none", default)]
39    range_start: Option<super::RangeStart>,
40    #[builder(custom(type = super::ThresholdRangesComparison, convert = Box::new))]
41    #[serde(rename = "comparison")]
42    comparison: Box<super::ThresholdRangesComparison>,
43}
44impl ThresholdRangesV2 {
45    /// Constructs a new instance of the type.
46    #[inline]
47    pub fn new(
48        input: super::NumericSeries,
49        comparison: super::ThresholdRangesComparison,
50    ) -> Self {
51        Self::builder().input(input).comparison(comparison).build()
52    }
53    #[inline]
54    pub fn input(&self) -> &super::NumericSeries {
55        &*self.input
56    }
57    /// Minimum number of matching points. Defaults to 1.
58    #[inline]
59    pub fn min_points(&self) -> Option<&super::IntegerConstant> {
60        self.min_points.as_ref().map(|o| &**o)
61    }
62    /// Minimum matching duration. Defaults to one nanosecond.
63    #[inline]
64    pub fn min_duration(&self) -> Option<&super::Duration> {
65        self.min_duration.as_ref().map(|o| &**o)
66    }
67    /// Selects whether the output begins at the first match or after persistence is satisfied.
68    #[inline]
69    pub fn range_start(&self) -> Option<&super::RangeStart> {
70        self.range_start.as_ref().map(|o| &*o)
71    }
72    #[inline]
73    pub fn comparison(&self) -> &super::ThresholdRangesComparison {
74        &*self.comparison
75    }
76}