pub enum Value<'a> {
None,
Int(i64),
UInt(u64),
Bcd(i64),
InvalidBcd(&'a [u8]),
Real32(u32),
Date(Date),
Time(Time),
DateTime(DateTime),
Text(&'a [u8]),
Bytes(&'a [u8]),
Duration(Quantity),
}Expand description
A record’s value.
Variants§
None
No data.
Int(i64)
A binary integer (data type B, two’s complement).
UInt(u64)
An unsigned binary integer (data type C, announced by the combinable extension
VIFE FC 11).
Bcd(i64)
A BCD number.
InvalidBcd(&'a [u8])
A BCD field with digits outside 0–9 (meters use this to signal errors). The raw bytes, as transmitted.
Real32(u32)
A 32-bit IEEE 754 real, as raw bits. Value::as_decimal and
Record::quantity give its exact decimal value; no
float is involved.
Date(Date)
A date (type G).
Time(Time)
A time of day (type J).
DateTime(DateTime)
A date and time (type F or I).
Text(&'a [u8])
A text (variable length, LVAR 00–BF), as transmitted (M-Bus sends it reversed).
Bytes(&'a [u8])
Binary data longer than 8 bytes (LVAR E9–EF, F0–F6).
Duration(Quantity)
A duration in seconds, exact: data type M in its relative form (EN 13757-3:2018 Table A.12, e.g. “offset 3 s” in OMS Annex N N.13).
Implementations§
Source§impl Value<'_>
impl Value<'_>
Sourcepub fn as_decimal(&self) -> Option<(i128, i8)>
pub fn as_decimal(&self) -> Option<(i128, i8)>
The value as an exact decimal mantissa × 10^exponent: integers and valid BCD
with exponent 0, and 32-bit reals converted exactly (every finite IEEE 754
single is a finite decimal). None for NaN, infinities, reals too large
or too small for an i128 mantissa, and non-numeric values.
Sourcepub const fn as_integer(&self) -> Option<i128>
pub const fn as_integer(&self) -> Option<i128>
The value as an integer, for binary integers and valid BCD.
Trait Implementations§
impl<'a> Copy for Value<'a>
Source§impl Display for Value<'_>
impl Display for Value<'_>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Integers in decimal, dates ISO-8601-like, text in reading order. Bytes from the
meter are never written raw: anything but printable ASCII is escaped as \xNN,
so a crafted telegram cannot put control sequences into a terminal or log
(001-describe-every-record/SR-003).