Skip to main content

nominal_api/conjure/objects/scout/comparisonnotebook/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::ComparisonWorkbookContext, convert = Box::new))]
19    #[serde(rename = "context")]
20    context: Box<super::ComparisonWorkbookContext>,
21    #[builder(
22        custom(type = super::SupplementalComparisonWorkbookContext, convert = Box::new)
23    )]
24    #[serde(rename = "supplementalContext")]
25    supplemental_context: Box<super::SupplementalComparisonWorkbookContext>,
26    #[builder(
27        default,
28        custom(
29            type = impl
30            Into<Option<super::super::super::channelvariables::api::ChannelVariableComputeExpression>>,
31            convert = |v|v.into().map(Box::new)
32        )
33    )]
34    #[serde(
35        rename = "computeExpression",
36        skip_serializing_if = "Option::is_none",
37        default
38    )]
39    compute_expression: Option<
40        Box<super::super::super::channelvariables::api::ChannelVariableComputeExpression>,
41    >,
42}
43impl ComputeNodeWithContext {
44    /// Constructs a new instance of the type.
45    #[inline]
46    pub fn new(
47        compute_node: super::super::super::compute::api::ComputeNode,
48        context: super::ComparisonWorkbookContext,
49        supplemental_context: super::SupplementalComparisonWorkbookContext,
50    ) -> Self {
51        Self::builder()
52            .compute_node(compute_node)
53            .context(context)
54            .supplemental_context(supplemental_context)
55            .build()
56    }
57    /// Graph representation of the compute for a variable.
58    #[inline]
59    pub fn compute_node(&self) -> &super::super::super::compute::api::ComputeNode {
60        &*self.compute_node
61    }
62    #[inline]
63    pub fn context(&self) -> &super::ComparisonWorkbookContext {
64        &*self.context
65    }
66    #[deprecated(note = "migrated into visualization definitions.")]
67    #[inline]
68    pub fn supplemental_context(&self) -> &super::SupplementalComparisonWorkbookContext {
69        &*self.supplemental_context
70    }
71    /// Code representation of the compute for a variable. Should be equivalent to the computeNode.
72    #[inline]
73    pub fn compute_expression(
74        &self,
75    ) -> Option<
76        &super::super::super::channelvariables::api::ChannelVariableComputeExpression,
77    > {
78        self.compute_expression.as_ref().map(|o| &**o)
79    }
80}