(&mut self)
| 87 | } |
| 88 | |
| 89 | pub(crate) fn read_bit(&mut self) -> Result<bool, CodecError> { |
| 90 | let byte_idx = self.bit_pos / 8; |
| 91 | if byte_idx >= self.buf.len() { |
| 92 | return Err(CodecError::Truncated { |
| 93 | expected: byte_idx + 1, |
| 94 | actual: self.buf.len(), |
| 95 | }); |
| 96 | } |
| 97 | let bit_idx = 7 - (self.bit_pos % 8); |
| 98 | let bit = (self.buf[byte_idx] >> bit_idx) & 1 == 1; |
| 99 | self.bit_pos += 1; |
| 100 | Ok(bit) |
| 101 | } |
| 102 | |
| 103 | pub(crate) fn read_bits(&mut self, num_bits: usize) -> Result<u64, CodecError> { |
| 104 | let mut value = 0u64; |
no test coverage detected