Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
threshold.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 Threshold {
13    #[serde(rename = "value")]
14    #[derive_with(with = conjure_object::private::DoubleWrapper)]
15    value: f64,
16    #[serde(rename = "color")]
17    color: super::super::super::api::HexColor,
18    #[builder(default, into)]
19    #[serde(rename = "label", skip_serializing_if = "Option::is_none", default)]
20    label: Option<String>,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::ThresholdLatch>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(rename = "latch", skip_serializing_if = "Option::is_none", default)]
30    latch: Option<Box<super::ThresholdLatch>>,
31}
32impl Threshold {
33    /// Constructs a new instance of the type.
34    #[inline]
35    pub fn new(value: f64, color: super::super::super::api::HexColor) -> Self {
36        Self::builder().value(value).color(color).build()
37    }
38    /// The minimum value a number must be to trigger the threshold color. If used in a staleness cell, this value is in milliseconds.
39    #[inline]
40    pub fn value(&self) -> f64 {
41        self.value
42    }
43    /// The color to apply to the cell when the threshold is active.
44    #[inline]
45    pub fn color(&self) -> &super::super::super::api::HexColor {
46        &self.color
47    }
48    /// A name for this threshold to display while editing.
49    #[inline]
50    pub fn label(&self) -> Option<&str> {
51        self.label.as_ref().map(|o| &**o)
52    }
53    /// Options for pinning an indicator that data was within the threshold range
54    /// while streaming.
55    #[inline]
56    pub fn latch(&self) -> Option<&super::ThresholdLatch> {
57        self.latch.as_ref().map(|o| &**o)
58    }
59}