nominal_api/conjure/objects/scout/chartdefinition/api/
threshold.rs1#[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 #[inline]
35 pub fn new(value: f64, color: super::super::super::api::HexColor) -> Self {
36 Self::builder().value(value).color(color).build()
37 }
38 #[inline]
40 pub fn value(&self) -> f64 {
41 self.value
42 }
43 #[inline]
45 pub fn color(&self) -> &super::super::super::api::HexColor {
46 &self.color
47 }
48 #[inline]
50 pub fn label(&self) -> Option<&str> {
51 self.label.as_ref().map(|o| &**o)
52 }
53 #[inline]
56 pub fn latch(&self) -> Option<&super::ThresholdLatch> {
57 self.latch.as_ref().map(|o| &**o)
58 }
59}