Skip to main content

ByteOrder

Trait ByteOrder 

Source
pub trait ByteOrder {
    // Required methods
    fn read_u32(buf: &[u8]) -> u32;
    fn write_u32(buf: &mut [u8], n: u32);
    fn write_u64(buf: &mut [u8], n: u64);
}
Expand description

Reads and writes numbers in a specific byte order.

Required Methods§

Source

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

Reads an unsigned 32-bit integer from the first four bytes of buf.

§Panics

Panics when buf.len() < 4.

Source

fn write_u32(buf: &mut [u8], n: u32)

Writes an unsigned 32-bit integer to the first four bytes of buf.

§Panics

Panics when buf.len() < 4.

Source

fn write_u64(buf: &mut [u8], n: u64)

Writes an unsigned 64-bit integer to the first eight bytes of buf.

§Panics

Panics when buf.len() < 8.

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§