Skip to main content

encode

Function encode 

Source
pub fn encode<T: Serialize>(
    version: u8,
    value: &T,
) -> Result<Vec<u8>, CodecError>
Expand description

Encode value as [version | postcard(value)].

The leading byte lets the on-disk/wire format evolve without a silent misdecode: see decode, which rejects a foreign version. The version is a parameter rather than a constant so each consumer owns its own schema version and can evolve it independently.