Skip to main content

nominal_api/conjure/objects/scout/compute/api/
value_map_series.rs

1/// Maps a continuous numeric series to a discrete enum series using the specified value ranges.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct ValueMapSeries {
14    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
15    #[serde(rename = "input")]
16    input: Box<super::NumericSeries>,
17    #[builder(default, list(item(type = super::RangeMap)))]
18    #[serde(rename = "mapping", skip_serializing_if = "Vec::is_empty", default)]
19    mapping: Vec<super::RangeMap>,
20    #[builder(
21        default,
22        custom(
23            type = impl
24            Into<Option<super::StringConstant>>,
25            convert = |v|v.into().map(Box::new)
26        )
27    )]
28    #[serde(rename = "default", skip_serializing_if = "Option::is_none", default)]
29    default: Option<Box<super::StringConstant>>,
30}
31impl ValueMapSeries {
32    /// Constructs a new instance of the type.
33    #[inline]
34    pub fn new(input: super::NumericSeries) -> Self {
35        Self::builder().input(input).build()
36    }
37    /// The input series to map to an enumerated series
38    #[inline]
39    pub fn input(&self) -> &super::NumericSeries {
40        &*self.input
41    }
42    /// The output of the first capturing range will be used. Ranges are start inclusive, end exclusive, must not overlap,
43    /// and increasing from lowest to highest. Ranges can be open ended to the edge of the next or prior range.
44    /// The first range can be open ended to negative infinity, and the last range can be open ended to positive infinity.
45    #[inline]
46    pub fn mapping(&self) -> &[super::RangeMap] {
47        &*self.mapping
48    }
49    /// The default value if not captured by any range. If not specified, points will be filtered.
50    #[inline]
51    pub fn default(&self) -> Option<&super::StringConstant> {
52        self.default.as_ref().map(|o| &**o)
53    }
54}