Trait ReadBytes

Source
pub trait ReadBytes {
    type Error;

    // Required methods
    fn read_u64(&mut self) -> Result<u64, Self::Error>;
    fn read_i64(&mut self) -> Result<i64, Self::Error>;
    fn read_u32(&mut self) -> Result<u32, Self::Error>;
    fn read_i32(&mut self) -> Result<i32, Self::Error>;
    fn read_u16(&mut self) -> Result<u16, Self::Error>;
    fn read_i16(&mut self) -> Result<i16, Self::Error>;
    fn read_bool(&mut self) -> Result<bool, Self::Error>;
    fn read_u8(&mut self) -> Result<u8, Self::Error>;
    fn read_i8(&mut self) -> Result<i8, Self::Error>;
    fn read_bytes<const N: usize>(&mut self) -> Result<[u8; N], Self::Error>;
    fn skip(&mut self, bytes_to_skip: usize);
}

Required Associated Types§

Required Methods§

Source

fn read_u64(&mut self) -> Result<u64, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 8] is within bounds of the bytes slice.

Source

fn read_i64(&mut self) -> Result<i64, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 8] is within bounds of the bytes slice.

Source

fn read_u32(&mut self) -> Result<u32, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 4] is within bounds of the bytes slice.

Source

fn read_i32(&mut self) -> Result<i32, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 4] is within bounds of the bytes slice.

Source

fn read_u16(&mut self) -> Result<u16, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 2] is within bounds of the bytes slice.

Source

fn read_i16(&mut self) -> Result<i16, Self::Error>

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + 2] is within bounds of the bytes slice.

Source

fn read_bool(&mut self) -> Result<bool, Self::Error>

§Safety

This function returns an error instead of panicking if the index is out of bounds. Valid values are 0 (false) and 1 (true). Any other value results in an error.

Source

fn read_u8(&mut self) -> Result<u8, Self::Error>

§Safety

This function returns an error instead of panicking if the index is out of bounds.

Source

fn read_i8(&mut self) -> Result<i8, Self::Error>

§Safety

This function returns an error instead of panicking if the index is out of bounds.

Source

fn read_bytes<const N: usize>(&mut self) -> Result<[u8; N], Self::Error>

Reads const N amount of bytes.

§Safety

The caller is responsible for ensuring that the range [self.offset..self.offset + N] is within bounds of the bytes slice.

Source

fn skip(&mut self, bytes_to_skip: usize)

Increments self.offset by bytes_to_skip.

§Safety

The caller is responsible for ensuring that the self.offset + bytes_to_skip is within bounds of the bytes slice

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§