Skip to main content

ConstFromBytes

Trait ConstFromBytes 

Source
pub trait ConstFromBytes: Sized {
    type Bytes: Copy + AsRef<[u8]> + AsMut<[u8]>;

    // Required methods
    fn from_le_bytes(bytes: &Self::Bytes) -> Self;
    fn from_be_bytes(bytes: &Self::Bytes) -> Self;
}
Expand description

Const-compatible byte deserialization.

Required Associated Types§

Source

type Bytes: Copy + AsRef<[u8]> + AsMut<[u8]>

The byte array type for this integer.

Required Methods§

Source

fn from_le_bytes(bytes: &Self::Bytes) -> Self

Creates a value from its little-endian byte representation.

Source

fn from_be_bytes(bytes: &Self::Bytes) -> Self

Creates a value from its big-endian byte representation.

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 ConstFromBytes for u8

Source§

type Bytes = [u8; 1]

Source§

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

Source§

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

Source§

impl ConstFromBytes for u16

Source§

type Bytes = [u8; 2]

Source§

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

Source§

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

Source§

impl ConstFromBytes for u32

Source§

type Bytes = [u8; 4]

Source§

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

Source§

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

Source§

impl ConstFromBytes for u64

Source§

type Bytes = [u8; 8]

Source§

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

Source§

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

Source§

impl ConstFromBytes for u128

Source§

type Bytes = [u8; 16]

Source§

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

Source§

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

Implementors§