Trait miden_core::utils::ByteReader
source · pub trait ByteReader {
fn read_u8(&mut self) -> Result<u8, DeserializationError>;
fn read_u16(&mut self) -> Result<u16, DeserializationError>;
fn read_u32(&mut self) -> Result<u32, DeserializationError>;
fn read_u64(&mut self) -> Result<u64, DeserializationError>;
fn read_u128(&mut self) -> Result<u128, DeserializationError>;
fn read_u8_vec(
&mut self,
len: usize
) -> Result<Vec<u8, Global>, DeserializationError>;
fn read_u8_array<const N: usize>(
&mut self
) -> Result<[u8; N], DeserializationError>;
fn has_more_bytes(&self) -> bool;
}
Expand description
Defines how primitive values are to be read from Self
.
Required Methods
sourcefn read_u8(&mut self) -> Result<u8, DeserializationError>
fn read_u8(&mut self) -> Result<u8, DeserializationError>
Returns a single byte read from self
.
Errors
Returns a DeserializationError error the reader is at EOF.
sourcefn read_u16(&mut self) -> Result<u16, DeserializationError>
fn read_u16(&mut self) -> Result<u16, DeserializationError>
Returns a u16 value read from self
in little-endian byte order.
Errors
Returns a DeserializationError if a u16 value could not be read from self
.
sourcefn read_u32(&mut self) -> Result<u32, DeserializationError>
fn read_u32(&mut self) -> Result<u32, DeserializationError>
Returns a u32 value read from self
in little-endian byte order.
Errors
Returns a DeserializationError if a u32 value could not be read from self
.
sourcefn read_u64(&mut self) -> Result<u64, DeserializationError>
fn read_u64(&mut self) -> Result<u64, DeserializationError>
Returns a u64 value read from self
in little-endian byte order.
Errors
Returns a DeserializationError if a u64 value could not be read from self
.
sourcefn read_u128(&mut self) -> Result<u128, DeserializationError>
fn read_u128(&mut self) -> Result<u128, DeserializationError>
Returns a u128 value read from self
in little-endian byte order.
Errors
Returns a DeserializationError if a u128 value could not be read from self
.
sourcefn read_u8_vec(
&mut self,
len: usize
) -> Result<Vec<u8, Global>, DeserializationError>
fn read_u8_vec(
&mut self,
len: usize
) -> Result<Vec<u8, Global>, DeserializationError>
Returns a byte vector of the specified length read from self
.
Errors
Returns a DeserializationError if a vector of the specified length could not be read
from self
.
sourcefn read_u8_array<const N: usize>(
&mut self
) -> Result<[u8; N], DeserializationError>
fn read_u8_array<const N: usize>(
&mut self
) -> Result<[u8; N], DeserializationError>
Returns a byte array of length N
reade from self
.
sourcefn has_more_bytes(&self) -> bool
fn has_more_bytes(&self) -> bool
Returns true if there are more bytes left to be read from self
.