pub struct ElementSpec {
pub key: String,
pub unit: String,
pub label: String,
pub labels: Option<BTreeMap<String, String>>,
pub viz: Viz,
pub band: Option<[f32; 2]>,
pub stat: bool,
pub scope: Scope,
pub span: bool,
pub value: Option<f32>,
pub state: Option<String>,
}Expand description
A custom sensor or node stat a profile contributes to the dashboard.
This is the unit of a Presentation: one element keyed by a stable, language-
neutral key, drawn with a chosen Viz, scoped to the groups it belongs on, and
labelled for people who do not read the key. The snapshot still carries the raw
value under key; this names how to show it.
Fields§
§key: StringThe stable, language-neutral element key, such as "water_turbidity".
unit: StringThe canonical unit name, such as "ntu", "ph", or "count".
label: StringA human-readable fallback label, shown when no localized label is available.
labels: Option<BTreeMap<String, String>>Optional per-locale labels, keyed by locale tag ("en", "sw", …). A locale
present here is shown in that locale; otherwise the page falls back to
label.
viz: VizThe graphic this element is drawn with.
band: Option<[f32; 2]>The safe band [low, high] in the element’s unit, drawn as the gauge’s safe zone.
stat: boolWhether this is a node or network stat rather than a measurement of the world.
Stats are counted and rendered apart from sensors. Defaults false.
scope: ScopeWhich groups this element is offered on. Defaults to Scope::Always.
span: boolWhether the element’s tile spans two columns, for a wide graphic. Defaults false.
value: Option<f32>A starting numeric value for the add-sensor dialog, before a real sample arrives.
state: Option<String>A starting discrete state code, such as "state.closed", for a non-numeric element.
Implementations§
Source§impl ElementSpec
impl ElementSpec
Sourcepub fn new(
key: impl Into<String>,
unit: impl Into<String>,
label: impl Into<String>,
viz: Viz,
) -> Self
pub fn new( key: impl Into<String>, unit: impl Into<String>, label: impl Into<String>, viz: Viz, ) -> Self
Sourcepub fn as_stat(self) -> Self
pub fn as_stat(self) -> Self
Marks the element as a node or network stat rather than a measurement.
§Returns
The element, for chaining.
Sourcepub fn with_value(self, value: f32) -> Self
pub fn with_value(self, value: f32) -> Self
Sourcepub fn with_state(self, state: impl Into<String>) -> Self
pub fn with_state(self, state: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for ElementSpec
impl Clone for ElementSpec
Source§fn clone(&self) -> ElementSpec
fn clone(&self) -> ElementSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ElementSpec
impl Debug for ElementSpec
Source§impl<'de> Deserialize<'de> for ElementSpec
impl<'de> Deserialize<'de> for ElementSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ElementSpec
impl PartialEq for ElementSpec
Source§fn eq(&self, other: &ElementSpec) -> bool
fn eq(&self, other: &ElementSpec) -> bool
self and other values to be equal, and is used by ==.