Trait ByteOrder

Source
pub trait ByteOrder:
    Default
    + Debug
    + Clone {
    // Required methods
    fn read_u16(buf: &[u8]) -> Result<u16>;
    fn read_u24(buf: &[u8]) -> Result<u32>;
    fn read_u32(buf: &[u8]) -> Result<u32>;
}
Expand description

A trait for handling different byte orders.

This trait defines methods for reading unsigned integers in various byte orders.

Required Methods§

Source

fn read_u16(buf: &[u8]) -> Result<u16>

Reads a 16-bit unsigned integer from a byte slice.

§Arguments
  • buf - A byte slice containing the data to read.
§Returns

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

Source

fn read_u24(buf: &[u8]) -> Result<u32>

Reads a 24-bit unsigned integer from a byte slice.

§Arguments
  • buf - A byte slice containing the data to read.
§Returns

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

Source

fn read_u32(buf: &[u8]) -> Result<u32>

Reads a 32-bit unsigned integer from a byte slice.

§Arguments
  • buf - A byte slice containing the data to read.
§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§