#serialization #deserializing #tooling #traits #pack #stack-pack #packable

bin+lib buffertk

Buffertk provides tooling for serializing and deserializing data

10 breaking releases

new 0.11.0 Dec 4, 2024
0.10.0 Oct 8, 2024
0.9.0 Sep 17, 2024
0.6.0 Feb 19, 2024
0.3.0 Jul 9, 2023

#519 in Parser implementations

Download history 403/week @ 2024-08-17 100/week @ 2024-08-24 145/week @ 2024-08-31 48/week @ 2024-09-07 250/week @ 2024-09-14 98/week @ 2024-09-21 95/week @ 2024-09-28 247/week @ 2024-10-05 95/week @ 2024-10-12 41/week @ 2024-10-19 97/week @ 2024-10-26 117/week @ 2024-11-02 40/week @ 2024-11-09 236/week @ 2024-11-16 66/week @ 2024-11-23 252/week @ 2024-11-30

609 downloads per month
Used in 28 crates (23 directly)

Apache-2.0

48KB
1K SLoC

buffertk

Buffertk provides tooling for serializing and deserializing data.

Status

Maintenance track. The library is considered stable and will be put into maintenance mode if unchanged for one year.

Scope

This library is about serialization and deserialization patterns that are common. It is chiefly intended to provide the primitives used by the prototk crate.

Example

To pack, implement the [Packable] trait and use [stack_pack].

use buffertk::{v64, stack_pack};

let x = v64::from(42);
let buf: &[u8] = &stack_pack(x).to_vec();
assert_eq!(&[42u8], buf);

Unpacking uses the [Unpackable] trait or the [Unpacker].

use buffertk::{v64, Unpacker};

let mut up = Unpacker::new(&[42u8]);
let x: v64 = up.unpack().expect("[42] is a valid varint; something's wrong");
assert_eq!(42u64, x.into());

Warts

  • Some patterns are used frequently and could be abstracted better. Given that most of this library is used with code generation this is not a concern.

Documentation

The latest documentation is always available at docs.rs.

No runtime deps