pub(crate) struct Cursor<'a> {
remaining: &'a [u8],
read_count: usize,
}
Expand description
A Cursor
contains a slice of a buffer and a read count.
Fields§
§remaining: &'a [u8]
Slice representing the remaining data to be read
read_count: usize
Number of already read bytes
Implementations§
source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
sourcepub(crate) const fn new(remaining: &'a [u8]) -> Self
pub(crate) const fn new(remaining: &'a [u8]) -> Self
Construct a new Cursor
from remaining data
pub(crate) fn peek(&self) -> Option<&u8>
pub(crate) fn read_be_u32(&mut self) -> Result<u32, Error>
sourcepub(crate) fn read_exact(&mut self, count: usize) -> Result<&'a [u8], Error>
pub(crate) fn read_exact(&mut self, count: usize) -> Result<&'a [u8], Error>
Read exactly count
bytes, reducing remaining data and incrementing read count
sourcepub(crate) fn read_tag(&mut self, tag: &[u8]) -> Result<(), Error>
pub(crate) fn read_tag(&mut self, tag: &[u8]) -> Result<(), Error>
Read bytes and compare them to the provided tag
sourcepub(crate) fn read_optional_tag(&mut self, tag: &[u8]) -> Result<bool, Error>
pub(crate) fn read_optional_tag(&mut self, tag: &[u8]) -> Result<bool, Error>
Read bytes if the remaining data is prefixed by the provided tag
sourcepub(crate) fn read_while<F: Fn(&u8) -> bool>(
&mut self,
f: F,
) -> Result<&'a [u8], Error>
pub(crate) fn read_while<F: Fn(&u8) -> bool>( &mut self, f: F, ) -> Result<&'a [u8], Error>
Read bytes as long as the provided predicate is true
pub(crate) fn read_int<T: FromStr<Err = ParseIntError>>( &mut self, ) -> Result<T, Error>
Trait Implementations§
impl<'a> Eq for Cursor<'a>
impl<'a> StructuralPartialEq for Cursor<'a>
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> 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