Skip to main content

nominal_api/conjure/objects/scout/channelvariables/api/
compute_node_with_context.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 ComputeNodeWithContext {
13    #[builder(
14        custom(type = super::super::super::compute::api::ComputeNode, convert = Box::new)
15    )]
16    #[serde(rename = "computeNode")]
17    compute_node: Box<super::super::super::compute::api::ComputeNode>,
18    #[builder(custom(type = super::WorkbookContext, convert = Box::new))]
19    #[serde(rename = "context")]
20    context: Box<super::WorkbookContext>,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::ChannelVariableComputeExpression>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(
30        rename = "computeExpression",
31        skip_serializing_if = "Option::is_none",
32        default
33    )]
34    compute_expression: Option<Box<super::ChannelVariableComputeExpression>>,
35}
36impl ComputeNodeWithContext {
37    /// Constructs a new instance of the type.
38    #[inline]
39    pub fn new(
40        compute_node: super::super::super::compute::api::ComputeNode,
41        context: super::WorkbookContext,
42    ) -> Self {
43        Self::builder().compute_node(compute_node).context(context).build()
44    }
45    /// Graph representation of the compute for a channel variable.
46    #[inline]
47    pub fn compute_node(&self) -> &super::super::super::compute::api::ComputeNode {
48        &*self.compute_node
49    }
50    #[inline]
51    pub fn context(&self) -> &super::WorkbookContext {
52        &*self.context
53    }
54    /// Code representation of the compute for a channel variable. Should be equivalent to the computeNode.
55    #[inline]
56    pub fn compute_expression(
57        &self,
58    ) -> Option<&super::ChannelVariableComputeExpression> {
59        self.compute_expression.as_ref().map(|o| &**o)
60    }
61}