Skip to main content

decode

Function decode 

Source
pub fn decode<'de, T: Deserialize<'de>>(
    input: &'de [u8],
    encoding: Encoding,
    limits: Limits,
) -> Result<T, Error>
Expand description

Decode exactly one payload or frame under explicit traversal allowances.

Borrowed results may reference the original input. Postcard owns primitive acceptance; this does not enforce canonical bytes or reserialize results. Consumer collections and custom Serde may normalize values. Retain original bytes for signatures, hashes and retries. Custom Serde work outside admitted visits is trusted; a valid prefix can allocate before a later failure.

ยงErrors

Oversized input returns Error::Limit before header checks. Short frames return Error::Malformed, then header mismatches return Error::Identity. During payload decoding exhausted allowances return Error::Limit, other deserialization failures return Error::Malformed. A successful value followed by unused input returns Error::Trailing.