• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vigna / dsi-bitstream-rs / 22237719643

20 Feb 2026 07:16PM UTC coverage: 54.824% (-0.5%) from 55.302%
22237719643

push

github

vigna
Cosmetic changes

2108 of 3845 relevant lines covered (54.82%)

3125840.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.83
/src/dispatch/codes.rs
1
/*
2
 * SPDX-FileCopyrightText: 2025 Tommaso Fontana
3
 * SPDX-FileCopyrightText: 2025 Inria
4
 * SPDX-FileCopyrightText: 2025 Sebastiano Vigna
5
 *
6
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
7
 */
8

9
//! Enumeration of all available codes, with associated read and write methods.
10
//!
11
//! This is the slower and more generic form of dispatching, mostly used for
12
//! testing and writing examples. For faster dispatching, consider using
13
//! [dynamic] or [static] dispatch.
14

15
use super::*;
16
#[cfg(feature = "mem_dbg")]
17
use mem_dbg::{MemDbg, MemSize};
18

19
#[derive(Debug, Clone, Copy, Eq)]
20
#[cfg_attr(feature = "mem_dbg", derive(MemDbg, MemSize))]
21
#[cfg_attr(feature = "mem_dbg", mem_size_flat)]
22
#[cfg_attr(feature = "fuzz", derive(arbitrary::Arbitrary))]
23
#[non_exhaustive]
24
/// An enum whose variants represent all the available codes.
25
///
26
/// This enum is kept in sync with implementations in the
27
/// [`codes`](crate::codes) module.
28
///
29
/// Both [`Display`](std::fmt::Display) and [`FromStr`](std::str::FromStr) are
30
/// implemented for this enum in a dual way, which makes it possible to store a
31
/// code as a string in a configuration file, and then parse it back.
32
pub enum Codes {
33
    Unary,
34
    Gamma,
35
    Delta,
36
    Omega,
37
    VByteLe,
38
    VByteBe,
39
    Zeta(usize),
40
    Pi(usize),
41
    Golomb(u64),
42
    ExpGolomb(usize),
43
    Rice(usize),
44
}
45

46
/// Some codes are equivalent, so we implement [`PartialEq`] to make them
47
/// interchangeable so `Codes::Unary == Codes::Rice(0)`.
48
impl PartialEq for Codes {
49
    fn eq(&self, other: &Self) -> bool {
×
50
        match (self, other) {
×
51
            // First we check the equivalence classes
52
            (
53
                Self::Unary | Self::Rice(0) | Self::Golomb(1),
54
                Self::Unary | Self::Rice(0) | Self::Golomb(1),
55
            ) => true,
×
56
            (
57
                Self::Gamma | Self::Zeta(1) | Self::ExpGolomb(0),
58
                Self::Gamma | Self::Zeta(1) | Self::ExpGolomb(0),
59
            ) => true,
×
60
            (Self::Golomb(2) | Self::Rice(1), Self::Golomb(2) | Self::Rice(1)) => true,
×
61
            (Self::Golomb(4) | Self::Rice(2), Self::Golomb(4) | Self::Rice(2)) => true,
×
62
            (Self::Golomb(8) | Self::Rice(3), Self::Golomb(8) | Self::Rice(3)) => true,
×
63
            // we know that we are not in a special case, so we can directly
64
            // compare them naively
65
            (Self::Delta, Self::Delta) => true,
×
66
            (Self::Omega, Self::Omega) => true,
×
67
            (Self::VByteLe, Self::VByteLe) => true,
×
68
            (Self::VByteBe, Self::VByteBe) => true,
×
69
            (Self::Zeta(k), Self::Zeta(k2)) => k == k2,
×
70
            (Self::Pi(k), Self::Pi(k2)) => k == k2,
×
71
            (Self::Golomb(b), Self::Golomb(b2)) => b == b2,
×
72
            (Self::ExpGolomb(k), Self::ExpGolomb(k2)) => k == k2,
×
73
            (Self::Rice(log2_b), Self::Rice(log2_b2)) => log2_b == log2_b2,
×
74
            _ => false,
×
75
        }
76
    }
77
}
78

