encode

Function encode 

Source
pub fn encode(message: &ProtocolMessage) -> Result<Vec<u8>, String>
Expand description

Encode a ProtocolMessage into a compact binary form according to protocol.md.

The encoder writes, in order: 4-byte CRDT magic, varBytes room id, 1-byte message type tag, and the message-specific payload. It validates room id length and ensures the final buffer does not exceed 256KB.

Returns an owned Vec<u8> containing the encoded message.