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
//! bzip2 (`.bz2`).
//!
//! Block-sorted compression: each block runs raw input through a
//! pipeline of RLE-1 → Burrows–Wheeler transform → move-to-front →
//! RLE-2 → multi-table canonical-Huffman → MSB-first bit packing. The
//! result is wrapped in a `"BZh<level>"` stream header, one or more
//! block payloads keyed off the `0x31_4159_2653_59` ("1AY&SY") magic,
//! and a `0x17_7245_3850_90` ("sqrt(pi)") end-of-stream magic followed
//! by a combined CRC over all per-block CRC-32/MPEG-2 values
//! (rotate-left-then-XOR accumulation).
//!
//! ## Module split
//!
//! - [`bits`](self#bit-readerwriter) — MSB-first bit reader/writer
//! (separate from `crate::bits`, which is LSB-first for deflate).
//! - [`crc`](self#crc-32mpeg-2) — CRC-32/MPEG-2 implementation
//! (non-reflected, no final XOR).
//! - [`huffman`](self#canonical-huffman) — canonical Huffman code
//! construction (encoder) and prefix-code decode tables (decoder),
//! limited to 20 bits.
//! - [`bwt`](self#burrowswheeler) — forward (naive O(n² log n) suffix
//! sort) and inverse (classic O(n) permutation walk) BWT.
//! - [`mtf`](self#move-to-front) — MTF over a reduced byte alphabet.
//! - [`rle`](self#rle) — RLE-1 (raw-byte pre-pass, runs of 4+
//! compressed into 4 copies + count) and RLE-2 (post-MTF zero-run
//! coding via RUNA/RUNB).
//! - `encoder` / `decoder` — the streaming state machines.
//!
//! ## Round-trip status
//!
//! Both directions work on arbitrary input. The encoder is correctness
//! first, not byte-for-byte compatible with reference `bzip2 -c`: it
//! picks slightly different (still valid) selectors and table
//! frequencies. Streams produced here decompress cleanly with system
//! `bunzip2`, and our decoder accepts arbitrary system-`bzip2`-produced
//! streams.
//!
//! ## Concatenated streams
//!
//! Single-stream only in this build. Concatenated bzip2 streams
//! (`cat a.bz2 b.bz2`) are not yet supported on the decode side; the
//! decoder treats the second stream's header magic as garbage and
//! stops at the first stream's end-of-stream trailer.
use crateError as _Error;
use crateAlgorithm;
// Silence "unused" if a downstream branch ever decouples; the public
// surface is re-exported below.
use _Error as _;
pub use Decoder;
pub use ;
/// Zero-sized marker type implementing [`Algorithm`] for bzip2.
;