Skip to main content

encode

Function encode 

Source
pub fn encode(frame: &Frame, buffer: &mut [u8]) -> Result<usize, ProtocolError>
Expand description

Encode a frame into the provided byte buffer, returning bytes written.

The buffer must be at least encoded_len bytes long. Encoding writes the fixed 10-byte header followed by the serialized payload and performs no heap allocation.

§Errors

Returns ProtocolError when the frame violates stream invariants, its payload cannot fit in the protocol’s length fields, or the provided buffer is too small.