Struct Reader
pub struct Reader<'a> { /* private fields */ }Expand description
A buffer values are read from.
Implementations§
§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub fn take_bytes(&mut self, len: usize) -> Result<&'a [u8], WireError>
pub fn take_bytes(&mut self, len: usize) -> Result<&'a [u8], WireError>
Takes exactly len bytes, refusing a length beyond the remaining buffer.
pub fn take_len(&mut self, min: usize) -> Result<usize, WireError>
pub fn take_len(&mut self, min: usize) -> Result<usize, WireError>
A length read before items values of at least min bytes each: refused when the rest
of the buffer could not hold them, so no allocation outruns its input.
pub fn take<T>(&mut self) -> Result<T, WireError>where
T: Wire,
pub fn take<T>(&mut self) -> Result<T, WireError>where
T: Wire,
Decodes one value from the current position.
pub fn bounded<T>(
&mut self,
max_bytes: usize,
read: impl FnOnce(&mut Reader<'a>) -> Result<T, WireError>,
) -> Result<T, WireError>
pub fn bounded<T>( &mut self, max_bytes: usize, read: impl FnOnce(&mut Reader<'a>) -> Result<T, WireError>, ) -> Result<T, WireError>
Read one value from at most max_bytes, preserving the enclosing reader’s depth and
leaving the following value untouched. No nested allocation can outrun this byte window.
pub fn list_with<T>(
&mut self,
max_items: usize,
read: impl FnMut(&mut Reader<'a>) -> Result<T, WireError>,
) -> Result<Vec<T>, WireError>where
T: Wire,
pub fn list_with<T>(
&mut self,
max_items: usize,
read: impl FnMut(&mut Reader<'a>) -> Result<T, WireError>,
) -> Result<Vec<T>, WireError>where
T: Wire,
A normal Wire list, with its element cap checked before allocating storage. read
may impose a shared payload budget across its elements without a second list codec.
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