Struct ElementSpec
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§
§impl ElementSpec
impl ElementSpec
pub fn new(
key: impl Into<String>,
unit: impl Into<String>,
label: impl Into<String>,
viz: Viz,
) -> ElementSpec
pub fn new( key: impl Into<String>, unit: impl Into<String>, label: impl Into<String>, viz: Viz, ) -> ElementSpec
pub fn with_band(self, low: f32, high: f32) -> ElementSpec
pub fn with_band(self, low: f32, high: f32) -> ElementSpec
pub fn on(self, scope: Scope) -> ElementSpec
pub fn on(self, scope: Scope) -> ElementSpec
pub fn as_stat(self) -> ElementSpec
pub fn as_stat(self) -> ElementSpec
Marks the element as a node or network stat rather than a measurement.
§Returns
The element, for chaining.
pub fn with_value(self, value: f32) -> ElementSpec
pub fn with_value(self, value: f32) -> ElementSpec
pub fn with_state(self, state: impl Into<String>) -> ElementSpec
pub fn with_state(self, state: impl Into<String>) -> ElementSpec
pub fn wide(self) -> ElementSpec
pub fn wide(self) -> ElementSpec
Spans the element’s tile across two columns, for a wide graphic.
§Returns
The element, for chaining.
pub fn with_locale_label(
self,
locale: impl Into<String>,
label: impl Into<String>,
) -> ElementSpec
pub fn with_locale_label( self, locale: impl Into<String>, label: impl Into<String>, ) -> ElementSpec
Trait Implementations§
§impl Clone for ElementSpec
impl Clone for ElementSpec
§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 more