Trait HasUnsignedVersion

Source
pub trait HasUnsignedVersion {
    type Unsigned;
    type LeBytes;

    // Required methods
    fn to_le_bytes(self) -> Self::LeBytes;
    fn from_le_bytes(bytes: Self::LeBytes) -> Self;
}
Expand description

Helper trait for efficient calculations in other implementations

Required Associated Types§

Source

type Unsigned

which unsigned type corresponds to this type?

Source

type LeBytes

Type returned by self.to_le_bytes(). Depends on how many bytes are needed, to represent the number

Required Methods§

Source

fn to_le_bytes(self) -> Self::LeBytes

to little endian. See implementation for integers in the standard library

Source

fn from_le_bytes(bytes: Self::LeBytes) -> Self

from little endian. See implementation for integers in the standard library

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 HasUnsignedVersion for i8

Source§

type Unsigned = u8

Source§

type LeBytes = [u8; 1]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for i16

Source§

type Unsigned = u16

Source§

type LeBytes = [u8; 2]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for i32

Source§

type Unsigned = u32

Source§

type LeBytes = [u8; 4]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for i64

Source§

type Unsigned = u64

Source§

type LeBytes = [u8; 8]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for i128

Source§

type Unsigned = u128

Source§

type LeBytes = [u8; 16]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for isize

Source§

type Unsigned = usize

Source§

type LeBytes = [u8; 8]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for u8

Source§

type Unsigned = u8

Source§

type LeBytes = [u8; 1]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for u16

Source§

type Unsigned = u16

Source§

type LeBytes = [u8; 2]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for u32

Source§

type Unsigned = u32

Source§

type LeBytes = [u8; 4]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for u64

Source§

type Unsigned = u64

Source§

type LeBytes = [u8; 8]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for u128

Source§

type Unsigned = u128

Source§

type LeBytes = [u8; 16]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Source§

impl HasUnsignedVersion for usize

Source§

type Unsigned = usize

Source§

type LeBytes = [u8; 8]

Source§

fn to_le_bytes(self) -> Self::LeBytes

Source§

fn from_le_bytes(bytes: Self::LeBytes) -> Self

Implementors§