79
impl Codes {
80
    /// Delegates to the [`DynamicCodeRead`] implementation.
81
    ///
82
    /// This inherent method is provided to reduce ambiguity in method
83
    /// resolution.
84
    #[inline(always)]
85
    pub fn read<E: Endianness, CR: CodesRead<E> + ?Sized>(
×
86
        &self,
87
        reader: &mut CR,
88
    ) -> Result<u64, CR::Error> {
89
        DynamicCodeRead::read(self, reader)
×
90
    }
91

92
    /// Delegates to the [`DynamicCodeWrite`] implementation.
93
    ///
94
    /// This inherent method is provided to reduce ambiguity in method
95
    /// resolution.
96
    #[inline(always)]
97
    pub fn write<E: Endianness, CW: CodesWrite<E> + ?Sized>(
×
98
        &self,
99
        writer: &mut CW,
100
        value: u64,
101
    ) -> Result<usize, CW::Error> {
102
        DynamicCodeWrite::write(self, writer, value)
×
103
    }
104

105
    /// Converts a code to the constant enum [`code_consts`] used for [`ConstCode`].
106
    /// This is mostly used to verify that the code is supported by
107
    /// [`ConstCode`].
108
    pub fn to_code_const(&self) -> Result<usize> {
×
109
        Ok(match self {
×
110
            Self::Unary => code_consts::UNARY,
×
111
            Self::Gamma => code_consts::GAMMA,
×
112
            Self::Delta => code_consts::DELTA,
×
113
            Self::Omega => code_consts::OMEGA,
×
114
            Self::VByteLe => code_consts::VBYTE_LE,
×
115
            Self::VByteBe => code_consts::VBYTE_BE,
×
116
            Self::Zeta(1) => code_consts::ZETA1,
×
117
            Self::Zeta(2) => code_consts::ZETA2,
×
118
            Self::Zeta(3) => code_consts::ZETA3,
×
119
            Self::Zeta(4) => code_consts::ZETA4,
×
120
            Self::Zeta(5) => code_consts::ZETA5,
×
121
            Self::Zeta(6) => code_consts::ZETA6,
×
122
            Self::Zeta(7) => code_consts::ZETA7,
×
123
            Self::Zeta(8) => code_consts::ZETA8,
×
124
            Self::Zeta(9) => code_consts::ZETA9,
×
125
            Self::Zeta(10) => code_consts::ZETA10,
×
126
            Self::Rice(0) => code_consts::RICE0,
×
127
            Self::Rice(1) => code_consts::RICE1,
×
128
            Self::Rice(2) => code_consts::RICE2,
×
129
            Self::Rice(3) => code_consts::RICE3,
×
130
            Self::Rice(4) => code_consts::RICE4,
×
131
            Self::Rice(5) => code_consts::RICE5,
×
132
            Self::Rice(6) => code_consts::RICE6,
×
133
            Self::Rice(7) => code_consts::RICE7,
×
134
            Self::Rice(8) => code_consts::RICE8,
×
135
            Self::Rice(9) => code_consts::RICE9,
×
136
            Self::Rice(10) => code_consts::RICE10,
×
137
            Self::Pi(0) => code_consts::PI0,
×
138
            Self::Pi(1) => code_consts::PI1,
×
139
            Self::Pi(2) => code_consts::PI2,
×
140
            Self::Pi(3) => code_consts::PI3,
×
141
            Self::Pi(4) => code_consts::PI4,
×
142
            Self::Pi(5) => code_consts::PI5,
×
143
            Self::Pi(6) => code_consts::PI6,
×
144
            Self::Pi(7) => code_consts::PI7,
×
145
            Self::Pi(8) => code_consts::PI8,
×
146
            Self::Pi(9) => code_consts::PI9,
×
147
            Self::Pi(10) => code_consts::PI10,
×
148
            Self::Golomb(1) => code_consts::GOLOMB1,
×
149
            Self::Golomb(2) => code_consts::GOLOMB2,
×
150
            Self::Golomb(3) => code_consts::GOLOMB3,
×
151
            Self::Golomb(4) => code_consts::GOLOMB4,
×
152
            Self::Golomb(5) => code_consts::GOLOMB5,
×
153
            Self::Golomb(6) => code_consts::GOLOMB6,
×
154
            Self::Golomb(7) => code_consts::GOLOMB7,
×
155
            Self::Golomb(8) => code_consts::GOLOMB8,
×
156
            Self::Golomb(9) => code_consts::GOLOMB9,
×
157
            Self::Golomb(10) => code_consts::GOLOMB10,
×
158
            Self::ExpGolomb(0) => code_consts::EXP_GOLOMB0,
×
159
            Self::ExpGolomb(1) => code_consts::EXP_GOLOMB1,
×
160
            Self::ExpGolomb(2) => code_consts::EXP_GOLOMB2,
×
161
            Self::ExpGolomb(3) => code_consts::EXP_GOLOMB3,
×
162
            Self::ExpGolomb(4) => code_consts::EXP_GOLOMB4,
×
163
            Self::ExpGolomb(5) => code_consts::EXP_GOLOMB5,
×
164
            Self::ExpGolomb(6) => code_consts::EXP_GOLOMB6,
×
165
            Self::ExpGolomb(7) => code_consts::EXP_GOLOMB7,
×
166
            Self::ExpGolomb(8) => code_consts::EXP_GOLOMB8,
×
167
            Self::ExpGolomb(9) => code_consts::EXP_GOLOMB9,
×
168
            Self::ExpGolomb(10) => code_consts::EXP_GOLOMB10,
×
169
            _ => {
170
                return Err(anyhow::anyhow!(
×
171
                    "Code {:?} not supported as const code",
×
172
                    self
×
173
                ));
174
            }
175
        })
176
    }
177

178
    /// Converts a value from [`code_consts`] to a code.
179
    pub fn from_code_const(const_code: usize) -> Result<Self> {
×
180
        Ok(match const_code {
×
181
            code_consts::UNARY => Self::Unary,
×
182
            code_consts::GAMMA => Self::Gamma,
×
183
            code_consts::DELTA => Self::Delta,
×
184
            code_consts::OMEGA => Self::Omega,
×
185
            code_consts::VBYTE_LE => Self::VByteLe,
×
186
            code_consts::VBYTE_BE => Self::VByteBe,
×
187
            code_consts::ZETA2 => Self::Zeta(2),
×
188
            code_consts::ZETA3 => Self::Zeta(3),
×
189
            code_consts::ZETA4 => Self::Zeta(4),
×
190
            code_consts::ZETA5 => Self::Zeta(5),
×
191
            code_consts::ZETA6 => Self::Zeta(6),
×
192
            code_consts::ZETA7 => Self::Zeta(7),
×
193
            code_consts::ZETA8 => Self::Zeta(8),
×
194
            code_consts::ZETA9 => Self::Zeta(9),
×
195
            code_consts::ZETA10 => Self::Zeta(10),
×
196
            code_consts::RICE1 => Self::Rice(1),
×
197
            code_consts::RICE2 => Self::Rice(2),
×
198
            code_consts::RICE3 => Self::Rice(3),
×
199
            code_consts::RICE4 => Self::Rice(4),
×
200
            code_consts::RICE5 => Self::Rice(5),
×
201
            code_consts::RICE6 => Self::Rice(6),
×
202
            code_consts::RICE7 => Self::Rice(7),
×
203
            code_consts::RICE8 => Self::Rice(8),
×
204
            code_consts::RICE9 => Self::Rice(9),
×
205
            code_consts::RICE10 => Self::Rice(10),
×
206
            code_consts::PI1 => Self::Pi(1),
×
207
            code_consts::PI2 => Self::Pi(2),
×
208
            code_consts::PI3 => Self::Pi(3),
×
209
            code_consts::PI4 => Self::Pi(4),
×
210
            code_consts::PI5 => Self::Pi(5),
×
211
            code_consts::PI6 => Self::Pi(6),
×
212
            code_consts::PI7 => Self::Pi(7),
×
213
            code_consts::PI8 => Self::Pi(8),
×
214
            code_consts::PI9 => Self::Pi(9),
×
215
            code_consts::PI10 => Self::Pi(10),
×
216
            code_consts::GOLOMB3 => Self::Golomb(3),
×
217
            code_consts::GOLOMB5 => Self::Golomb(5),
×
218
            code_consts::GOLOMB6 => Self::Golomb(6),
×
219
            code_consts::GOLOMB7 => Self::Golomb(7),
×
220
            code_consts::GOLOMB9 => Self::Golomb(9),
×
221
            code_consts::GOLOMB10 => Self::Golomb(10),
×
222
            code_consts::EXP_GOLOMB1 => Self::ExpGolomb(1),
×
223
            code_consts::EXP_GOLOMB2 => Self::ExpGolomb(2),
×
224
            code_consts::EXP_GOLOMB3 => Self::ExpGolomb(3),
×
225
            code_consts::EXP_GOLOMB4 => Self::ExpGolomb(4),
×
226
            code_consts::EXP_GOLOMB5 => Self::ExpGolomb(5),
×
227
            code_consts::EXP_GOLOMB6 => Self::ExpGolomb(6),
×
228
            code_consts::EXP_GOLOMB7 => Self::ExpGolomb(7),
×
229
            code_consts::EXP_GOLOMB8 => Self::ExpGolomb(8),
×
230
            code_consts::EXP_GOLOMB9 => Self::ExpGolomb(9),
×
231
            code_consts::EXP_GOLOMB10 => Self::ExpGolomb(10),
×
232
            _ => return Err(anyhow::anyhow!("Code {} not supported", const_code)),
×
233
        })
234
    }
235
}
236

