1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
[]
= "bitsandbytes"
= "0.3.2"
= true
= true
= true
= true
= "An owned, bit-aware binary codec: fast bit/byte field types and the unified #[bin] macro."
= "README.md"
= ["bitfield", "codec", "binary", "no_std", "protocol"]
= ["encoding", "parsing", "no-std", "network-programming"]
# docs.rs builds with all features (so the `std` ladder and `bytes` adapters are
# documented) and `--cfg docsrs`, which lights up the per-item feature badges
# (`#![cfg_attr(docsrs, feature(doc_auto_cfg))]` in lib.rs).
[]
= true
= ["--cfg", "docsrs"]
[]
# 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`.
= "bnb"
[]
# 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`.
= { = 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).
= { = true, = 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`.
= { = true, = true }
# Optional: the `tokio_util::codec` adapter ([`BinCodec`]) for async framing. Off by
# default; pulled in only by the `tokio` feature.
= { = true, = true }
[]
# `std` (default) enables the `std::io` ladder (`StreamBitReader`/`BufSource`/
# `SeekReader`, the `encode(writer)` convenience, `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>`.
= ["std"]
= ["dep:tracing"]
# `bytes`-crate adapters (`BytesReader`/`BytesWriter`); imply `std` (tokio framing).
= ["dep:bytes", "std"]
# `BinCodec`: a `tokio_util::codec` Decoder/Encoder for any `#[bin]` message (async framing
# over `tokio`). Needs the `bytes` adapters' `BytesMut`, so it implies `bytes`.
= ["dep:tokio-util", "bytes"]
# Ergonomic std socket helpers (`MessageStream` over a `Read + Write` stream, `MessageDatagram`
# over a `DatagramSocket`). Pure std — no extra deps.
= ["std"]
# Test-only mock transport (`MockDatagramSocket`) for exercising `net` code without real sockets.
# Put it in your `[dev-dependencies]` features, not your release build.
= ["net"]
[]
# Real logging in the examples (instead of `println!`). `tracing` is also an optional
# runtime dep (the `std` feature, for `#[br(dbg)]`); as a dev-dep it's always available
# to examples, and `tracing-subscriber` renders the events.
= true
= true
# Compile-fail UI tests: assert that `#[bin]`/`#[bitfield]` misuse is rejected with
# a clear, well-spanned error. Regenerate snapshots with `TRYBUILD=overwrite`.
= true
# Property-based round-trip stress testing.
= true
# `tests/serde_compat.rs`: pins the 1.0 scope line — user-side serde derives coexist with
# plain `#[bin]` types; serde-as-data-format is explicitly out of scope (see ROADMAP.md).
= true
= true
# Statistical benchmarking with HTML reports. The benches use `Criterion::default()`
# directly (no shared `testutil` harness) so `bnb` stays self-contained / publishable.
= { = true, = ["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.
= true
= true
= true
# The `tokio_framed` example drives `bnb::BinCodec` (the `tokio` feature) over a real async
# socket. The runtime + the `Stream`/`Sink` ext traits are dev-only; `tokio-util` comes from
# the `tokio` feature.
= true
= true
# The `framed` example exercises the opt-in `bytes` adapters, so it only builds with
# `--features bytes` (default `cargo build`/`test` skip it; the others auto-discover).
[[]]
= "framed"
= ["bytes"]
[[]]
= "bytes_frame"
= ["bytes"]
# `tokio_framed` (TCP) and `tokio_udp` (UDP) drive `bnb::BinCodec`; gated on `tokio` so default
# builds skip them (and the heavy async deps).
[[]]
= "tokio_framed"
= ["tokio"]
[[]]
= "tokio_udp"
= ["tokio"]
# `sockets` and `unix_stream` show the `net` feature's helpers (`MessageStream`/`MessageDatagram`).
[[]]
= "sockets"
= ["net"]
[[]]
= "unix_stream"
= ["net"]
# `mock_datagram`/`mock_stream` show testing `net` code with the `mock` feature's in-memory transports.
[[]]
= "mock_datagram"
= ["mock"]
[[]]
= "mock_stream"
= ["mock"]
[[]]
= "bitfield_bench"
= false
[[]]
= "bitstream_bench"
= false
[[]]
= "message_bench"
= false
[]
= true