pub struct Reader<'a> { /* private fields */ }Expand description
A cursor over SML bytes. Never allocates and never panics.
Debug shows the position and length, never the bytes: they may hold credentials.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
Sourcepub fn slice(&self, from: usize, to: usize) -> Result<&'a [u8]>
pub fn slice(&self, from: usize, to: usize) -> Result<&'a [u8]>
The bytes between two positions of this reader.
Sourcepub fn end_of_message(&mut self) -> Result<()>
pub fn end_of_message(&mut self) -> Result<()>
Consume the end-of-message byte.
Sourcepub fn absent(&mut self) -> bool
pub fn absent(&mut self) -> bool
Consume an absent-field marker if one is next. Returns whether it was.
Sourcepub fn list(&mut self, n: usize) -> Result<()>
pub fn list(&mut self, n: usize) -> Result<()>
Read a list header and require exactly n elements.
Sourcepub fn list_any(&mut self) -> Result<usize>
pub fn list_any(&mut self) -> Result<usize>
Read a list header of any length and return the element count.
Sourcepub fn octet_string(&mut self) -> Result<&'a [u8]>
pub fn octet_string(&mut self) -> Result<&'a [u8]>
Read an octet string. An absent marker reads as an empty string.
Sourcepub fn opt_octet_string(&mut self) -> Result<Option<&'a [u8]>>
pub fn opt_octet_string(&mut self) -> Result<Option<&'a [u8]>>
Read an optional octet string.
Sourcepub fn opt_unsigned(&mut self) -> Result<Option<u64>>
pub fn opt_unsigned(&mut self) -> Result<Option<u64>>
Read an optional unsigned integer.
Sourcepub fn opt_integer(&mut self) -> Result<Option<i64>>
pub fn opt_integer(&mut self) -> Result<Option<i64>>
Read an optional signed integer.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Forget for Reader<'a>
impl<'a> Freeze for Reader<'a>
impl<'a> Move 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>where
&'a [u8]: UnsafeUnpin,
impl<'a> UnwindSafe for Reader<'a>where
&'a [u8]: UnwindSafe,
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