#[non_exhaustive]pub enum FrameError {
Show 14 variants
TooShort {
needed: usize,
available: usize,
},
InvalidPreamble {
first: u8,
second: u8,
},
HeaderCrcMismatch,
UnsupportedCobsFrame {
raw_type: u8,
},
BroadcastSource,
InvalidCobsLength {
length: usize,
},
ExtendedFrame {
raw_type: u8,
},
Oversize {
length: usize,
maximum: usize,
},
UnexpectedData {
raw_type: u8,
length: usize,
},
MissingVendorId {
raw_type: u8,
length: usize,
},
Truncated {
length: usize,
available: usize,
},
DataCrcMismatch {
length: usize,
},
FrameTooLong {
needed: usize,
capacity: usize,
},
BufferExhausted {
needed: usize,
available: usize,
},
}Expand description
A frame could not be encoded or decoded.
Encode and decode share the variants that mean the same thing in both directions; the caller knows which one it asked for. Later releases may add variants, so a match outside this crate needs a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TooShort
Decode: the input ended before the header was complete.
InvalidPreamble
Decode: the input does not start with the preamble 0x55, 0xFF.
HeaderCrcMismatch
Decode: the header CRC does not match.
UnsupportedCobsFrame
A reserved COBS-encoded frame type, 34-127, which the codec doesn’t implement. The header passed every other check first, source and Length included, so it is a good header (Clause 9.5.8).
BroadcastSource
The source address is 255, the broadcast address, which no station may send from (Clause 9.3).
InvalidCobsLength
A COBS-encoded frame’s Length is outside
MIN_COBS_LENGTH..=MAX_COBS_LENGTH,
so the header is bad (Clause 9.5.8). On encode, the data is empty or
encodes to more than the largest Length allows.
Fields
ExtendedFrame
Decode with decode_frame: a good extended
frame header, whose COBS-encoded data can’t be borrowed from the
input. It says only “decode this in place”: nothing after the header
was checked, and
decode_frame_in_place gives the
verdict on the rest of the frame.
Oversize
The data field of a standard (not COBS-encoded) frame is longer than one allows.
Fields
maximum: usizeLargest standard data field, crate::MAX_STANDARD_MPDU_DATA.
UnexpectedData
Encode: data was supplied for a frame type that never carries any (see
crate::FrameType::allows_data).
MissingVendorId
Encode: a proprietary frame (type 128-255) has fewer than the two data octets its vendor identifier takes (Clause 9.3.11).
Truncated
Decode: the input ended before the frame did: before a standard frame’s data and data CRC, or an extended frame’s encoded fields, were complete.
Fields
DataCrcMismatch
Decode: the frame’s data failed its check. For a standard frame the data CRC doesn’t match. For an extended frame the CRC-32K doesn’t, or a code octet in either encoded field is zero or runs past the field’s end, which Clause 9.10.3 treats as a bad CRC too.
FrameTooLong
Stream decode: a candidate frame is longer than the decoder’s whole
storage, so it can never be buffered. See crate::StreamDecoder.
Fields
BufferExhausted
There was no room for the octets. It comes from three places:
- Encode, before writing: the sink reports a capacity, and the frame
doesn’t fit it.
neededis the frame’s wire length,availablethe sink’s remaining capacity, and nothing was written. - Encode, part way through: one of the sink’s own writes failed with
a
SinkFull, as a growable sink’s can, since it is never checked up front.neededandavailableare that write’s, as the sink reported them, and the octets of the earlier writes stay in the sink (seeFrameSink). - Stream decode: a pushed slice is longer than the decoder’s free
storage.
neededis the slice less the octets of a frame the decoder is skipping,availablethe decoder’s capacity less what it already buffers, and none of the slice was taken.
Trait Implementations§
Source§impl Clone for FrameError
impl Clone for FrameError
impl Copy for FrameError
Source§impl Debug for FrameError
impl Debug for FrameError
Source§impl Display for FrameError
impl Display for FrameError
impl Eq for FrameError
Source§impl Error for FrameError
impl Error for FrameError
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()