Skip to main content

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

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