#byte #async #pack #msg-pack #impl #write #most

no-std msgpck

A no-std and async compatible msgpck de/serializer

3 unstable releases

0.2.8 Mar 17, 2024
0.1.0 Oct 31, 2023

#429 in Encoding

Download history 33/week @ 2024-02-10 1/week @ 2024-02-17 17/week @ 2024-02-24 2/week @ 2024-03-02 115/week @ 2024-03-16 9/week @ 2024-03-23 45/week @ 2024-03-30 11/week @ 2024-04-06

68 downloads per month

Apache-2.0 OR MIT

50KB
1.5K SLoC

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

Dependencies

~0.4–1MB
~22K SLoC