pub struct Metric {
pub name: Option<String>,
pub alias: Option<u64>,
pub timestamp: Option<u64>,
pub value: MetricValue,
pub is_historical: Option<bool>,
pub is_transient: Option<bool>,
pub metadata: Option<MetaData>,
pub properties: Option<PropertySet>,
}Expand description
A single named/aliased typed value — the unit of all Sparkplug data.
name and alias are both optional: BIRTH metrics carry the name (and,
when aliasing, an alias); DATA metrics may carry only the alias
(tck-id-payloads-alias-data-cmd-requirement).
Fields§
§name: Option<String>Metric name (required on BIRTH unless aliasing — tck-id-payloads-name-requirement).
alias: Option<u64>Metric alias (unique per Edge Node — tck-id-payloads-alias-uniqueness).
timestamp: Option<u64>Acquisition timestamp, epoch milliseconds UTC.
value: MetricValueThe typed value (carries the datatype; Null carries the declared type).
is_historical: Option<bool>Whether this is historical data (should not update the live tag).
is_transient: Option<bool>Whether this value should not be stored as a tag.
metadata: Option<MetaData>Optional metadata (esp. for Bytes/File/multi-part transfers).
properties: Option<PropertySet>Optional property set (engineering units, quality, …).
Implementations§
Source§impl Metric
impl Metric
Sourcepub fn new(name: impl Into<String>, value: MetricValue) -> Self
pub fn new(name: impl Into<String>, value: MetricValue) -> Self
A named metric with the given value and no other fields set.
Sourcepub fn aliased(alias: u64, value: MetricValue) -> Self
pub fn aliased(alias: u64, value: MetricValue) -> Self
An alias-only metric (no name), as used in DATA/CMD messages.
Sourcepub fn with_alias(self, alias: u64) -> Self
pub fn with_alias(self, alias: u64) -> Self
Builder-style setter for the alias.
Sourcepub fn with_timestamp(self, ts: u64) -> Self
pub fn with_timestamp(self, ts: u64) -> Self
Builder-style setter for the timestamp (epoch ms).
Sourcepub fn with_properties(self, props: PropertySet) -> Self
pub fn with_properties(self, props: PropertySet) -> Self
Builder-style setter for the property set.