Trait IntoBytes

Source
pub trait IntoBytes<const T: usize> {
    // Required methods
    fn into_le_bytes(self) -> [u8; T];
    fn into_be_bytes(self) -> [u8; T];
}
Expand description

Defines a type can be converted into a byte array.

use num_bytes::IntoBytes;
let a = 8u32;
let b = a.into_le_bytes();
assert_eq!(b,[8,0,0,0]);

Required Methods§

Source

fn into_le_bytes(self) -> [u8; T]

Source

fn into_be_bytes(self) -> [u8; T]

Implementations on Foreign Types§

Source§

impl IntoBytes<1> for i8

Source§

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

Source§

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

Source§

impl IntoBytes<1> for u8

Source§

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

Source§

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

Source§

impl IntoBytes<2> for i16

Source§

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

Source§

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

Source§

impl IntoBytes<2> for u16

Source§

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

Source§

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

Source§

impl IntoBytes<4> for f32

Source§

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

Source§

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

Source§

impl IntoBytes<4> for i32

Source§

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

Source§

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

Source§

impl IntoBytes<4> for u32

Source§

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

Source§

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

Source§

impl IntoBytes<8> for f64

Source§

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

Source§

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

Source§

impl IntoBytes<8> for i64

Source§

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

Source§

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

Source§

impl IntoBytes<8> for isize

Source§

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

Source§

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

Source§

impl IntoBytes<8> for u64

Source§

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

Source§

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

Source§

impl IntoBytes<8> for usize

Source§

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

Source§

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

Implementors§