pub enum CodecError {
Empty,
Version {
expected: u8,
actual: u8,
},
Encode(Error),
Decode(Error),
TrailingBytes {
extra: usize,
},
VersionUnsupported {
min: u8,
max: u8,
actual: u8,
},
NotRepresentable {
version: u8,
},
}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.
VersionUnsupported
The leading version byte was outside the reader’s supported range
[min, max]. Distinct from CodecError::Version (which a single-version
reader returns); a multi-version reader uses this to fail loudly on a
version it has no parser for.
NotRepresentable
Down-conversion was asked to encode state not representable at version
(a feature-gate violation: a field/behavior introduced at a later version
is set while encoding an older layout). Fail-loud rather than silently
dropping the value.
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()