protosocket-messagepack
MessagePack codec adapters for protosocket.
Provides MessagePackSerializer and MessagePackDecoder.
MessagePackSerializer implements protosocket::Serialize for use with the PooledEncoder.
MessagePackDecoder implements protosocket::Decoder. Wire these up as the codec for any
protosocket::Connection or protosocket-rpc service.
Wire format
Each message is framed as a 5-byte MessagePack-encoded u32 length prefix followed by the
MessagePack-encoded payload. The decoder is stateful and handles messages that arrive split
across multiple reads.
Usage
use ;
use PooledEncoder;
// Encoder: wrap in PooledEncoder to reuse send buffers
type Encoder = ;
// Decoder
type Decoder = ;
// Combine into a codec tuple for protosocket
let codec = ;
Your message type must implement serde::Serialize for the serializer and
serde::de::DeserializeOwned for the decoder.
See example-messagepack for a complete working client and server.