pub struct ConstReader<'a> { /* private fields */ }Expand description
Const-friendly cursor for reading primitives out of a byte buffer.
Reads return slices borrowed from the underlying buffer, which keeps the
reader allocation-free; callers can .to_owned() if they need ownership.
Implementations§
Source§impl<'a> ConstReader<'a>
impl<'a> ConstReader<'a>
pub const fn new(buf: &'a [u8]) -> Self
pub const fn read_bytes(&mut self, n: usize) -> Option<&'a [u8]>
pub const fn read_u16_le(&mut self) -> Option<u16>
pub const fn read_u64_le(&mut self) -> Option<u64>
pub const fn read_str(&mut self) -> Option<&'a str>
Sourcepub const fn read_str_opt(&mut self) -> Option<Option<&'a str>>
pub const fn read_str_opt(&mut self) -> Option<Option<&'a str>>
Reads an optional string, encoding three states: None when the buffer
is exhausted, Some(None) for an absent string, and Some(Some(_)) for
a present string.
pub const fn skip(&mut self, n: usize) -> Option<()>
Auto Trait Implementations§
impl<'a> Freeze for ConstReader<'a>
impl<'a> RefUnwindSafe for ConstReader<'a>
impl<'a> Send for ConstReader<'a>
impl<'a> Sync for ConstReader<'a>
impl<'a> Unpin for ConstReader<'a>
impl<'a> UnsafeUnpin for ConstReader<'a>
impl<'a> UnwindSafe for ConstReader<'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