Skip to main content

nominal_api/conjure/objects/scout/compute/api/
range_map.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 RangeMap {
13    #[builder(
14        default,
15        custom(
16            type = impl
17            Into<Option<super::DoubleConstant>>,
18            convert = |v|v.into().map(Box::new)
19        )
20    )]
21    #[serde(rename = "start", skip_serializing_if = "Option::is_none", default)]
22    start: Option<Box<super::DoubleConstant>>,
23    #[builder(
24        default,
25        custom(
26            type = impl
27            Into<Option<super::DoubleConstant>>,
28            convert = |v|v.into().map(Box::new)
29        )
30    )]
31    #[serde(rename = "end", skip_serializing_if = "Option::is_none", default)]
32    end: Option<Box<super::DoubleConstant>>,
33    #[builder(custom(type = super::StringConstant, convert = Box::new))]
34    #[serde(rename = "output")]
35    output: Box<super::StringConstant>,
36}
37impl RangeMap {
38    /// Constructs a new instance of the type.
39    #[inline]
40    pub fn new(output: super::StringConstant) -> Self {
41        Self::builder().output(output).build()
42    }
43    /// Inclusive start value. If not specified, the start is the prior range's end value, or negative infinity.
44    #[inline]
45    pub fn start(&self) -> Option<&super::DoubleConstant> {
46        self.start.as_ref().map(|o| &**o)
47    }
48    /// Exclusive end value. If not specified, the end value is the next range's start value, or positive infinity.
49    #[inline]
50    pub fn end(&self) -> Option<&super::DoubleConstant> {
51        self.end.as_ref().map(|o| &**o)
52    }
53    /// The value to map to if the input value is within the range.
54    #[inline]
55    pub fn output(&self) -> &super::StringConstant {
56        &*self.output
57    }
58}