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.
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.
Malformed
A candidate frame failed a check and was dropped.
Fields
discard: usizeOctets 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: FrameErrorWhy 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.