pub struct Cursor<'a> { /* private fields */ }Expand description
A zero-copy cursor over an in-memory byte slice.
Avoids std::io::Cursor and its wide error surface; only the two error
cases above can ever occur during TL deserialization.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn from_slice(buf: &'a [u8]) -> Self
pub fn from_slice(buf: &'a [u8]) -> Self
Create a cursor positioned at the start of buf.
Sourcepub fn read_exact(&mut self, out: &mut [u8]) -> Result<()>
pub fn read_exact(&mut self, out: &mut [u8]) -> Result<()>
Read exactly buf.len() bytes.
Sourcepub fn read_to_end(&mut self, out: &mut Vec<u8>) -> usize
pub fn read_to_end(&mut self, out: &mut Vec<u8>) -> usize
Consume all remaining bytes into out.
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Send for Cursor<'a>
impl<'a> Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnsafeUnpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'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