Skip to main content

Crate bnb_macros

Crate bnb_macros 

Source
Expand description

Procedural macros for the bnb crate.

  • bitfield — pack typed fields into one backing integer with explicit bit and byte order.
  • bitflags — pack named single-bit flags into one integer, with set algebra.
  • BitEnum — derive enum ⇄ integer with an optional catch-all.
  • BitDecode / BitEncode — the low-level read/write codec derives (fields at arbitrary bit offsets).
  • bin — the unified whole-message codec attribute, folding the codec derives plus a builder (also dispatches tagged-union enums).
  • BitsBuilder — a required-by-default builder.

These are re-exported from bnb; depend on that crate, not this one.

Attribute Macros§

bin
#[bin] — the unified whole-message bit codec. One attribute that folds the read codec (BitDecode), the write codec (BitEncode), and a required-by-default builder (BitsBuilder) over a struct of bnb::Bits fields, read and written at arbitrary bit offsets.
bitfield
Packs the annotated struct’s fields into a single backing integer.
bitflags
Packs named single-bit flags into one backing integer, with set algebra.

Derive Macros§

BitDecode
Derives a bnb::BitDecode impl that reads the struct’s named fields, in declaration order, from a bit cursor (a bnb::BitReader).
BitEncode
Derives a bnb::BitEncode impl — the dual of BitDecode, writing the struct’s named fields in order to a bnb::BitWriter bit cursor. Shares BitDecode’s right-tool guard and #[bit_stream(...)] override.
BitEnum
Derives an enum ⇄ integer mapping of a fixed bit width.
BitsBuilder
Generates a derive_builder-style builder for a struct (or, when listed in a #[bitfield]’s derives, for the bitfield — intercepted by #[bitfield]).