ToBytes

Trait ToBytes 

Source
pub trait ToBytes: AsBytes {
    // Required methods
    fn to_be_bytes(self) -> Self::Bytes;
    fn to_le_bytes(self) -> Self::Bytes;
    fn to_ne_bytes(self) -> Self::Bytes;
}
Expand description

Traits for types that can be cast to an array of bytes.

Required Methods§

Source

fn to_be_bytes(self) -> Self::Bytes

Return the memory representation of this integer as a byte array in big-endian (network) byte order.

Source

fn to_le_bytes(self) -> Self::Bytes

Return the memory representation of this integer as a byte array in little-endian byte order.

Source

fn to_ne_bytes(self) -> Self::Bytes

Return the memory representation of this integer as a byte array in native byte order. As the target platform’s native endianness is used, portable code should use to_be_bytes or to_le_bytes, as appropriate, instead.

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 ToBytes for f32

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for f64

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for i8

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for i16

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for i32

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for i64

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for i128

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for isize

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for u8

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for u16

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for u32

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for u64

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for u128

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for usize

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for bf16

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Source§

impl ToBytes for f16

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn to_le_bytes(self) -> Self::Bytes

Source§

fn to_ne_bytes(self) -> Self::Bytes

Implementors§