pub struct BitReader<'a> { /* private fields */ }Expand description
MSB-first bit reader with the same semantics as Prometheus’
chunkenc.bstreamReader.
Bits are consumed from the most significant end of each byte. Every read
either succeeds or reports crate::Error::Eof; a truncated chunk never
yields partially valid values.
Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
Sourcepub fn bits_left_hint(&self) -> usize
pub fn bits_left_hint(&self) -> usize
Upper bound on the bits still available, including buffered ones.
Sourcepub fn read_bits(&mut self, nbits: u8) -> Result<u64>
pub fn read_bits(&mut self, nbits: u8) -> Result<u64>
Reads nbits (0-64) bits into the low bits of the result.
Returns crate::Error::Decode for nbits > 64 and
crate::Error::Eof when the stream ends mid-read.
Sourcepub fn read_byte(&mut self) -> Result<u8>
pub fn read_byte(&mut self) -> Result<u8>
Reads a big-endian byte from the bit stream (Go’s ReadByte).
Sourcepub fn read_uvarint(&mut self) -> Result<u64>
pub fn read_uvarint(&mut self) -> Result<u64>
Go’s binary.ReadUvarint over the bit stream.
Sourcepub fn read_varint(&mut self) -> Result<i64>
pub fn read_varint(&mut self) -> Result<i64>
Go’s binary.ReadVarint (zig-zag).
Auto Trait Implementations§
impl<'a> Forget for BitReader<'a>
impl<'a> Freeze for BitReader<'a>
impl<'a> Move for BitReader<'a>
impl<'a> RefUnwindSafe for BitReader<'a>
impl<'a> Send for BitReader<'a>
impl<'a> Sync for BitReader<'a>
impl<'a> Unpin for BitReader<'a>
impl<'a> UnsafeUnpin for BitReader<'a>where
&'a [u8]: UnsafeUnpin,
impl<'a> UnwindSafe for BitReader<'a>where
&'a [u8]: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more