237
impl DynamicCodeRead for Codes {
238
    #[inline]
239
    fn read<E: Endianness, CR: CodesRead<E> + ?Sized>(
230,064✔
240
        &self,
241
        reader: &mut CR,
242
    ) -> Result<u64, CR::Error> {
243
        Ok(match self {
230,064✔
244
            Codes::Unary => reader.read_unary()?,
8,192✔
245
            Codes::Gamma => reader.read_gamma()?,
8,712✔
246
            Codes::Delta => reader.read_delta()?,
8,712✔
247
            Codes::Omega => reader.read_omega()?,
8,712✔
248
            Codes::VByteBe => reader.read_vbyte_be()?,
8,720✔
249
            Codes::VByteLe => reader.read_vbyte_le()?,
8,720✔
250
            Codes::Zeta(3) => reader.read_zeta3()?,
8,712✔
251
            Codes::Zeta(k) => reader.read_zeta(*k)?,
139,392✔
252
            Codes::Pi(2) => reader.read_pi2()?,
8,712✔
253
            Codes::Pi(k) => reader.read_pi(*k)?,
156,816✔
254
            Codes::Golomb(b) => reader.read_golomb(*b)?,
147,504✔
255
            Codes::ExpGolomb(k) => reader.read_exp_golomb(*k)?,
174,272✔
256
            Codes::Rice(log2_b) => reader.read_rice(*log2_b)?,
163,888✔
257
        })
258
    }
259
}
260

