bitsandbytes 0.3.2

An owned, bit-aware binary codec: fast bit/byte field types and the unified #[bin] macro.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! A read-side `#[br(map = …)]` transforms the wire repr into a non-`Bits` field
//! type, so encoding needs the inverse `#[bw(map = …)]`. Omitting it is an error.
use bnb::bin;

#[derive(Clone)]
struct Wrapped(u16);

#[bin]
struct Frame {
    tag: bnb::u4,
    #[br(map = |raw: u16| Wrapped(raw))]
    value: Wrapped,
}

fn main() {}