pub fn decode<T: DeserializeOwned>(
expected_version: u8,
bytes: &[u8],
) -> Result<T, CodecError>Expand description
Decode a payload produced by encode, rejecting a version mismatch.
Returns CodecError::Version when the leading byte differs from
expected_version — a stale reader fails loudly instead of parsing old
bytes against a new struct layout. Returns CodecError::TrailingBytes
when the body decodes but leaves surplus bytes unconsumed: for a versioned
format that exists to catch drift, garbage appended to a valid record is a
corruption signal, not something to silently discard.