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

bin+lib buffertk

Buffertk provides tooling for serializing and deserializing data

6 releases (breaking)

0.6.0 Feb 19, 2024
0.5.0 Dec 27, 2023
0.4.0 Sep 21, 2023
0.3.0 Jul 9, 2023
0.1.0 Apr 4, 2023

#584 in Parser implementations

Download history 12/week @ 2024-01-04 19/week @ 2024-01-11 9/week @ 2024-01-18 3/week @ 2024-01-25 3/week @ 2024-02-01 13/week @ 2024-02-08 166/week @ 2024-02-15 113/week @ 2024-02-22 54/week @ 2024-02-29 45/week @ 2024-03-07 31/week @ 2024-03-14 52/week @ 2024-03-21 83/week @ 2024-03-28 44/week @ 2024-04-04 32/week @ 2024-04-11 26/week @ 2024-04-18

189 downloads per month
Used in 22 crates (20 directly)

Apache-2.0

47KB
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

Features