Skip to main content

encode_to_slice

Function encode_to_slice 

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

Encode a payload into caller-owned storage without allocating codec output.

Returns only the completed encoding. A short buffer returns Error::Limit before writing; on any other error storage contents are unspecified and must not be published. The returned slice borrows storage, not the value. Admission, two-pass sizing and trusted custom Serde rules match encode_into; storage capacity does not replace or reduce the configured allocation allowance.