pub enum UnPackError {
ReSync {
skip: usize,
},
MissingHeader {
skip: usize,
},
UnexpectedEnd {
read: usize,
},
InvalidChecksum {
at: usize,
},
MarshalerError(MarshalerError),
}Expand description
Errors returned by
Messager::unpack
and Messager::unmarshal.
Variants§
ReSync
The input does not start with the SOF byte (0xA5), but a SOF byte
was found later in the buffer.
skip is the byte offset of the first SOF byte found.
Discard that many bytes from the input, then retry.
MissingHeader
No SOF byte was found anywhere in the input buffer.
skip equals the buffer length.
Discard the entire buffer and wait for more data before retrying.
UnexpectedEnd
The frame is truncated; more bytes are needed to complete it.
read is the number of bytes currently available.
Keep the existing bytes and wait for more data before retrying.
InvalidChecksum
CRC validation failed (header CRC8 or frame CRC16).
at is the cursor position when the failure was detected.
Call UnPackError::skip to determine how many bytes to discard.
MarshalerError(MarshalerError)
The payload could not be decoded into the target type.
Wraps a MarshalerError from RawFrame::unmarshal.
Implementations§
Source§impl UnPackError
impl UnPackError
Sourcepub fn skip(&self) -> usize
pub fn skip(&self) -> usize
Returns the number of bytes to discard before retrying a parse.
Use this when processing a continuous byte stream to advance the read position past invalid or incomplete data:
| Variant | Returned value | Action |
|---|---|---|
ReSync | offset of next SOF | discard bytes, retry |
MissingHeader | buffer length | discard all, wait for data |
UnexpectedEnd | 0 | wait for more data at current position |
InvalidChecksum | cursor at failure | discard frame, retry |
MarshalerError | 0 | frame was consumed; handle decode error |