#messagepack #serializer-deserializer #embedded #serde #field-name

no-std ser-write-msgpack

MessagePack serializer for ser-write and deserializer for convenience

3 releases (breaking)

0.3.0 Oct 31, 2024
0.2.0 May 14, 2024
0.1.0 May 11, 2024

#140 in No standard library

Download history 2/week @ 2024-07-27 13/week @ 2024-09-21 16/week @ 2024-09-28 112/week @ 2024-10-26 25/week @ 2024-11-02 1/week @ 2024-11-09

138 downloads per month

MIT/Apache

215KB
4.5K SLoC

ser-write-msgpack

Crate Docs Build Status Coverage Status Minimum rustc version

This crate provides a no_std friendly MessagePack serializers for serde using SerWrite as a writer and a deserializer for convenience.

Usage

[dependencies]
ser-write-msgpack = { version = "0.3", default-features = false }

Serializer

ser-write-msgpack comes with 3 serializers:

  • to_writer_compact - serializes structs to arrays and enum variants as indexes,
  • to_writer - serializes structs to maps with fields and enum variants as indexes,
  • to_writer_named - serializes structs to maps with field names and enum variants as strings.

Features:

  • std enables std library,
  • alloc enables alloc library,

With alloc or std feature enabled serde::ser::Serializer::collect_str method is implemented using intermediate String.

Otherwise Serializer::collect_str is implemented by formatting a string twice, once to count the string size and the second time to actually write it.

Deserializer

The MessagePack deserializer expects a MessagePack encoded slice of bytes. &str or &[u8] types deserialize using (ZERO-COPY) references from the provided slice.

  • from_slice - deserializes MessagePack data from a slice of bytes
  • from_slice_split_tail - deserializes MessagePack data from a slice of bytes returning a remaining portion of the input slice

Deserializer supports self-describing formats.

Deserializer deserializes structs from both maps and arrays using either strings or indexes as variant or field identifiers.

Rust Version Requirements

ser-write-msgpack requires Rustc version 1.81 or greater.

Dependencies

~100–380KB