Skip to main content

encode_frame

Function encode_frame 

Source
pub fn encode_frame(value: &impl Serialize) -> Result<Vec<u8>, ProtocolError>
Expand description

Encode a serializable value into a length-prefixed protocol frame.

The wire format is:

  • 4-byte big-endian payload length (u32)
  • JSON payload bytes

§Returns

Ok(Vec<u8>) on succesfull frame encoding.

§Errors

Returns ProtocolError if:

  • serialization fails,
  • the serialized payload is too large to fit into a u32 length prefix,
  • the required output buffer capacity would overflow usize.