pub struct Reader<'a> {
pub pos: usize,
/* private fields */
}Fields§
§pos: usizeImplementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub fn new(data: &'a [u8]) -> Self
pub fn data(&self) -> &'a [u8] ⓘ
pub fn eof(&self) -> bool
pub fn remaining(&self) -> usize
Sourcepub fn varint(&mut self) -> Result<u64>
pub fn varint(&mut self) -> Result<u64>
Read an unsigned varint, up to 10 bytes (uint64 range).
pub fn fixed32(&mut self) -> Result<u32>
pub fn fixed64(&mut self) -> Result<u64>
pub fn float(&mut self) -> Result<f32>
pub fn double(&mut self) -> Result<f64>
Sourcepub fn bytes_view(&mut self) -> Result<&'a [u8]>
pub fn bytes_view(&mut self) -> Result<&'a [u8]>
Length-prefixed bytes; returns a borrow into the underlying buffer.
Guards against attacker-supplied length-prefix overflow per
HARDENING.md §API contract item 3: a 10-byte varint of 2^64-1
would wrap pos + len to a small value and slip past a naive
bounds check, then trip a slice-indexing panic. Compute the end
offset with checked_add and reject before slicing.
Auto Trait Implementations§
impl<'a> Freeze for Reader<'a>
impl<'a> RefUnwindSafe for Reader<'a>
impl<'a> Send for Reader<'a>
impl<'a> Sync for Reader<'a>
impl<'a> Unpin for Reader<'a>
impl<'a> UnsafeUnpin for Reader<'a>
impl<'a> UnwindSafe for Reader<'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