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). Read moresource§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. Read moresource§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<T> Seek for Cursor<T>where
T: HasSize,
impl<T> Seek for Cursor<T>where
T: HasSize,
type Err = ()
source§fn seek(&mut self, pos: SeekFrom) -> Result<u32, <Cursor<T> as Seek>::Err>
fn seek(&mut self, pos: SeekFrom) -> Result<u32, <Cursor<T> as Seek>::Err>
Seek to the new position. If successful, return the new position from
the beginning of the stream. Read more
source§fn cursor_position(&self) -> u32
fn cursor_position(&self) -> u32
Get the cursor position counted from the beginning of the stream.
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. Read more