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
sourceimpl HasCallResponse for Cursor<Vec<u8>>
impl HasCallResponse for Cursor<Vec<u8>>
sourceimpl<T> Read for Cursor<T> where
T: AsRef<[u8]>,
impl<T> Read for Cursor<T> where
T: AsRef<[u8]>,
sourcefn 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 more
sourcefn 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 more
sourcefn read_u64(&mut self) -> Result<u64, ParseError>
fn read_u64(&mut self) -> Result<u64, ParseError>
Read a u64
in little-endian format.
sourcefn read_u32(&mut self) -> Result<u32, ParseError>
fn read_u32(&mut self) -> Result<u32, ParseError>
Read a u32
in little-endian format.
sourcefn read_u16(&mut self) -> Result<u16, ParseError>
fn read_u16(&mut self) -> Result<u16, ParseError>
Read a u16
in little-endian format.
sourcefn read_u8(&mut self) -> Result<u8, ParseError>
fn read_u8(&mut self) -> Result<u8, ParseError>
Read a u8
.
sourcefn read_i64(&mut self) -> Result<i64, ParseError>
fn read_i64(&mut self) -> Result<i64, ParseError>
Read a i64
in little-endian format.
sourcefn read_i32(&mut self) -> Result<i32, ParseError>
fn read_i32(&mut self) -> Result<i32, ParseError>
Read a i32
in little-endian format.
sourcefn read_i16(&mut self) -> Result<i16, ParseError>
fn read_i16(&mut self) -> Result<i16, ParseError>
Read a i16
in little-endian format.
sourcefn read_i8(&mut self) -> Result<i8, ParseError>
fn read_i8(&mut self) -> Result<i8, ParseError>
Read a i32
in little-endian format.
sourcefn 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.
sourceimpl<T> Seek for Cursor<T> where
T: HasSize,
impl<T> Seek for Cursor<T> where
T: HasSize,
type Err = ()
sourcefn 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
sourcefn cursor_position(&self) -> u32
fn cursor_position(&self) -> u32
Get the cursor position counted from the beginning of the stream.
sourceimpl Write for Cursor<&mut Vec<u8, Global>>
impl Write for Cursor<&mut Vec<u8, Global>>
type Err = ()
sourcefn 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
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more