pub struct Reader<'a> { /* private fields */ }Expand description
Cursor over a byte string.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub fn new(buf: &'a [u8]) -> Self
pub fn remaining(&self) -> usize
Sourcepub fn expect_end(&self, field: &'static str) -> Result<(), DecodeError>
pub fn expect_end(&self, field: &'static str) -> Result<(), DecodeError>
Assert the value consumed the whole buffer. Called at the end of every top-level decode: a decoder that stops early is reading a different shape than the encoder wrote, and silently ignoring the tail is how an ABI skew turns into wrong values instead of an error.
pub fn u8(&mut self, field: &'static str) -> Result<u8, DecodeError>
pub fn u16(&mut self, field: &'static str) -> Result<u16, DecodeError>
pub fn u32(&mut self, field: &'static str) -> Result<u32, DecodeError>
pub fn u64(&mut self, field: &'static str) -> Result<u64, DecodeError>
pub fn i64(&mut self, field: &'static str) -> Result<i64, DecodeError>
pub fn bool(&mut self, field: &'static str) -> Result<bool, DecodeError>
pub fn bytes(&mut self, field: &'static str) -> Result<Vec<u8>, DecodeError>
pub fn str(&mut self, field: &'static str) -> Result<String, DecodeError>
pub fn opt_str( &mut self, field: &'static str, ) -> Result<Option<String>, DecodeError>
pub fn opt_bytes( &mut self, field: &'static str, ) -> Result<Option<Vec<u8>>, DecodeError>
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