Skip to main content

nominal_api_conjure/conjure/objects/scout/compute/api/
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 Context {
13    #[builder(
14        default,
15        map(key(type = super::VariableName), value(type = super::VariableValue))
16    )]
17    #[serde(
18        rename = "variables",
19        skip_serializing_if = "std::collections::BTreeMap::is_empty",
20        default
21    )]
22    variables: std::collections::BTreeMap<super::VariableName, super::VariableValue>,
23    #[builder(default, into)]
24    #[serde(
25        rename = "functionVariables",
26        skip_serializing_if = "Option::is_none",
27        default
28    )]
29    function_variables: Option<
30        std::collections::BTreeMap<super::FunctionReference, super::FunctionVariables>,
31    >,
32    #[builder(
33        default,
34        map(key(type = super::DatasetReferenceName), value(type = super::Dataset))
35    )]
36    #[serde(
37        rename = "datasetReferences",
38        skip_serializing_if = "std::collections::BTreeMap::is_empty",
39        default
40    )]
41    dataset_references: std::collections::BTreeMap<
42        super::DatasetReferenceName,
43        super::Dataset,
44    >,
45    #[builder(
46        default,
47        custom(
48            type = impl
49            Into<Option<super::FillStrategy>>,
50            convert = |v|v.into().map(Box::new)
51        )
52    )]
53    #[serde(
54        rename = "defaultFillStrategy",
55        skip_serializing_if = "Option::is_none",
56        default
57    )]
58    default_fill_strategy: Option<Box<super::FillStrategy>>,
59    #[builder(
60        default,
61        custom(
62            type = impl
63            Into<Option<super::Alignment>>,
64            convert = |v|v.into().map(Box::new)
65        )
66    )]
67    #[serde(
68        rename = "defaultAlignmentStrategy",
69        skip_serializing_if = "Option::is_none",
70        default
71    )]
72    default_alignment_strategy: Option<Box<super::Alignment>>,
73    #[builder(default, into)]
74    #[serde(
75        rename = "applyDataScopeOffsets",
76        skip_serializing_if = "Option::is_none",
77        default
78    )]
79    apply_data_scope_offsets: Option<bool>,
80}
81impl Context {
82    /// Constructs a new instance of the type.
83    #[inline]
84    pub fn new() -> Self {
85        Self::builder().build()
86    }
87    #[inline]
88    pub fn variables(
89        &self,
90    ) -> &std::collections::BTreeMap<super::VariableName, super::VariableValue> {
91        &self.variables
92    }
93    #[deprecated(
94        note = "This field is deprecated and will be removed in a future version.\n"
95    )]
96    #[inline]
97    pub fn function_variables(
98        &self,
99    ) -> Option<
100        &std::collections::BTreeMap<super::FunctionReference, super::FunctionVariables>,
101    > {
102        self.function_variables.as_ref().map(|o| &*o)
103    }
104    /// Named datasets looked up by `DatasetReference` nodes in the compute tree.
105    #[inline]
106    pub fn dataset_references(
107        &self,
108    ) -> &std::collections::BTreeMap<super::DatasetReferenceName, super::Dataset> {
109        &self.dataset_references
110    }
111    /// Default fill strategy applied at every multi-input alignment boundary
112    /// where no per-node interpolationConfiguration is specified. When absent, falls back
113    /// to the server-configured default (forward fill with a 1 second fill limit).
114    #[inline]
115    pub fn default_fill_strategy(&self) -> Option<&super::FillStrategy> {
116        self.default_fill_strategy.as_ref().map(|o| &**o)
117    }
118    /// Default alignment strategy applied at every multi-input alignment boundary
119    /// where no per-node alignment strategy is specified. When absent, falls back
120    /// to the server default (driver-series alignment).
121    #[inline]
122    pub fn default_alignment_strategy(&self) -> Option<&super::Alignment> {
123        self.default_alignment_strategy.as_ref().map(|o| &**o)
124    }
125    /// When true, dataset resolution applies each data scope's persisted offset as a time
126    /// shift, and the client must not pre-apply those offsets itself. When absent or false,
127    /// scope offsets are left to the client, preserving behavior for legacy clients that
128    /// inject equivalent timeShift nodes into the compute request. Read from the context in
129    /// scope at resolution time.
130    #[inline]
131    pub fn apply_data_scope_offsets(&self) -> Option<bool> {
132        self.apply_data_scope_offsets.as_ref().map(|o| *o)
133    }
134}