Skip to main content

nominal_api/conjure/objects/scout/channelvariables/api/
channel_variable.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct ChannelVariable {
13    #[builder(default, into)]
14    #[serde(rename = "displayName", skip_serializing_if = "Option::is_none", default)]
15    display_name: Option<String>,
16    #[serde(rename = "variableName")]
17    variable_name: super::ChannelVariableName,
18    #[builder(custom(type = super::ComputeSpec, convert = Box::new))]
19    #[serde(rename = "computeSpec")]
20    compute_spec: Box<super::ComputeSpec>,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::ComputeNodeWithContext>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(rename = "computeSpecV2", skip_serializing_if = "Option::is_none", default)]
30    compute_spec_v2: Option<Box<super::ComputeNodeWithContext>>,
31}
32impl ChannelVariable {
33    /// Constructs a new instance of the type.
34    #[inline]
35    pub fn new(
36        variable_name: super::ChannelVariableName,
37        compute_spec: super::ComputeSpec,
38    ) -> Self {
39        Self::builder().variable_name(variable_name).compute_spec(compute_spec).build()
40    }
41    #[inline]
42    pub fn display_name(&self) -> Option<&str> {
43        self.display_name.as_ref().map(|o| &**o)
44    }
45    #[inline]
46    pub fn variable_name(&self) -> &super::ChannelVariableName {
47        &self.variable_name
48    }
49    #[inline]
50    pub fn compute_spec(&self) -> &super::ComputeSpec {
51        &*self.compute_spec
52    }
53    /// optional for backcompatibility. If empty, fall back to computeSpec.
54    #[inline]
55    pub fn compute_spec_v2(&self) -> Option<&super::ComputeNodeWithContext> {
56        self.compute_spec_v2.as_ref().map(|o| &**o)
57    }
58}