Trait LittleEndianBytes

Source
pub trait LittleEndianBytes<const N: usize> {
    // Required methods
    fn from_le_bytes(bytes: [u8; N]) -> Self;
    fn to_le_bytes(self) -> [u8; N];
}
Expand description

Convert from and to the little endian byte representation of a value

N denotes the number of bytes required for the little endian representation

Required Methods§

Source

fn from_le_bytes(bytes: [u8; N]) -> Self

Convert from a byte array to Self

Source

fn to_le_bytes(self) -> [u8; N]

Convert from self to a byte array

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.

Implementations on Foreign Types§

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for f32

Source§

fn from_le_bytes(bytes: [u8; 4]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 4]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for f64

Source§

fn from_le_bytes(bytes: [u8; 8]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 8]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for i8

Source§

fn from_le_bytes(bytes: [u8; 1]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 1]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for i16

Source§

fn from_le_bytes(bytes: [u8; 2]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 2]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for i32

Source§

fn from_le_bytes(bytes: [u8; 4]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 4]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for i64

Source§

fn from_le_bytes(bytes: [u8; 8]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 8]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for i128

Source§

fn from_le_bytes(bytes: [u8; 16]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 16]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for u8

Source§

fn from_le_bytes(bytes: [u8; 1]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 1]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for u16

Source§

fn from_le_bytes(bytes: [u8; 2]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 2]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for u32

Source§

fn from_le_bytes(bytes: [u8; 4]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 4]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for u64

Source§

fn from_le_bytes(bytes: [u8; 8]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 8]

Source§

impl LittleEndianBytes<{ ::core::mem::size_of::<$type>() }> for u128

Source§

fn from_le_bytes(bytes: [u8; 16]) -> Self

Source§

fn to_le_bytes(self) -> [u8; 16]

Implementors§