Crate msgpck

Source
Expand description

A light-weight library for serializing/deserializing types as MsgPack.

To limit binary bloat, this library doesn’t use serde. Insetead, we provide the MsgPack and MsgUnpack traits, which can be derived for most types.

§Usage

We also provide functions like [pack_vec] and unpack_slice to convert between rust types and msgpack bytes, but it’s easy to define your own.

Here is a simple example of an async pack function:

use msgpck::MsgPack;

trait AsyncWrite {
    async fn write(&mut self, bytes: &[u8]);
}

async fn async_pack(writer: &mut impl AsyncWrite, msg: &impl MsgPack) {
    for piece in msg.pack() {
        writer.write(piece.as_bytes()).await;
    }
}

§Compatibility with rmp_serde

We aim to be able to deserialize any value serialized using rmp_serde.

TODO: decide if we’re gonna change serialized representation of enums

Modules§

helpers
Helpers for packing/unpacking certain msgpack values.

Structs§

EnumHeader
The header/key of a msgpack-encoded enum value.

Enums§

Marker
Format markers.
PackErr
Piece
A piece of msgpack data. Used by the MsgPack trait.
UnpackErr
Variant
The discriminant or name of an enum variant.

Traits§

MsgPack
Trait for serializing a type using msgpack.
MsgUnpack
Trait for deserializing a type using msgpack.
Write

Functions§

pack_slice
Pack a MsgPack type into a [u8].
unpack_slice
Unpack a MsgUnpack type from a byte slice.

Derive Macros§

MsgPack
MsgUnpack