Struct concordium_std::Cursor
source · pub struct Cursor<T> {
pub offset: usize,
pub data: T,
}
Expand description
Add offset tracking inside a data structure.
Fields§
§offset: usize
§data: T
Implementations§
Trait Implementations§
source§impl<T> Read for Cursor<T>
impl<T> Read for Cursor<T>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, ParseError>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, ParseError>
Read a number of bytes into the provided buffer. The returned value is
Ok(n)
if a read was successful, and n
bytes were read (n
could be
0).source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ParseError>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ParseError>
Read exactly the required number of bytes. If not enough bytes could be
read the function returns
Err(_)
, and the contents of the given buffer
is unspecified.source§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], ParseError>
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], ParseError>
Load an array of the given size.
source§impl Write for Cursor<&mut Vec<u8>>
impl Write for Cursor<&mut Vec<u8>>
type Err = ()
source§fn write(
&mut self,
buf: &[u8]
) -> Result<usize, <Cursor<&mut Vec<u8>> as Write>::Err>
fn write( &mut self, buf: &[u8] ) -> Result<usize, <Cursor<&mut Vec<u8>> as Write>::Err>
Try to write the given buffer into the output stream. If writes are
successful returns the number of bytes written.
Auto Trait Implementations§
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