Skip to main content

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

1/// Configures how long a condition has to be true for to output a time range, and what to use as the
2/// start of the output range. For a point to be included in the output time range, both the minPoints and
3/// minDuration conditions must be satisfied.
4#[derive(
5    Debug,
6    Clone,
7    conjure_object::serde::Serialize,
8    conjure_object::serde::Deserialize,
9    PartialEq,
10    Eq,
11    PartialOrd,
12    Ord,
13    Hash
14)]
15#[serde(crate = "conjure_object::serde")]
16#[conjure_object::private::staged_builder::staged_builder]
17#[builder(crate = conjure_object::private::staged_builder, update, inline)]
18pub struct PersistenceWindowConfiguration {
19    #[builder(
20        default,
21        custom(
22            type = impl
23            Into<Option<super::IntegerConstant>>,
24            convert = |v|v.into().map(Box::new)
25        )
26    )]
27    #[serde(rename = "minPoints", skip_serializing_if = "Option::is_none", default)]
28    min_points: Option<Box<super::IntegerConstant>>,
29    #[builder(
30        default,
31        custom(
32            type = impl
33            Into<Option<super::DurationConstant>>,
34            convert = |v|v.into().map(Box::new)
35        )
36    )]
37    #[serde(rename = "minDuration", skip_serializing_if = "Option::is_none", default)]
38    min_duration: Option<Box<super::DurationConstant>>,
39    #[builder(custom(type = super::OutputRangeStart, convert = Box::new))]
40    #[serde(rename = "outputRangeStart")]
41    output_range_start: Box<super::OutputRangeStart>,
42}
43impl PersistenceWindowConfiguration {
44    /// Constructs a new instance of the type.
45    #[inline]
46    pub fn new(output_range_start: super::OutputRangeStart) -> Self {
47        Self::builder().output_range_start(output_range_start).build()
48    }
49    /// The minimum number of points for which this condition be must satisfied to include the time range in the
50    /// output. Must be non-negative. If not present, will default to 1.
51    #[inline]
52    pub fn min_points(&self) -> Option<&super::IntegerConstant> {
53        self.min_points.as_ref().map(|o| &**o)
54    }
55    /// The minimum number of points for which this condition must be satisfied to include the time range in the
56    /// output. Must be non-negative. If not present, will default to 1 nanosecond.
57    #[inline]
58    pub fn min_duration(&self) -> Option<&super::DurationConstant> {
59        self.min_duration.as_ref().map(|o| &**o)
60    }
61    /// Which point to use as the start of the output range. Defaults to firstPointMatchingCondition if not specified.
62    #[inline]
63    pub fn output_range_start(&self) -> &super::OutputRangeStart {
64        &*self.output_range_start
65    }
66}