pub struct Reading {
pub key: String,
pub value: f32,
pub unit: String,
pub status: Status,
pub band: Option<[f32; 2]>,
pub viz: Option<String>,
pub trend: Option<Trend>,
pub state: Option<String>,
pub actions: Option<Vec<String>>,
pub stat: bool,
}Expand description
A single measured value, named by a stable key and a canonical unit.
Fields§
§key: StringA stable, language-neutral element key, such as "soil_moisture".
value: f32The raw measured value, in the canonical unit.
unit: StringThe canonical unit name, such as "percent", "celsius", or "volt".
status: StatusThe health of this reading on its own.
band: Option<[f32; 2]>The safe band [low, high] in the same unit, drawn as the gauge’s safe zone.
viz: Option<String>An explicit visualization kind that overrides the page’s key/unit heuristic, such
as "radial" or "bar". Set from a profile’s Viz with
with_viz so a custom reading is drawn the way its profile
intends; None lets the page pick from the key and unit.
trend: Option<Trend>Which way the reading is moving, if known.
state: Option<String>A discrete state code for a non-numeric reading, such as "state.open" for a
valve or "pump.nominal" for a pump, which the page renders as a labelled chip.
Numeric readings leave this None.
actions: Option<Vec<String>>The discrete actions this reading can be commanded to, such as
["open", "closed"] for a valve. Present only on a controllable actuator; a
read-only sensor leaves this None, and the page shows control only when it is set.
stat: boolWhether this is a node or network stat (neighbours, hops, link or relay status, a
tamper-log record count) rather than a measurement of the world. The page counts and
renders stats apart from sensors. Defaults false.
Implementations§
Source§impl Reading
impl Reading
Sourcepub fn new(key: impl Into<String>, value: f32, unit: impl Into<String>) -> Self
pub fn new(key: impl Into<String>, value: f32, unit: impl Into<String>) -> Self
Creates a reading in good standing with no band or trend.
§Arguments
key- the stable element key.value- the raw measured value.unit- the canonical unit name.
§Returns
A Status::Ok reading carrying just the value and unit.
Sourcepub fn with_status(self, status: Status) -> Self
pub fn with_status(self, status: Status) -> Self
Sourcepub fn with_viz(self, viz: Viz) -> Self
pub fn with_viz(self, viz: Viz) -> Self
Pins the graphic this reading is drawn with, overriding the page’s heuristic.
Use this when a profile declares a custom element with Viz and you want the
live reading drawn the same way, regardless of its key and unit.
§Arguments
viz- the graphic to draw the reading with.
§Returns
The reading, for chaining.