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    #[builder(default, into)]
81    #[serde(
82        rename = "resolveAssetsThroughDatasets",
83        skip_serializing_if = "Option::is_none",
84        default
85    )]
86    resolve_assets_through_datasets: Option<bool>,
87}
88impl Context {
89    /// Constructs a new instance of the type.
90    #[inline]
91    pub fn new() -> Self {
92        Self::builder().build()
93    }
94    #[inline]
95    pub fn variables(
96        &self,
97    ) -> &std::collections::BTreeMap<super::VariableName, super::VariableValue> {
98        &self.variables
99    }
100    #[deprecated(
101        note = "This field is deprecated and will be removed in a future version.\n"
102    )]
103    #[inline]
104    pub fn function_variables(
105        &self,
106    ) -> Option<
107        &std::collections::BTreeMap<super::FunctionReference, super::FunctionVariables>,
108    > {
109        self.function_variables.as_ref().map(|o| &*o)
110    }
111    /// Named datasets looked up by `DatasetReference` nodes in the compute tree.
112    #[inline]
113    pub fn dataset_references(
114        &self,
115    ) -> &std::collections::BTreeMap<super::DatasetReferenceName, super::Dataset> {
116        &self.dataset_references
117    }
118    /// Default fill strategy applied at every multi-input alignment boundary
119    /// where no per-node interpolationConfiguration is specified. When absent, falls back
120    /// to the server-configured default (forward fill with a 1 second fill limit).
121    #[inline]
122    pub fn default_fill_strategy(&self) -> Option<&super::FillStrategy> {
123        self.default_fill_strategy.as_ref().map(|o| &**o)
124    }
125    /// Default alignment strategy applied at every multi-input alignment boundary
126    /// where no per-node alignment strategy is specified. When absent, falls back
127    /// to the server default (driver-series alignment).
128    #[inline]
129    pub fn default_alignment_strategy(&self) -> Option<&super::Alignment> {
130        self.default_alignment_strategy.as_ref().map(|o| &**o)
131    }
132    /// When true, dataset resolution applies each data scope's persisted offset as a time
133    /// shift, and the client must not pre-apply those offsets itself. When absent or false,
134    /// scope offsets are left to the client, preserving behavior for legacy clients that
135    /// inject equivalent timeShift nodes into the compute request. Read from the context in
136    /// scope at resolution time.
137    #[inline]
138    pub fn apply_data_scope_offsets(&self) -> Option<bool> {
139        self.apply_data_scope_offsets.as_ref().map(|o| *o)
140    }
141    /// When true, `Dataset.asset`, the asset-typed sources of `Dataset.run`, and asset or run
142    /// search expand through each asset's mirrored derived dataset instead of its data scopes.
143    /// Branches then carry the dataset's declared channel-search split tag keys in place of
144    /// the reserved `DATA_SCOPE` tag, so callers must filter and group on those keys; the
145    /// definition's own time shifts apply regardless of `applyDataScopeOffsets`; and an asset
146    /// with no mirrored dataset resolves to no data. When absent or false, assets expand from
147    /// their data scopes as before.
148    #[inline]
149    pub fn resolve_assets_through_datasets(&self) -> Option<bool> {
150        self.resolve_assets_through_datasets.as_ref().map(|o| *o)
151    }
152}