Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 21 variants UnexpectedEnd, InvalidStart(u8), InvalidHeader, MissingStop, Checksum { computed: u8, found: u8, }, Crc { block: usize, computed: u16, found: u16, }, InvalidLength, TooManyExtensions, ReservedDif(u8), UnsupportedLvar(u8), UnsupportedCi(u8), OutputTooSmall, UnexpectedLayer(u8), UnsupportedSecurity(u8), NoKey, UnknownFormat(u16), InvalidFormat, UnexpectedFragment { expected: u8, found: u8, }, FragmentFromOtherMeter, Verification(Check), InvalidAddress(u8),
}
Expand description

Everything that can go wrong between the meter’s bytes and a typed record.

Every variant is a property of the input, never of this crate’s state. It is a core::error::Error in every build, no_std included:

fn volume(data: &[u8]) -> Result<(), Box<dyn core::error::Error>> {
    let app = mbus_kit::Application::parse(0x78, data)?;
    let record = app.records().ok_or("no records")?.next().ok_or("empty")??;
    assert_eq!(record.to_string(), "volume — 2850.427 m³");
    Ok(())
}
volume(&[0x0C, 0x13, 0x27, 0x04, 0x85, 0x02]).unwrap();
assert_eq!(volume(&[0x0C, 0x13]).unwrap_err().to_string(), "input ended in the middle of a value");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UnexpectedEnd

The input ended in the middle of a frame or record.

§

InvalidStart(u8)

The first byte is not a known frame start (E5, 10, 68).

§

InvalidHeader

The two length bytes of a long frame differ, or the second 68 is missing.

§

MissingStop

The stop byte (16) is missing.

§

Checksum

The wired checksum does not match.

Fields

§computed: u8

Checksum computed over the frame.

§found: u8

Checksum on the wire.

§

Crc

A wireless block CRC does not match.

Fields

§block: usize

The block (0-based) whose CRC failed.

§computed: u16

CRC computed over the block.

§found: u16

CRC on the wire.

§

InvalidLength

A length field is inconsistent with the frame.

§

TooManyExtensions

More than 10 DIFE or VIFE bytes follow one another.

§

ReservedDif(u8)

A reserved special-function DIF (3F…6F).

§

UnsupportedLvar(u8)

An LVAR value in a reserved range.

§

UnsupportedCi(u8)

The CI field announces something this crate does not parse yet.

§

OutputTooSmall

The output buffer is too small for what is being written.

§

UnexpectedLayer(u8)

A layer appears where it may not (e.g. a second ELL, or an AFL after the TPL).

§

UnsupportedSecurity(u8)

The telegram is encrypted with a security mode this crate does not decrypt.

§

NoKey

No key for this meter in the key lookup.

§

UnknownFormat(u16)

A compact frame whose layout (format signature) is not known yet: wait for a full frame of this meter and remember its Format.

§

InvalidFormat

A compact-frame layout that cannot describe values: a special DIF (manufacturer data, filler) or a plain-text unit in it.

§

UnexpectedFragment

A fragment that does not continue the message in progress: missing, repeated or out of order (found is its fragment ID; 0 for a telegram that is not a fragment).

Fields

§expected: u8

The fragment ID expected next (1 when no message is open).

§found: u8

The fragment ID received.

§

FragmentFromOtherMeter

A fragment from another meter than the message in progress.

§

Verification(Check)

Decryption or authentication failed: the check that failed, never the key.

§

InvalidAddress(u8)

A wired primary address no slave answers from: 251 and 252 are reserved, 255 is the broadcast without reply.

Trait Implementations§

Source§

impl Clone for Error

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 Error

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Eq for Error

Source§

impl Error for Error

Also without std: a no_std crate can wrap it as a source, and a binary can ? it into Box<dyn Error> with default-features = false.

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Available on crate feature std only.
Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Error

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 Error

Auto Trait Implementations§

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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.