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
//! LEB128 varint coding for posting lists.
//!
//! Posting entries store fact-id *deltas*; lists are sorted by
//! construction (fact ids are assigned monotonically), so deltas are
//! small and most entries take 1 byte instead of 4.
/// Maximum encoded size of a `u32` (5 × 7 bits ≥ 32 bits).
pub const MAX_VARINT: usize = 5;
/// Encodes `v` into `out`, returning the number of bytes written (1..=5).
/// Decodes one `u32` from the front of `bytes`, returning the value and
/// the number of bytes consumed. `None` on truncated input or a value
/// that does not fit 32 bits (a 5th byte with more than 4 payload bits,
/// or a continuation bit on the 5th byte).