pub struct Cursor<T> { /* private fields */ }Expand description
Wraps an in memory buffer providing position functionality for read and write.
Implementations§
Source§impl<T: AsRef<[u8]>> Cursor<T>
impl<T: AsRef<[u8]>> Cursor<T>
Sourcepub fn set_position(&mut self, position: u64)
pub fn set_position(&mut self, position: u64)
Sets the internal position.
This method allows seeking within the wrapped memory by setting the position.
Note that setting a position that is larger than the buffer length will cause reads to succeed by reading zero bytes. Further, writes will be no-op zero length writes.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the inner buffer.
This is the whole wrapped buffer, including the bytes already read.
Sourcepub const fn get_ref(&self) -> &T
pub const fn get_ref(&self) -> &T
Returns a reference to the inner buffer.
This is the whole wrapped buffer, including the bytes already read.
Trait Implementations§
Source§impl<T: AsRef<[u8]>> Read for Cursor<T>
impl<T: AsRef<[u8]>> Read for Cursor<T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Reads bytes from source into
buf. Read moreSource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Reads bytes from source until
buf is full. Read moreSource§impl<T: AsMut<[u8]>> Write for Cursor<T>
impl<T: AsMut<[u8]>> Write for Cursor<T>
impl<T: Eq> Eq for Cursor<T>
impl<T> StructuralPartialEq for Cursor<T>
Auto Trait Implementations§
impl<T> Freeze for Cursor<T>where
T: Freeze,
impl<T> RefUnwindSafe for Cursor<T>where
T: RefUnwindSafe,
impl<T> Send for Cursor<T>where
T: Send,
impl<T> Sync for Cursor<T>where
T: Sync,
impl<T> Unpin for Cursor<T>where
T: Unpin,
impl<T> UnwindSafe for Cursor<T>where
T: 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