Skip to main content

ObisCode

Struct ObisCode 

Source
pub struct ObisCode<'a> { /* private fields */ }
Expand description

An OBIS code from RI, keeping its original spelling.

Borrows the record’s own bytes in the ordinary case. It holds a Cow rather than a &str for one reason: RI is a JSON string like any other, so "1-b:1.8.\u0030" is a lawful spelling of "1-b:1.8.0" — and a decoded escape is longer than what it denotes, so it can never be a subslice of the source. Refusing such a record would throw away an intact signed payload over a spelling.

Implementations§

Source§

impl<'a> ObisCode<'a>

Source

pub fn as_str(&self) -> &str

The code exactly as the station wrote it — decoded, when the source spelled a character as an escape.

Source

pub fn medium(&self) -> &str

The A group (medium).

Source

pub fn channel(&self) -> &str

The B group (channel).

Source

pub fn quantity(&self) -> &str

The C group (physical quantity).

Source

pub fn processing(&self) -> &str

The D group (processing).

Source

pub fn tariff(&self) -> &str

The E group (tariff).

Source

pub fn billing_period(&self) -> Option<&str>

The F group (billing period), when written.

Source

pub fn register(&self) -> Register

What this register measures.

Source

pub fn is_register(&self) -> bool

Whether D marks this as a time-integral register (8) — the reading a bill is computed from, as opposed to an instantaneous value.

Source

pub fn canonical(&self) -> String

The canonical [OCMF Tab. 25] spelling: two-digit upper-case groups, * before the billing period.

Two codes are the same register exactly when their canonical forms are equal, which is the comparison by_register uses.

Source

pub fn is_canonical(&self) -> bool

Whether the code is already written in the [OCMF Tab. 25] form: AA-BB:CC.DD.EE with two upper-case digits per group, and * before the billing period when there is one.

Answered without building the canonical string, because this runs once per reading and the answer is “no” for every OBIS code in the reference corpus.

Source

pub fn parse(raw: &'a str) -> Option<Self>

Parses a plain string. None when the text has no OBIS shape at all.

Source

pub fn parse_cow(raw: Cow<'a, str>) -> Option<Self>

Parses text that may have had to be decoded from a JSON escape.

RI is a JSON string like any other, so "1-b:1.8.\u0030" is a lawful spelling of "1-b:1.8.0" — and a decoded escape is longer than what it denotes, so the result can never be a subslice of the record. That is why this type holds a Cow: borrowed in every real case, owned when it has to be. Refusing such a record instead would throw away an intact signed payload over a spelling.

Trait Implementations§

Source§

impl<'a> Clone for ObisCode<'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> Debug for ObisCode<'a>

Source§

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

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

impl Display for ObisCode<'_>

Source§

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

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

impl<'a> Eq for ObisCode<'a>

Source§

impl<'a> PartialEq for ObisCode<'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 ObisCode<'a>

Auto Trait Implementations§

§

impl<'a> Forget for ObisCode<'a>

§

impl<'a> Freeze for ObisCode<'a>

§

impl<'a> Move for ObisCode<'a>

§

impl<'a> RefUnwindSafe for ObisCode<'a>

§

impl<'a> Send for ObisCode<'a>

§

impl<'a> Sync for ObisCode<'a>

§

impl<'a> Unpin for ObisCode<'a>

§

impl<'a> UnsafeUnpin for ObisCode<'a>

§

impl<'a> UnwindSafe for ObisCode<'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.