Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants UnexpectedEnd, InvalidTl(u8), UnexpectedType { expected: Kind, found: Kind, }, ListLength { expected: usize, found: usize, }, InvalidLength, ValueOutOfRange, DepthLimit, MissingEndOfMessage, ObisLength(usize), UnknownChoice { what: &'static str, choice: u64, }, MessageCrc { computed: u16, found: u16, }, FrameCrc { computed: u16, found: u16, }, InvalidPadding, InvalidEscape([u8; 4]), UnexpectedStart, BufferFull, OutputTooSmall, NoReadings, ObisSyntax, InvalidFile,
}
Expand description

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

Every variant is a property of the input, never of this crate’s state: a decoder that returns an error can be fed the next byte.

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

§

InvalidTl(u8)

A type-length field is malformed (an unknown type, a continuation byte with type bits set, or a length shorter than its own TL bytes).

§

UnexpectedType

A value of one type was found where another was required.

Fields

§expected: Kind

The type the grammar requires here.

§found: Kind

The type on the wire.

§

ListLength

A list has a different number of elements than the grammar requires.

Fields

§expected: usize

Elements the grammar requires.

§found: usize

Elements on the wire.

§

InvalidLength

A length is out of range for its type (an integer of 0 or more than 8 bytes, a boolean that is not 1 byte, a TL field of more than 4 bytes).

§

ValueOutOfRange

An unsigned value does not fit the field it was read into.

§

DepthLimit

Lists are nested deeper than the decoder allows.

§

MissingEndOfMessage

The end-of-message byte (0x00) is missing after the message CRC.

§

ObisLength(usize)

An object name is not the six bytes of an OBIS code.

§

UnknownChoice

A choice (SML_Time, SML_Value) uses a tag this crate does not know.

Fields

§what: &'static str

The choice type, e.g. "SML_Time".

§choice: u64

The tag on the wire.

§

MessageCrc

The message CRC does not match its bytes.

Fields

§computed: u16

CRC computed over the message.

§found: u16

CRC field on the wire.

§

FrameCrc

The transport CRC does not match the frame.

Fields

§computed: u16

CRC computed over the frame.

§found: u16

CRC on the wire.

§

InvalidPadding

The end sequence announces more padding than the frame has, or a padding byte is not zero.

§

InvalidEscape([u8; 4])

An escape sequence is followed by a command this crate does not know.

§

UnexpectedStart

A new start sequence arrived before the current frame ended. The decoder has already begun the new frame; the old one is lost.

§

BufferFull

A frame does not fit the buffer the caller gave the decoder.

§

OutputTooSmall

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

§

NoReadings

The frame holds no GetListResponse, so there are no readings in it.

§

ObisSyntax

Text is not an OBIS code (A-B:C.D.E*F, A-B:C.D.E or C.D.E).

§

InvalidFile

An SmlFile does not open first and close last, or has more than 256 messages.

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

The core error trait: available without std (stable since Rust 1.81).

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 ReadError

Available on crate feature std only.
Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl Hash for Error

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 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
where &'static str: Freeze,

§

impl Move for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error
where &'static str: Send,

§

impl Sync for Error

§

impl Unpin for Error
where &'static str: Unpin,

§

impl UnsafeUnpin for Error
where &'static str: UnsafeUnpin,

§

impl UnwindSafe for Error
where &'static str: UnwindSafe,

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