Skip to main content

Address

Struct Address 

Source
pub struct Address {
    pub manufacturer: Manufacturer,
    pub id: [u8; 4],
    pub version: u8,
    pub medium: Medium,
}
Expand description

A meter’s address: manufacturer, identification number, version and device type.

The same eight bytes appear in the wireless link layer and in a long header (where they name the meter behind a repeater or a gateway). They select the key and form part of the OMS initialisation vector.

Fields§

§manufacturer: Manufacturer

Manufacturer (FLAG association code).

§id: [u8; 4]

Identification number, 8 BCD digits, as transmitted (LSB first).

§version: u8

Version / generation.

§medium: Medium

Device type (medium).

Implementations§

Source§

impl Address

Source

pub fn id_number(&self) -> Option<u32>

The identification number as printed on the meter, if it is valid BCD.

Examples found in repository?
examples/readout.rs (line 23)
14fn main() -> Result<(), mbus_kit::Error> {
15    let Some((Frame::Long { ci, data, .. }, _)) = Frame::parse(&TELEGRAM)? else {
16        return Err(mbus_kit::Error::UnexpectedEnd);
17    };
18    let app = Application::parse(ci, data)?;
19    if let Header::Long(h) = app.header {
20        println!(
21            "{} meter {:08} by {}, version {}",
22            h.address.medium,
23            h.address.id_number().unwrap_or(0),
24            h.address.manufacturer,
25            h.address.version
26        );
27    }
28    if let Body::Records(records) = app.body {
29        for record in records {
30            // e.g. "volume flow · maximum · storage 5 — 0.113 m³/h"
31            println!("  {}", record?);
32        }
33    }
34    Ok(())
35}
Source

pub const fn to_bytes(self) -> [u8; 8]

The address in link-layer order: manufacturer (LE), ID, version, medium.

Parse link-layer order (manufacturer first).

Trait Implementations§

Source§

impl Clone for Address

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 Copy for Address

Source§

impl Debug for Address

Source§

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

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

impl Display for Address

Source§

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

KAM 12345678 water v27; the raw ID in hex if it is not valid BCD.

Source§

impl Eq for Address

Source§

impl Hash for Address

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Address

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 StructuralPartialEq for Address

Auto Trait Implementations§

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.