261
impl DynamicCodeWrite for Codes {
262
    #[inline]
263
    fn write<E: Endianness, CW: CodesWrite<E> + ?Sized>(
230,064✔
264
        &self,
265
        writer: &mut CW,
266
        value: u64,
267
    ) -> Result<usize, CW::Error> {
268
        Ok(match self {
230,064✔
269
            Codes::Unary => writer.write_unary(value)?,
12,288✔
270
            Codes::Gamma => writer.write_gamma(value)?,
13,068✔
271
            Codes::Delta => writer.write_delta(value)?,
13,068✔
272
            Codes::Omega => writer.write_omega(value)?,
13,068✔
273
            Codes::VByteBe => writer.write_vbyte_be(value)?,
13,080✔
274
            Codes::VByteLe => writer.write_vbyte_le(value)?,
13,080✔
275
            Codes::Zeta(1) => writer.write_gamma(value)?,
13,068✔
276
            Codes::Zeta(3) => writer.write_zeta3(value)?,
13,068✔
277
            Codes::Zeta(k) => writer.write_zeta(value, *k)?,
152,460✔
278
            Codes::Pi(2) => writer.write_pi2(value)?,
13,068✔
279
            Codes::Pi(k) => writer.write_pi(value, *k)?,
196,020✔
280
            Codes::Golomb(b) => writer.write_golomb(value, *b)?,
184,380✔
281
            Codes::ExpGolomb(k) => writer.write_exp_golomb(value, *k)?,
217,840✔
282
            Codes::Rice(log2_b) => writer.write_rice(value, *log2_b)?,
204,860✔
283
        })
284
    }
285
}
286

287
impl<E: Endianness, CR: CodesRead<E> + ?Sized> StaticCodeRead<E, CR> for Codes {
288
    #[inline(always)]
289
    fn read(&self, reader: &mut CR) -> Result<u64, CR::Error> {
115,032✔
290
        <Self as DynamicCodeRead>::read(self, reader)
345,096✔
291
    }
292
}
293

