pub enum CodecError {
Empty,
Version {
expected: u8,
actual: u8,
},
Encode(Error),
Decode(Error),
TrailingBytes {
extra: usize,
},
}Expand description
Failure modes of the version-prefixed postcard codec.
Encode and Decode are kept distinct so a caller can tell which
direction failed; both carry the underlying postcard::Error as the
error source rather than via a From conversion, so a stray ? on a
postcard result never silently becomes a CodecError.
Variants§
Empty
The payload had no leading version byte (it was empty).
Version
The leading version byte did not match the version the reader expected. A stale reader hits this instead of misdecoding old bytes against a new struct layout.
Encode(Error)
postcard failed to serialize the value.
Decode(Error)
postcard failed to deserialize the framed body.
TrailingBytes
The body decoded successfully but extra bytes remained unconsumed.
For a versioned on-disk format this signals corruption — e.g. a partial
overwrite that left stale tail bytes — rather than a clean record.
Trait Implementations§
Source§impl Debug for CodecError
impl Debug for CodecError
Source§impl Display for CodecError
impl Display for CodecError
Source§impl Error for CodecError
impl Error for CodecError
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()