Struct concordium_contracts_common::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: AsRef<[u8]>> Read for Cursor<T>
impl<T: AsRef<[u8]>> Read for Cursor<T>
source§fn read(&mut self, buf: &mut [u8]) -> ParseResult<usize>
fn read(&mut self, buf: &mut [u8]) -> ParseResult<usize>
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]) -> ParseResult<()>
fn read_exact(&mut self, buf: &mut [u8]) -> ParseResult<()>
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_u64(&mut self) -> ParseResult<u64>
fn read_u64(&mut self) -> ParseResult<u64>
Read a
u64
in little-endian format.source§fn read_u32(&mut self) -> ParseResult<u32>
fn read_u32(&mut self) -> ParseResult<u32>
Read a
u32
in little-endian format.source§fn read_u16(&mut self) -> ParseResult<u16>
fn read_u16(&mut self) -> ParseResult<u16>
Read a
u16
in little-endian format.source§fn read_u8(&mut self) -> ParseResult<u8>
fn read_u8(&mut self) -> ParseResult<u8>
Read a
u8
.source§fn read_i64(&mut self) -> ParseResult<i64>
fn read_i64(&mut self) -> ParseResult<i64>
Read a
i64
in little-endian format.source§fn read_i32(&mut self) -> ParseResult<i32>
fn read_i32(&mut self) -> ParseResult<i32>
Read a
i32
in little-endian format.source§fn read_i16(&mut self) -> ParseResult<i16>
fn read_i16(&mut self) -> ParseResult<i16>
Read a
i16
in little-endian format.source§fn read_i8(&mut self) -> ParseResult<i8>
fn read_i8(&mut self) -> ParseResult<i8>
Read a
i32
in little-endian format.source§fn read_array<const N: usize>(&mut self) -> ParseResult<[u8; N]>
fn read_array<const N: usize>(&mut self) -> ParseResult<[u8; N]>
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, Self::Err>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::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> 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
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Upper case
letters are used (e.g. F9B4CA
)