TinyStrInt

Trait TinyStrInt 

Source
pub trait TinyStrInt:
    Copy
    + Clone
    + Eq
    + Ord
    + Hash
    + Sized {
    type Bytes: Copy + Default + AsMut<[u8]> + AsRef<[u8]>;
    type Raw: Copy + Default;

    const LEN: usize;

    // Required methods
    fn to_be_bytes(self) -> Self::Bytes;
    fn trailing_zeros(self) -> u32;
    fn set_raw(accumulator: Self::Raw, byte: u8, pos: usize) -> Self::Raw;
    fn from_raw(raw: Self::Raw) -> Option<Self>;
}
Expand description

Helper trait for integer types that can be used as storage for a TinyStr.

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn to_be_bytes(self) -> Self::Bytes

Source

fn trailing_zeros(self) -> u32

Source

fn set_raw(accumulator: Self::Raw, byte: u8, pos: usize) -> Self::Raw

Source

fn from_raw(raw: Self::Raw) -> Option<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 TinyStrInt for NonZero<u16>

Source§

const LEN: usize

Source§

type Raw = u16

Source§

type Bytes = [u8; 2]

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn trailing_zeros(self) -> u32

Source§

fn set_raw(accumulator: Self::Raw, byte: u8, pos: usize) -> Self::Raw

Source§

fn from_raw(raw: Self::Raw) -> Option<Self>

Source§

impl TinyStrInt for NonZero<u32>

Source§

const LEN: usize

Source§

type Raw = u32

Source§

type Bytes = [u8; 4]

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn trailing_zeros(self) -> u32

Source§

fn set_raw(accumulator: Self::Raw, byte: u8, pos: usize) -> Self::Raw

Source§

fn from_raw(raw: Self::Raw) -> Option<Self>

Source§

impl TinyStrInt for NonZero<u64>

Source§

const LEN: usize

Source§

type Raw = u64

Source§

type Bytes = [u8; 8]

Source§

fn to_be_bytes(self) -> Self::Bytes

Source§

fn trailing_zeros(self) -> u32

Source§

fn set_raw(accumulator: Self::Raw, byte: u8, pos: usize) -> Self::Raw

Source§

fn from_raw(raw: Self::Raw) -> Option<Self>

Implementors§