Trait BeBytes

Source
pub trait BeBytes: Sized {
    type ByteArray: AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Copy + PartialEq + Eq + PartialOrd + Ord + Hash;
    type Base32Array: AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Copy + PartialEq + Eq + PartialOrd + Ord + Hash;

    const SIZE: usize;
    const BASE32_SIZE: usize;

    // Required methods
    fn to_be_bytes(self) -> Self::ByteArray;
    fn from_be_bytes(bytes: Self::ByteArray) -> Self;
}
Expand description

A trait for types that can be encoded to and decoded from big-endian bytes.

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn to_be_bytes(self) -> Self::ByteArray

Source

fn from_be_bytes(bytes: Self::ByteArray) -> Self

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 BeBytes for u32

Source§

const SIZE: usize = 4usize

Source§

const BASE32_SIZE: usize = 7usize

Source§

type ByteArray = [u8; 4]

Source§

type Base32Array = [u8; 7]

Source§

fn to_be_bytes(self) -> Self::ByteArray

Source§

fn from_be_bytes(bytes: Self::ByteArray) -> Self

Source§

impl BeBytes for u64

Source§

const SIZE: usize = 8usize

Source§

const BASE32_SIZE: usize = 13usize

Source§

type ByteArray = [u8; 8]

Source§

type Base32Array = [u8; 13]

Source§

fn to_be_bytes(self) -> Self::ByteArray

Source§

fn from_be_bytes(bytes: Self::ByteArray) -> Self

Source§

impl BeBytes for u128

Source§

const SIZE: usize = 16usize

Source§

const BASE32_SIZE: usize = 26usize

Source§

type ByteArray = [u8; 16]

Source§

type Base32Array = [u8; 26]

Source§

fn to_be_bytes(self) -> Self::ByteArray

Source§

fn from_be_bytes(bytes: Self::ByteArray) -> Self

Implementors§