Skip to main content

nominal_api/conjure/objects/persistent/compute/api/
append_result.rs

1/// An append result won't cover the full `StreamingComputeNodeRequest#windowWidth` but rather just a smaller
2/// window. The end of the window that the append covers is guaranteed to be later than previously sent results.
3/// The start, however, can and most likely will overlap with previous results. That allows us to support
4/// out-of-order points. The client will have to merge this new `AppendResult` with previous results.
5/// Example of time windows that might be covered by results for a subscription:
6/// We send a full result for window [0s, 120s] followed by an append result for [116s, 121s] and another
7/// append result for [117s, 122s].
8#[derive(
9    Debug,
10    Clone,
11    conjure_object::serde::Serialize,
12    conjure_object::serde::Deserialize,
13    conjure_object::private::DeriveWith
14)]
15#[serde(crate = "conjure_object::serde")]
16#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
17#[conjure_object::private::staged_builder::staged_builder]
18#[builder(crate = conjure_object::private::staged_builder, update, inline)]
19pub struct AppendResult {
20    #[builder(
21        custom(type = super::super::super::super::api::Timestamp, convert = Box::new)
22    )]
23    #[serde(rename = "start")]
24    start: Box<super::super::super::super::api::Timestamp>,
25    #[builder(
26        custom(type = super::super::super::super::api::Timestamp, convert = Box::new)
27    )]
28    #[serde(rename = "end")]
29    end: Box<super::super::super::super::api::Timestamp>,
30    #[builder(custom(type = super::ComputeNodeAppendResponse, convert = Box::new))]
31    #[serde(rename = "result")]
32    result: Box<super::ComputeNodeAppendResponse>,
33}
34impl AppendResult {
35    /// Constructs a new instance of the type.
36    #[inline]
37    pub fn new(
38        start: super::super::super::super::api::Timestamp,
39        end: super::super::super::super::api::Timestamp,
40        result: super::ComputeNodeAppendResponse,
41    ) -> Self {
42        Self::builder().start(start).end(end).result(result).build()
43    }
44    /// The start of the time range that the append result covers
45    #[inline]
46    pub fn start(&self) -> &super::super::super::super::api::Timestamp {
47        &*self.start
48    }
49    /// The end of the time range that the append result covers
50    #[inline]
51    pub fn end(&self) -> &super::super::super::super::api::Timestamp {
52        &*self.end
53    }
54    #[inline]
55    pub fn result(&self) -> &super::ComputeNodeAppendResponse {
56        &*self.result
57    }
58}