Skip to main content

nominal_api/conjure/objects/storage/writer/api/
column_batch.rs

1/// Batch of data to stream for a single channel with their associated timestamps.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct ColumnBatch {
14    #[builder(into)]
15    #[serde(rename = "channel")]
16    channel: String,
17    #[builder(default, map(key(type = String, into), value(type = String, into)))]
18    #[serde(
19        rename = "tags",
20        skip_serializing_if = "std::collections::BTreeMap::is_empty",
21        default
22    )]
23    tags: std::collections::BTreeMap<String, String>,
24    #[builder(default, list(item(type = super::super::super::super::api::Timestamp)))]
25    #[serde(rename = "timestamps", skip_serializing_if = "Vec::is_empty", default)]
26    timestamps: Vec<super::super::super::super::api::Timestamp>,
27    #[builder(custom(type = super::ColumnValues, convert = Box::new))]
28    #[serde(rename = "values")]
29    values: Box<super::ColumnValues>,
30}
31impl ColumnBatch {
32    /// Constructs a new instance of the type.
33    #[inline]
34    pub fn new(channel: impl Into<String>, values: super::ColumnValues) -> Self {
35        Self::builder().channel(channel).values(values).build()
36    }
37    /// Channel within nominal to stream data to.
38    #[inline]
39    pub fn channel(&self) -> &str {
40        &*self.channel
41    }
42    /// Mapping of key-value pairs to provide as tags to all points within the batch
43    #[inline]
44    pub fn tags(&self) -> &std::collections::BTreeMap<String, String> {
45        &self.tags
46    }
47    /// List of timestamp values that correspond to the provided list of column values. The number of timestamps
48    /// provided MUST match the number of columnar values provided, otherwise a 400 error will be returned.
49    #[inline]
50    pub fn timestamps(&self) -> &[super::super::super::super::api::Timestamp] {
51        &*self.timestamps
52    }
53    /// List of time series values that should be ingested to a single channel. The number of columnar values
54    /// provided MUST match the number of timestamps provided, otherwise a 400 error will be returned.
55    #[inline]
56    pub fn values(&self) -> &super::ColumnValues {
57        &*self.values
58    }
59}