Skip to main content

encode_to_slice

Function encode_to_slice 

Source
pub fn encode_to_slice<'out, T: Serialize + ?Sized>(
    value: &T,
    encoding: Encoding,
    limits: Limits,
    output: &'out mut [u8],
) -> Result<&'out [u8], Error>
Expand description

Encode into caller storage without allocating codec output.

A short destination is rejected before writing. Other failures may modify storage; only a successful returned slice may be published. Custom Serialize work is trusted and may allocate independently. Caller capacity does not reduce the configured allocation allowance.

ยงErrors

Returns Limit for exhausted allowances or a short destination, otherwise Malformed for serialization failure (including growth between passes).