MessagePacker - a no-std msgpack implementation
The protocol specification can be found here.
This crate targets simplicity and performance. No dependencies are used, just the standard Rust library.
It will implement Packable
and Unpackable
for Rust atomic types. The traits can also be implemented manually.
Features
- alloc: Implements the functionality for
Vec
,String
, and unlocks custom extensions. - derive: Enables
MsgPacker
derive convenience macro. - strict: Will panic if there is a protocol violation of the size of a buffer; the maximum allowed size is
u32::MAX
. - std: Will implement the
Packable
andUnpackable
forstd
collections.
Example
use *;
use HashMap;
// boilerplate derives - those aren't required
// this convenience derive macro will implement `Packable` and `Unpackable`
// create an instance of a city.
let city = City ;
// serialize the city into bytes
let mut buf = Vec new;
let n = city.pack;
println!;
// deserialize the city and assert correctness
let = unpack.unwrap;
println!;
assert_eq!;
Benchmarks
Results obtained with Intel(R) Core(TM) i9-9900X CPU @ 3.50GHz
.
The simplicity of the implementation unlocks a performance more than ~10x better than rmp-serde.
Pack 1.000 elements
Unpack 1.000 elements