deser-msgpack
MessagePack support for deser. MessagePack is a compact binary format with the data model of JSON plus binary data and extensions. Use this crate when you want smaller payloads than JSON without giving up a self describing format, or when you need to talk to MessagePack based systems (Redis, Neovim, fluentd, RPC protocols, ...).
The same types you use with JSON work unchanged, but bytes become native binary data instead of base64 and timestamps use the timestamp extension:
use ;
let blob = Blob ;
// MessagePack has native binary data
let msgpack = to_vec.unwrap;
assert_eq!;
assert_eq!;
// JSON falls back to base64 for the very same type
assert_eq!;
- Reads all well-formed MessagePack and passes the msgpack-test-suite.
- Writes integers and lengths in their shortest form, floats keep their
precision (
f32is float 32,f64is float 64).SerializerConfig::canonicaladditionally sorts map entries for a deterministic encoding (for instance for hashing or signing). - Timestamps (extension type
-1) map onto deser's well-knownTimestamp, sostd::time::SystemTimeand the timestamp types ofjiff,chronoandtimework with the respective features of deser. - Other extensions are read and written with
Ext. Their fallback is the binary data. - Strings and binary data are borrowed from the input.
- Deeply nested input does not overflow the stack.
- Items that follow each other are read with a
Deserializerand written with aSerializer. from_readerandto_writerwork withstd::io, and the configurations read and write streams of items withdeser::ioor async runtimes (deser-tokio). Items are parsed while their input arrives, so only incomplete atoms (like strings) are buffered.
License and Links
- Issue Tracker
- Documentation
- License: Apache-2.0