(input: &mut &[u8])
| 17 | pub(super) const LENGTH: usize = 11; |
| 18 | |
| 19 | pub(super) fn get(input: &mut &[u8]) -> Result<u64> { |
| 20 | let mut n = 0; |
| 21 | for shift in (0..70).step_by(7) { |
| 22 | let (&b, rest) = input.split_first().context("truncated control varint")?; |
| 23 | *input = rest; |
| 24 | ensure!(shift != 63 || b <= 1, "control varint overflow"); |
| 25 | n |= u64::from(b & 127) << shift; |
| 26 | if b < 128 { |
| 27 | ensure!(shift == 0 || b != 0, "noncanonical control varint"); |
| 28 | return Ok(n); |
| 29 | } |
| 30 | } |
| 31 | anyhow::bail!("control varint overflow") |
| 32 | } |
| 33 | pub(super) trait Values { |
| 34 | fn value(&mut self, role: usize) -> Result<u64>; |
| 35 | } |
no test coverage detected