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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// Aligns each anchored portion of the input dataset onto a common anchor timestamp while preserving grouping
/// tags. Without a `reference` the selected anchor becomes timestamp zero, so the output is in a relative time
/// domain; with a `reference` the anchors are aligned onto the referenced portion's anchor and the output stays
/// in the input's absolute time domain. Currently run boundary and event anchors are supported, and every
/// storage-backed leaf of the input must resolve to run-backed branches.
#[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 AnchorAlignedDataset {
#[builder(custom(type = super::Dataset, convert = Box::new))]
#[serde(rename = "input")]
input: Box<super::Dataset>,
#[builder(custom(type = super::DatasetAnchor, convert = Box::new))]
#[serde(rename = "anchor")]
anchor: Box<super::DatasetAnchor>,
#[builder(
default,
custom(
type = impl
Into<Option<super::AnchorReference>>,
convert = |v|v.into().map(Box::new)
)
)]
#[serde(rename = "reference", skip_serializing_if = "Option::is_none", default)]
reference: Option<Box<super::AnchorReference>>,
}
impl AnchorAlignedDataset {
/// Constructs a new instance of the type.
#[inline]
pub fn new(input: super::Dataset, anchor: super::DatasetAnchor) -> Self {
Self::builder().input(input).anchor(anchor).build()
}
/// The dataset to align.
#[inline]
pub fn input(&self) -> &super::Dataset {
&*self.input
}
/// Selects the timestamp each anchored portion of the input is aligned by.
#[inline]
pub fn anchor(&self) -> &super::DatasetAnchor {
&*self.anchor
}
/// When present, each anchor is aligned onto the referenced anchor timestamp instead of onto timestamp
/// zero, so output remains in the input's absolute time domain and the referenced portion is unshifted.
/// When absent, the selected anchor becomes timestamp zero.
#[inline]
pub fn reference(&self) -> Option<&super::AnchorReference> {
self.reference.as_ref().map(|o| &**o)
}
}