Skip to main content

encode_projected_to_slice_with

Function encode_projected_to_slice_with 

Source
pub fn encode_projected_to_slice_with(
    output: &mut [u8],
    encoding: Encoding,
    limits: Limits,
    write: impl FnOnce(ProjectedOutput<'_>) -> Result<(), Error>,
) -> Result<&[u8], Error>
Expand description

Encode a DTO that borrows its projection context into caller-owned output.

The callback receives the destination for one final write. Use its context to prepare envelopes while Serde visits the DTO, for example when staging one sequence element at a time. Its output becomes visible only after the callback and the shared resource checks succeed.

§Errors

Returns a callback, serialization or allowance error. Success requires one completed write. A failed callback or serialization may modify the caller’s output and scratch.