Trait ReadBytes

Source
pub trait ReadBytes: Read {
    // Provided methods
    fn read_u8(&mut self) -> Result<u8> { ... }
    fn read_u16<T: ByteOrder>(&mut self) -> Result<u16> { ... }
    fn read_u24<T: ByteOrder>(&mut self) -> Result<u32> { ... }
    fn read_u32<T: ByteOrder>(&mut self) -> Result<u32> { ... }
}
Expand description

A trait for reading bytes with support for different byte orders.

Provided Methods§

Source

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

Reads a single 8-bit unsigned integer.

§Returns

Returns a Result containing the 8-bit integer on success, or an Error if the read operation fails.

Source

fn read_u16<T: ByteOrder>(&mut self) -> Result<u16>

Reads a 16-bit unsigned integer using the specified byte order.

§Type Parameters
  • T - The byte order to use for reading the integer.
§Returns

Returns a Result containing the 16-bit integer on success, or an Error if the read operation fails.

Source

fn read_u24<T: ByteOrder>(&mut self) -> Result<u32>

Reads a 24-bit unsigned integer using the specified byte order.

§Type Parameters
  • T - The byte order to use for reading the integer.
§Returns

Returns a Result containing the 24-bit integer on success, or an Error if the read operation fails.

Source

fn read_u32<T: ByteOrder>(&mut self) -> Result<u32>

Reads a 32-bit unsigned integer using the specified byte order.

§Type Parameters
  • T - The byte order to use for reading the integer.
§Returns

Returns a Result containing the 32-bit integer on success, or an Error if the read operation fails.

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§

Source§

impl<R: Read + ?Sized> ReadBytes for R