Skip to main content

DecodeEvent

Enum DecodeEvent 

Source
pub enum DecodeEvent<'a> {
    NeedMore,
    Frame {
        frame: Frame<'a>,
        consumed: usize,
    },
    Invalid {
        discard: usize,
    },
    Malformed {
        discard: usize,
        error: FrameError,
        destination: Option<u8>,
    },
    Error(FrameError),
}
Expand description

The outcome of one StreamDecoder::push_slice call.

Variants§

§

NeedMore

Nothing complete and nothing to discard: push more octets.

§

Frame

A valid frame. It borrows the decoder’s storage and stays buffered until the next push, which removes it.

Fields

§frame: Frame<'a>

The decoded frame.

§consumed: usize

The frame’s wire length.

§

Invalid

Line noise was discarded while searching for a preamble: every buffered octet up to the next 0x55 among them, which might start one, in a single event. A run of noise that arrives over several pushes gives one event per push.

This is not a received invalid frame in terms of the Clause 9.5.4 receive state machine.

Fields

§discard: usize

Octets discarded.

§

Malformed

A candidate frame failed a check and was dropped.

Fields

§discard: usize

Octets of the stream discarded, counted from the candidate’s first octet.

When its header passed every check, its declared length can be trusted, so the decoder drops the whole frame by count, as the receive state machine skips one (Clause 9.5.4.4): for a frame longer than the storage, a reserved COBS type, or data that failed its CRC. This is then the frame’s wire length, and any of it that hasn’t arrived yet is dropped as it comes, with no further event. For anything else, a bad header or one that never completes, it is the first preamble octet, and the octets after it are scanned again.

§error: FrameError

Why the candidate was dropped.

§destination: Option<u8>

The candidate’s destination address once its header CRC has passed, including for a header refused afterwards (source 255, a Length out of range). None when the header CRC failed or the header never completed. See StreamDecoder for why a receiver needs it.

§

Error(FrameError)

The pushed slice did not fit in the free storage. None of it was taken; see StreamDecoder.

Trait Implementations§

Source§

impl<'a> Clone for DecodeEvent<'a>

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<'a> Copy for DecodeEvent<'a>

Source§

impl<'a> Debug for DecodeEvent<'a>

Source§

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

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

impl<'a> Eq for DecodeEvent<'a>

Source§

impl<'a> PartialEq for DecodeEvent<'a>

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<'a> StructuralPartialEq for DecodeEvent<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for DecodeEvent<'a>

§

impl<'a> RefUnwindSafe for DecodeEvent<'a>

§

impl<'a> Send for DecodeEvent<'a>

§

impl<'a> Sync for DecodeEvent<'a>

§

impl<'a> Unpin for DecodeEvent<'a>

§

impl<'a> UnsafeUnpin for DecodeEvent<'a>

§

impl<'a> UnwindSafe for DecodeEvent<'a>

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