Skip to main content

nominal_api/conjure/objects/scout/compute/api/
parameter_input.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 ParameterInput {
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(
24        default,
25        custom(
26            type = impl
27            Into<Option<super::Range>>,
28            convert = |v|v.into().map(Box::new)
29        )
30    )]
31    #[serde(rename = "timeRange", skip_serializing_if = "Option::is_none", default)]
32    time_range: Option<Box<super::Range>>,
33}
34impl ParameterInput {
35    /// Constructs a new instance of the type.
36    #[inline]
37    pub fn new() -> Self {
38        Self::builder().build()
39    }
40    #[inline]
41    pub fn variables(
42        &self,
43    ) -> &std::collections::BTreeMap<super::VariableName, super::VariableValue> {
44        &self.variables
45    }
46    /// Overrides the start and end time of the compute request. If either the start or end are not present, we
47    /// default back to the start/end specified in the request.
48    #[inline]
49    pub fn time_range(&self) -> Option<&super::Range> {
50        self.time_range.as_ref().map(|o| &**o)
51    }
52}