(mut val: usize, buf: &mut [u8; 4])
| 5 | /// Returns the slice within `buf` that holds the value. |
| 6 | #[allow(clippy::cast_possible_truncation)] |
| 7 | fn encode_vlq(mut val: usize, buf: &mut [u8; 4]) -> &[u8] { |
| 8 | macro_rules! step { |
| 9 | ($n:expr) => { |
| 10 | buf[$n] = if $n == 3 { |
| 11 | (val & (VAL_MASK as usize)) as u8 |
| 12 | } else { |
| 13 | val -= 1; |
| 14 | NEXT_MASK | (val & (VAL_MASK as usize)) as u8 |
| 15 | }; |
| 16 | val >>= 7; |
| 17 | if val == 0 { |
| 18 | return &buf[$n..]; |
| 19 | } |
| 20 | }; |
| 21 | } |
| 22 | |
| 23 | step!(3); |
| 24 | step!(2); |
| 25 | step!(1); |
| 26 | step!(0); |
| 27 | panic!("integer is too big") |
| 28 | } |
| 29 | |
| 30 | /// Encode the given collection of binary blobs in .blb format into `writer`. |
| 31 | /// Returns the encoded data together with a count of the number of blobs included in the index. |
no outgoing calls