294
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> StaticCodeWrite<E, CW> for Codes {
295
    #[inline(always)]
296
    fn write(&self, writer: &mut CW, value: u64) -> Result<usize, CW::Error> {
115,032✔
297
        <Self as DynamicCodeWrite>::write(self, writer, value)
460,128✔
298
    }
299
}
300

301
impl CodeLen for Codes {
302
    #[inline]
303
    fn len(&self, value: u64) -> usize {
230,064✔
304
        match self {
230,064✔
305
            Codes::Unary => value as usize + 1,
4,096✔
306
            Codes::Gamma => len_gamma(value),
8,712✔
307
            Codes::Delta => len_delta(value),
8,712✔
308
            Codes::Omega => len_omega(value),
8,712✔
309
            Codes::VByteLe | Codes::VByteBe => bit_len_vbyte(value),
17,440✔
310
            Codes::Zeta(1) => len_gamma(value),
8,712✔
311
            Codes::Zeta(k) => len_zeta(value, *k),
139,392✔
312
            Codes::Pi(k) => len_pi(value, *k),
174,240✔
313
            Codes::Golomb(b) => len_golomb(value, *b),
147,504✔
314
            Codes::ExpGolomb(k) => len_exp_golomb(value, *k),
174,272✔
315
            Codes::Rice(log2_b) => len_rice(value, *log2_b),
163,888✔
316
        }
317
    }
318
}
319

320
#[derive(Debug, Clone)]
321
/// Error type for parsing a code from a string.
322
pub enum CodeError {
323
    /// Error parsing an integer parameter.
324
    ParseError(core::num::ParseIntError),
325
    /// Unknown code name. Uses a fixed-size array instead of `String` for `no_std` compatibility.
326
    UnknownCode([u8; 32]),
327
}
328
#[cfg(feature = "std")]
329
impl std::error::Error for CodeError {}
330
impl core::fmt::Display for CodeError {
331
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
×
332
        match self {
×
333
            CodeError::ParseError(e) => write!(f, "Parse error: {}", e),
×
334
            CodeError::UnknownCode(s) => {
×
335
                write!(f, "Unknown code: ")?;
×
336
                for c in s {
×
337
                    if *c == 0 {
×
338
                        break;
×
339
                    }
340
                    write!(f, "{}", *c as char)?;
×
341
                }
342
                Ok(())
×
343
            }
344
        }
345
    }
346
}
347

348
impl From<core::num::ParseIntError> for CodeError {
349
    fn from(e: core::num::ParseIntError) -> Self {
×
350
        CodeError::ParseError(e)
×
351
    }
352
}
353

354
impl core::fmt::Display for Codes {
355
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
×
356
        match self {
×
357
            Codes::Unary => write!(f, "Unary"),
×
358
            Codes::Gamma => write!(f, "Gamma"),
×
359
            Codes::Delta => write!(f, "Delta"),
×
360
            Codes::Omega => write!(f, "Omega"),
×
361
            Codes::VByteBe => write!(f, "VByteBe"),
×
362
            Codes::VByteLe => write!(f, "VByteLe"),
×
363
            Codes::Zeta(k) => write!(f, "Zeta({})", k),
×
364
            Codes::Pi(k) => write!(f, "Pi({})", k),
×
365
            Codes::Golomb(b) => write!(f, "Golomb({})", b),
×
366
            Codes::ExpGolomb(k) => write!(f, "ExpGolomb({})", k),
×
367
            Codes::Rice(log2_b) => write!(f, "Rice({})", log2_b),
×
368
        }
369
    }
370
}
371

372
fn array_format_error(s: &str) -> [u8; 32] {
×
373
    let mut error_buffer = [0u8; 32];
×
374
    const ERROR_PREFIX: &[u8] = b"Could not parse ";
375
    error_buffer[..ERROR_PREFIX.len()].copy_from_slice(ERROR_PREFIX);
×
376
    error_buffer[ERROR_PREFIX.len()..ERROR_PREFIX.len() + s.len().min(32 - ERROR_PREFIX.len())]
×
377
        .copy_from_slice(&s.as_bytes()[..s.len().min(32 - ERROR_PREFIX.len())]);
×
378
    error_buffer
×
379
}
380

