Skip to main content

FrameError

Enum FrameError 

Source
#[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
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.
§

TooShort

Decode: the input ended before the header was complete.

Fields

§needed: usize

Octets needed for the preamble and header.

§available: usize

Octets supplied.

§

InvalidPreamble

Decode: the input does not start with the preamble 0x55, 0xFF.

Fields

§first: u8

First input octet.

§second: u8

Second input octet.

§

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

Fields

§raw_type: u8

The frame type octet.

§

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

§length: usize

The Length declared by the header (decode), or the one the data would need (encode).

§

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.

Fields

§raw_type: u8

The frame type octet, 32 or 33.

§

Oversize

The data field of a standard (not COBS-encoded) frame is longer than one allows.

Fields

§length: usize

Data length declared by the header (decode) or supplied (encode).

§maximum: usize

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

Fields

§raw_type: u8

The frame type octet.

§length: usize

Length of the supplied data.

§

MissingVendorId

Encode: a proprietary frame (type 128-255) has fewer than the two data octets its vendor identifier takes (Clause 9.3.11).

Fields

§raw_type: u8

The frame type octet.

§length: usize

Length of the supplied data.

§

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

§length: usize

The Length declared by the header.

§available: usize

Octets supplied after the header.

§

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.

Fields

§length: usize

The Length declared by the header.

§

FrameTooLong

Stream decode: a candidate frame is longer than the decoder’s whole storage, so it can never be buffered. See crate::StreamDecoder.

Fields

§needed: usize

Octets the candidate needs, from its preamble to its last octet.

§capacity: usize

The decoder’s storage capacity.

§

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. needed is the frame’s wire length, available the 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. needed and available are that write’s, as the sink reported them, and the octets of the earlier writes stay in the sink (see FrameSink).
  • Stream decode: a pushed slice is longer than the decoder’s free storage. needed is the slice less the octets of a frame the decoder is skipping, available the decoder’s capacity less what it already buffers, and none of the slice was taken.

Fields

§needed: usize

Octets the refused call or write had to store.

§available: usize

Room there was for them.

Trait Implementations§

Source§

impl Clone for FrameError

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 FrameError

Source§

impl Debug for FrameError

Source§

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

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

impl Display for FrameError

Source§

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

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

impl Eq for FrameError

Source§

impl Error for FrameError

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

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<SinkFull> for FrameError

Source§

fn from(full: SinkFull) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for FrameError

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 FrameError

Auto Trait Implementations§

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.