Trait concordium_std::Read

source ·
pub trait Read {
    // Required method
    fn read(&mut self, buf: &mut [u8]) -> Result<usize, ParseError>;

    // Provided methods
    fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ParseError> { ... }
    fn read_u64(&mut self) -> Result<u64, ParseError> { ... }
    fn read_u32(&mut self) -> Result<u32, ParseError> { ... }
    fn read_u16(&mut self) -> Result<u16, ParseError> { ... }
    fn read_u8(&mut self) -> Result<u8, ParseError> { ... }
    fn read_i64(&mut self) -> Result<i64, ParseError> { ... }
    fn read_i32(&mut self) -> Result<i32, ParseError> { ... }
    fn read_i16(&mut self) -> Result<i16, ParseError> { ... }
    fn read_i8(&mut self) -> Result<i8, ParseError> { ... }
    fn read_array<const N: usize>(&mut self) -> Result<[u8; N], ParseError> { ... }
}
Expand description

The Read trait provides a means of reading from byte streams.

Required Methods§

source

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).

Provided Methods§

source

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_u64(&mut self) -> Result<u64, ParseError>

Read a u64 in little-endian format.

source

fn read_u32(&mut self) -> Result<u32, ParseError>

Read a u32 in little-endian format.

source

fn read_u16(&mut self) -> Result<u16, ParseError>

Read a u16 in little-endian format.

source

fn read_u8(&mut self) -> Result<u8, ParseError>

Read a u8.

source

fn read_i64(&mut self) -> Result<i64, ParseError>

Read a i64 in little-endian format.

source

fn read_i32(&mut self) -> Result<i32, ParseError>

Read a i32 in little-endian format.

source

fn read_i16(&mut self) -> Result<i16, ParseError>

Read a i16 in little-endian format.

source

fn read_i8(&mut self) -> Result<i8, ParseError>

Read a i32 in little-endian format.

source

fn read_array<const N: usize>(&mut self) -> Result<[u8; N], ParseError>

Load an array of the given size.

Implementors§