Skip to main content

Value

Enum Value 

Source
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<'_>

Source

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.

Source

pub const fn as_integer(&self) -> Option<i128>

The value as an integer, for binary integers and valid BCD.

Trait Implementations§

Source§

impl<'a> Clone for Value<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Value<'a>

Source§

impl<'a> Debug for Value<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Value<'_>

Source§

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).

Source§

impl<'a> Eq for Value<'a>

Source§

impl<'a> PartialEq for Value<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Value<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Value<'a>

§

impl<'a> Freeze for Value<'a>

§

impl<'a> Move for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnsafeUnpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.