Trait Endian

Source
pub(crate) trait Endian {
    // Required methods
    fn write_u16(n: u16, dst: &mut [u8]);
    fn write_u32(n: u32, dst: &mut [u8]);
    fn write_u128(n: u128, dst: &mut [u8]);
}
Expand description

A simple trait for writing code generic over endianness.

This is similar to what byteorder provides, but we only need a very small subset.

Required Methods§

Source

fn write_u16(n: u16, dst: &mut [u8])

Writes a u16 to the given destination buffer in a particular endianness. If the destination buffer has a length smaller than 2, then this panics.

Source

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

Writes a u32 to the given destination buffer in a particular endianness. If the destination buffer has a length smaller than 4, then this panics.

Source

fn write_u128(n: u128, dst: &mut [u8])

Writes a u128 to the given destination buffer in a particular endianness. If the destination buffer has a length smaller than 16, then this panics.

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§