#[derive(
Debug,
Clone,
conjure_object::serde::Serialize,
conjure_object::serde::Deserialize,
conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct Threshold {
#[serde(rename = "value")]
#[derive_with(with = conjure_object::private::DoubleWrapper)]
value: f64,
#[serde(rename = "color")]
color: super::super::super::api::HexColor,
#[builder(default, into)]
#[serde(rename = "label", skip_serializing_if = "Option::is_none", default)]
label: Option<String>,
#[builder(
default,
custom(
type = impl
Into<Option<super::ThresholdLatch>>,
convert = |v|v.into().map(Box::new)
)
)]
#[serde(rename = "latch", skip_serializing_if = "Option::is_none", default)]
latch: Option<Box<super::ThresholdLatch>>,
}
impl Threshold {
#[inline]
pub fn new(value: f64, color: super::super::super::api::HexColor) -> Self {
Self::builder().value(value).color(color).build()
}
#[inline]
pub fn value(&self) -> f64 {
self.value
}
#[inline]
pub fn color(&self) -> &super::super::super::api::HexColor {
&self.color
}
#[inline]
pub fn label(&self) -> Option<&str> {
self.label.as_ref().map(|o| &**o)
}
#[inline]
pub fn latch(&self) -> Option<&super::ThresholdLatch> {
self.latch.as_ref().map(|o| &**o)
}
}