381
impl core::str::FromStr for Codes {
382
    type Err = CodeError;
383

384
    fn from_str(s: &str) -> Result<Self, Self::Err> {
×
385
        match s {
×
386
            "Unary" => Ok(Codes::Unary),
×
387
            "Gamma" => Ok(Codes::Gamma),
×
388
            "Delta" => Ok(Codes::Delta),
×
389
            "Omega" => Ok(Codes::Omega),
×
390
            "VByteBe" => Ok(Codes::VByteBe),
×
391
            "VByteLe" => Ok(Codes::VByteLe),
×
392

393
            _ => {
394
                let mut parts = s.split('(');
×
395
                let name = parts
×
396
                    .next()
397
                    .ok_or_else(|| CodeError::UnknownCode(array_format_error(s)))?;
×
398
                let k = parts
×
399
                    .next()
400
                    .ok_or_else(|| CodeError::UnknownCode(array_format_error(s)))?
×
401
                    .split(')')
402
                    .next()
403
                    .ok_or_else(|| CodeError::UnknownCode(array_format_error(s)))?;
×
404
                match name {
×
405
                    "Zeta" => Ok(Codes::Zeta(k.parse()?)),
×
406
                    "Pi" => Ok(Codes::Pi(k.parse()?)),
×
407
                    "Golomb" => Ok(Codes::Golomb(k.parse()?)),
×
408
                    "ExpGolomb" => Ok(Codes::ExpGolomb(k.parse()?)),
×
409
                    "Rice" => Ok(Codes::Rice(k.parse()?)),
×
410
                    _ => Err(CodeError::UnknownCode(array_format_error(name))),
×
411
                }
412
            }
413
        }
414
    }
415
}
416

417
#[cfg(feature = "serde")]
418
impl serde::Serialize for Codes {
419
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
×
420
    where
421
        S: serde::Serializer,
422
    {
423
        serializer.serialize_str(&self.to_string())
×
424
    }
425
}
426

427
#[cfg(feature = "serde")]
428
impl<'de> serde::Deserialize<'de> for Codes {
429
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
×
430
    where
431
        D: serde::Deserializer<'de>,
432
    {
433
        let s = String::deserialize(deserializer)?;
×
434
        s.parse().map_err(serde::de::Error::custom)
×
435
    }
436
}
437

438
/// Structure representing minimal binary coding with a fixed length.
439
///
440
/// [Minimal binary coding](crate::codes::minimal_binary) does not
441
/// fit the [`Codes`] enum because it is not defined for all integers.
442
///
443
/// Instances of this structure can be used in context in which a
444
/// [`DynamicCodeRead`], [`DynamicCodeWrite`], [`StaticCodeRead`],
445
/// [`StaticCodeWrite`] or [`CodeLen`] implementing minimal binary coding
446
/// is necessary.
447
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
448
pub struct MinimalBinary(pub u64);
449

450
impl DynamicCodeRead for MinimalBinary {
451
    fn read<E: Endianness, R: CodesRead<E> + ?Sized>(
48✔
452
        &self,
453
        reader: &mut R,
454
    ) -> Result<u64, R::Error> {
455
        reader.read_minimal_binary(self.0)
144✔
456
    }
457
}
458

459
impl DynamicCodeWrite for MinimalBinary {
460
    fn write<E: Endianness, W: CodesWrite<E> + ?Sized>(
48✔
461
        &self,
462
        writer: &mut W,
463
        n: u64,
464
    ) -> Result<usize, W::Error> {
465
        writer.write_minimal_binary(n, self.0)
192✔
466
    }
467
}
468

469
impl<E: Endianness, CR: CodesRead<E> + ?Sized> StaticCodeRead<E, CR> for MinimalBinary {
470
    fn read(&self, reader: &mut CR) -> Result<u64, CR::Error> {
24✔
471
        <Self as DynamicCodeRead>::read(self, reader)
72✔
472
    }
473
}
474

475
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> StaticCodeWrite<E, CW> for MinimalBinary {
476
    fn write(&self, writer: &mut CW, n: u64) -> Result<usize, CW::Error> {
24✔
477
        <Self as DynamicCodeWrite>::write(self, writer, n)
96✔
478
    }
479
}
480

481
impl CodeLen for MinimalBinary {
482
    fn len(&self, n: u64) -> usize {
48✔
483
        len_minimal_binary(n, self.0)
144✔
484
    }
485
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc