pub struct Cursor<'a> { /* private fields */ }Expand description
A cursor over a byte slice, tracking the current read position.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn capacity_hint(&self, count: u32) -> usize
pub fn capacity_hint(&self, count: u32) -> usize
Pre-allocation capacity for count entries yet to be parsed.
Malformed binaries can declare counts in the billions; blindly
trusting them in Vec::with_capacity turns a tiny input into a
multi-gigabyte allocation. Every entry needs at least one byte in
the stream, so the remaining input length is a sound upper bound.
Sourcepub fn read_byte(&mut self) -> Result<u8, DecodeError>
pub fn read_byte(&mut self) -> Result<u8, DecodeError>
Read a single byte, advancing the cursor.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], DecodeError>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], DecodeError>
Read exactly n bytes as a slice, advancing the cursor.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Send for Cursor<'a>
impl<'a> Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnsafeUnpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
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