Skip to main content

encode_frame

Function encode_frame 

Source
pub fn encode_frame<T: Serialize>(
    msg: &T,
    msg_type: MessageType,
) -> Result<Vec<u8>>
Expand description

Encode a message into a framed byte vector suitable for writing to a TCP stream.

The caller provides the message (which must implement serde::Serialize), its MessageType discriminant, and optionally a specific protocol version (defaults to PROTOCOL_VERSION).

Returns the complete frame bytes: 10-byte header + JSON-encoded body.