#[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
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.
Crc
A wireless block CRC does not match.
Fields
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
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§
impl Copy for Error
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.
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)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()