Skip to main content

nominal_api/conjure/objects/datasource/api/
channel_metadata.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct ChannelMetadata {
16    #[builder(into)]
17    #[serde(rename = "name")]
18    name: String,
19    #[serde(rename = "dataSource")]
20    data_source: conjure_object::ResourceIdentifier,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::super::super::scout::run::api::Unit>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(rename = "unit", skip_serializing_if = "Option::is_none", default)]
30    unit: Option<Box<super::super::super::scout::run::api::Unit>>,
31    #[builder(default, into)]
32    #[serde(rename = "description", skip_serializing_if = "Option::is_none", default)]
33    description: Option<String>,
34    #[builder(default, into)]
35    #[serde(rename = "dataType", skip_serializing_if = "Option::is_none", default)]
36    data_type: Option<super::super::super::api::SeriesDataType>,
37    #[builder(
38        custom(type = super::SeriesMetadataRidOrLogicalSeriesRid, convert = Box::new)
39    )]
40    #[serde(rename = "seriesRid")]
41    series_rid: Box<super::SeriesMetadataRidOrLogicalSeriesRid>,
42}
43impl ChannelMetadata {
44    /// Constructs a new instance of the type.
45    #[inline]
46    pub fn new(
47        name: impl Into<String>,
48        data_source: conjure_object::ResourceIdentifier,
49        series_rid: super::SeriesMetadataRidOrLogicalSeriesRid,
50    ) -> Self {
51        Self::builder()
52            .name(name)
53            .data_source(data_source)
54            .series_rid(series_rid)
55            .build()
56    }
57    #[inline]
58    pub fn name(&self) -> &str {
59        &*self.name
60    }
61    #[inline]
62    pub fn data_source(&self) -> &conjure_object::ResourceIdentifier {
63        &self.data_source
64    }
65    #[inline]
66    pub fn unit(&self) -> Option<&super::super::super::scout::run::api::Unit> {
67        self.unit.as_ref().map(|o| &**o)
68    }
69    #[inline]
70    pub fn description(&self) -> Option<&str> {
71        self.description.as_ref().map(|o| &**o)
72    }
73    #[inline]
74    pub fn data_type(&self) -> Option<&super::super::super::api::SeriesDataType> {
75        self.data_type.as_ref().map(|o| &*o)
76    }
77    #[inline]
78    pub fn series_rid(&self) -> &super::SeriesMetadataRidOrLogicalSeriesRid {
79        &*self.series_rid
80    }
81}