Trait Integer

Source
pub trait Integer<const BYTES: usize> {
    // Required methods
    fn from_be_bytes(bytes: [u8; BYTES]) -> Self;
    fn from_le_bytes(bytes: [u8; BYTES]) -> Self;
    fn from_ne_bytes(bytes: [u8; BYTES]) -> Self;
}
Expand description

Common functions for integers.

Required Methods§

Source

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

Creates a native endian integer value from its representation as a byte array in big endian.

Source

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

Creates a native endian integer value from its representation as a byte array in little endian.

Source

fn from_ne_bytes(bytes: [u8; BYTES]) -> Self

Creates a native endian integer value from its representation as a byte array in native endian.

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 Integer<1> for i8

Source§

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

Source§

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

Source§

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

Source§

impl Integer<1> for u8

Source§

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

Source§

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

Source§

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

Source§

impl Integer<2> for i16

Source§

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

Source§

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

Source§

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

Source§

impl Integer<2> for u16

Source§

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

Source§

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

Source§

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

Source§

impl Integer<4> for i32

Source§

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

Source§

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

Source§

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

Source§

impl Integer<4> for u32

Source§

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

Source§

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

Source§

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

Source§

impl Integer<8> for i64

Source§

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

Source§

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

Source§

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

Source§

impl Integer<8> for u64

Source§

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

Source§

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

Source§

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

Source§

impl Integer<16> for i128

Source§

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

Source§

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

Source§

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

Source§

impl Integer<16> for u128

Source§

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

Source§

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

Source§

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

Implementors§