neopack 1.2.1

neopack is a small, opinionated library for binary tlv serialization
Documentation

Neopack is a small binary serialization library.

Everything is encoded using a (nestable!) tag-length-value (TLV) format. a one-byte tag says what follows, an optional four-byte length says how big it is, then the value data follows. All integers are little-endian.

(Some notes for writing neopack encoders/decoders for your types by hand.) Encoding is explicit, you push values onto an [Encoder], then call [Encoder::into_bytes]. Decoding is zero-copy, a [Decoder] borrows the input slice and hands back references.

Thankfully, for structs and enums, #[derive(Pack, Unpack)] (via neopack-derive) generates neopack implementations automatically.

use neopack::Pack;
use neopack::Unpack;

#[derive(Pack, Unpack)]
struct Point { x: i32, y: i32 }

let bytes = Point { x: 1, y: 2 }.pack_to_vec().unwrap();
let point = Point::unpack_from_bytes(&bytes).unwrap();