bitsandbytes 0.1.0

An owned, bit-aware binary codec: fast bit/byte field types and the unified #[bin] macro.
Documentation
[package]
name = "bitsandbytes"
version = "0.1.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
description = "An owned, bit-aware binary codec: fast bit/byte field types and the unified #[bin] macro."
readme = "README.md"

[lib]
# Published as `bitsandbytes`, but the library is named `bnb` — so the crate's own
# tests/doctests/examples and downstream `bnb = { package = "bitsandbytes" }`
# consumers all import it as `bnb`.
name = "bnb"

[dependencies]
# The derive/attribute macros live in a sibling proc-macro crate (a proc-macro
# crate cannot also export runtime items). Re-exported below so users only
# depend on `bnb`.
bnb-macros = { workspace = true }
# Structured diagnostics: the `#[br(dbg)]` directive emits a `tracing` event (TRACE,
# target `bnb::dbg`). Optional, pulled in by the `std` feature — `tracing`'s default
# features link `std`, and the workspace dep can't be overridden here, so `#[br(dbg)]`
# is a `std`-only debugging aid (an embedded build uses its own logger).
tracing = { workspace = true, optional = true }
# Optional: zero-copy `Source`/`Sink` over the `bytes` crate (own a `Bytes` frame to
# decode, encode to a `Bytes` to send) — for async/tokio framing. Off by default so
# the core stays dependency-light; users off tokio never pull it in. The adapters are
# inherently a std/tokio concern, so the `bytes` feature also turns on `std`.
bytes = { workspace = true, optional = true }

[features]
# `std` (default) enables the `std::io` ladder (`StreamBitReader`/`BufSource`/
# `SeekReader`, `encode(writer)`/`spec_encode(writer)`, `From<std::io::Error>`) and the
# `tracing`-backed `#[br(dbg)]` directive. Without it `bnb` is `no_std` — it always
# needs `alloc`: decode from `&[u8]`, encode to `Vec<u8>`.
default = ["std"]
std = ["dep:tracing"]
# `bytes`-crate adapters (`BytesReader`/`BytesWriter`); imply `std` (tokio framing).
bytes = ["dep:bytes", "std"]

[dev-dependencies]
# Compile-fail UI tests: assert that `#[bin]`/`#[bitfield]` misuse is rejected with
# a clear, well-spanned error. Regenerate snapshots with `TRYBUILD=overwrite`.
trybuild.workspace = true
# Property-based round-trip stress testing.
proptest.workspace = true
# Statistical benchmarking with HTML reports. The benches use `Criterion::default()`
# directly (no shared `testutil` harness) so `bnb` stays self-contained / publishable.
criterion = { workspace = true, features = ["html_reports"] }
# The crates `bnb` replaces — used *only* in benchmarks to substantiate the
# "as fast as a hand-written shift/mask" claim before any migration. They are
# dev-dependencies, so they never enter a real build.
bitbybit.workspace = true
arbitrary-int.workspace = true
modular-bitfield-msb.workspace = true

[[bench]]
name = "bitfield_bench"
harness = false

[[bench]]
name = "bitstream_bench"
harness = false

[lints]
workspace = true