1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// Converts a boolean series to a range series, where each contiguous run of true values becomes a
/// half-open range [start, end). The boolean series is treated as forward-filled: a value holds until the
/// next sample. For example, given timestamps [0, 1, 2, 3, 4] and values [true, true, true, false, false],
/// the result is a single range [0, 3). When openEnded is false and the series ends with true, the last
/// range is closed at the final timestamp, producing a zero-duration range (moment) for isolated true values.
#[derive(
Debug,
Clone,
conjure_object::serde::Serialize,
conjure_object::serde::Deserialize,
conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct BooleanToRanges {
#[builder(custom(type = super::BooleanSeries, convert = Box::new))]
#[serde(rename = "input")]
input: Box<super::BooleanSeries>,
#[builder(default, into)]
#[serde(rename = "openEnded", skip_serializing_if = "Option::is_none", default)]
open_ended: Option<bool>,
}
impl BooleanToRanges {
/// Constructs a new instance of the type.
#[inline]
pub fn new(input: super::BooleanSeries) -> Self {
Self::builder().input(input).build()
}
#[inline]
pub fn input(&self) -> &super::BooleanSeries {
&*self.input
}
/// If true, the last range will be open-ended if the last value is true. Defaults to true.
/// Set to false to close trailing ranges at the last timestamp, which produces zero-duration
/// ranges (moments) for isolated trailing true values.
#[inline]
pub fn open_ended(&self) -> Option<bool> {
self.open_ended.as_ref().map(|o| *o)
}
}