pub struct ByteReader<'a> { /* private fields */ }Expand description
Byte-aligned, forward-scanning cursor over a &[u8] buffer.
ByteReader is used to walk the outer demo command stream — the
sequence of (cmd, tick, size, body) tuples that make up a .dem file
after the 16-byte file header. All multi-byte integers are little-endian,
and variable-length integers use protobuf-style LEB128 encoding.
For bit-level access inside decompressed packet payloads, see
BitReader.
Implementations§
Source§impl<'a> ByteReader<'a>
impl<'a> ByteReader<'a>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true when the cursor is at or past the end of the buffer.
Sourcepub fn seek(&mut self, position: usize) -> Result<()>
pub fn seek(&mut self, position: usize) -> Result<()>
Move the cursor to an absolute byte position.
Returns Error::Overflow if position exceeds the buffer length.
Sourcepub fn read_u16(&mut self) -> Result<u16>
pub fn read_u16(&mut self) -> Result<u16>
Read a little-endian u16 and advance the cursor by 2 bytes.
Sourcepub fn read_u32(&mut self) -> Result<u32>
pub fn read_u32(&mut self) -> Result<u32>
Read a little-endian u32 and advance the cursor by 4 bytes.
Sourcepub fn read_i32(&mut self) -> Result<i32>
pub fn read_i32(&mut self) -> Result<i32>
Read a little-endian i32 and advance the cursor by 4 bytes.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
Borrow n bytes starting at the cursor and advance past them.
Sourcepub fn read_uvarint32(&mut self) -> Result<u32>
pub fn read_uvarint32(&mut self) -> Result<u32>
Read a protobuf-style unsigned varint (up to 32 bits / 5 bytes).
Sourcepub fn read_uvarint64(&mut self) -> Result<u64>
pub fn read_uvarint64(&mut self) -> Result<u64>
Read a protobuf-style unsigned varint (up to 64 bits / 10 bytes).