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>where
T: AsRef<[u8]>,
impl<T> Read for Cursor<T>where T: AsRef<[u8]>,
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, Global>>
impl Write for Cursor<&mut Vec<u8, Global>>
type Err = ()
source§fn write(
&mut self,
buf: &[u8]
) -> Result<usize, <Cursor<&mut Vec<u8, Global>> as Write>::Err>
fn write( &mut self, buf: &[u8] ) -> Result<usize, <Cursor<&mut Vec<u8, Global>> as Write>::Err>
Try to write the given buffer into the output stream. If writes are
successful returns the number of bytes written.