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
//! Internal hybrid codec dispatcher for variable-length integer codes.
//!
//! This module provides `CodecReader`, a two-stage dispatcher that optimizes
//! reading from compressed bitstreams while maintaining compatibility with all
//! codecs supported by [`dsi-bitstream`](https://crates.io/crates/dsi-bitstream).
//!
//! The design prioritizes performance for common codecs while providing a robust
//! fallback for exotic parameter combinations, ensuring that any validly created
//! compressed vector can be read without panicking.
use ;
/// Type alias for bitstream readers operating on in-memory word buffers.
///
/// This reader type is used throughout the variable-length integer modules
/// for decoding compressed data. It is configured to:
/// - Read from memory ([`MemWordReader`])
/// - Use buffered bit-level access ([`BufBitReader`])
/// - Have infallible read operations (memory reads cannot fail)
pub type VarVecBitReader<'a, E> =
;
/// A hybrid dispatcher for reading compression codes.
///
/// This enum acts as a two-stage dispatcher to read values from a compressed
/// bitstream. It is designed to handle all valid codecs supported by
/// [`dsi-bitstream`](https://crates.io/crates/dsi-bitstream), ensuring
/// correctness while maximizing performance.
///
/// # Dispatch Strategy
///
/// 1. **Fast Path ([`CodecReader::Fast`])**: For common codecs (e.g., Gamma,
/// Delta, or Zeta with small parameters), [`dsi-bitstream`](https://crates.io/crates/dsi-bitstream)
/// provides pre-compiled function pointers via [`FuncCodeReader`]. This path
/// avoids the overhead of a `match` statement on every read operation, as the
/// correct function is resolved once at creation time.
///
/// 2. **Slow Path ([`CodecReader::Slow`])**: For codecs with parameters outside
/// of the pre-compiled set (e.g., `Golomb { b: 15 }`), the fast path is not
/// available. In this case, the dispatcher falls back to storing the [`Codes`]
/// enum variant directly. Each read operation then uses a `match` statement to
/// call the appropriate decoding function. While slightly slower due to the
/// runtime dispatch, this ensures that any validly created compressed vector
/// can be read.
///
/// This hybrid approach guarantees that the reader will never panic due to an
/// "unsupported code" error, which was a critical issue in previous implementations.
/// The [`new`](Self::new) constructor automatically selects the appropriate path.
///
/// # Type Parameters
///
/// - `E`: The endianness used for reading bits from the bitstream.
pub