Skip to main content

ValidLength

Trait ValidLength 

Source
pub trait ValidLength:
    LengthSealed
    + Copy
    + Display
    + PartialEq
    + From<u8>
    + TryFrom<usize>
    + Into<u32> {
    type NonZero: NonZero<Self>;
    type InlineStrRepr: Copy + AsRef<[u8]> + AsMut<[u8]> + Default + TypeSize;

    const ZERO: Self;
    const MAX: Self;
    const DANGLING: Self::NonZero;

    // Required method
    fn to_usize(self) -> usize;

    // Provided method
    fn from_usize(len: usize) -> Option<Self> { ... }
}
Expand description

A sealed trait to represent valid lengths for a FixedArray.

This is implemented on u32 for non-16 bit platforms, and u16 on all platforms.

Required Associated Constants§

Source

const ZERO: Self

Source

const MAX: Self

Source

const DANGLING: Self::NonZero

👎Deprecated:

will be removed in the next major release

Required Associated Types§

Source

type NonZero: NonZero<Self>

👎Deprecated:

will be removed in the next major release

Source

type InlineStrRepr: Copy + AsRef<[u8]> + AsMut<[u8]> + Default + TypeSize

Available on crate feature typesize only.

Required Methods§

Source

fn to_usize(self) -> usize

Provided Methods§

Source

fn from_usize(len: usize) -> Option<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ValidLength for u8

Source§

const ZERO: Self = 0

Source§

const MAX: Self = Self::MAX

Source§

const DANGLING: Self::NonZero = <Self::NonZero>::MAX

👎Deprecated:

will be removed in the next major release

Source§

type NonZero = NonZero<u8>

👎Deprecated:

will be removed in the next major release

Source§

type InlineStrRepr = [u8; 9]

Available on crate feature typesize only.
Source§

fn to_usize(self) -> usize

Source§

impl ValidLength for u16

Source§

const ZERO: Self = 0

Source§

const MAX: Self = Self::MAX

Source§

const DANGLING: Self::NonZero = <Self::NonZero>::MAX

👎Deprecated:

will be removed in the next major release

Source§

type NonZero = NonZero<u16>

👎Deprecated:

will be removed in the next major release

Source§

type InlineStrRepr = [u8; 10]

Available on crate feature typesize only.
Source§

fn to_usize(self) -> usize

Source§

impl ValidLength for u32

Available on 32-bit or 64-bit only.
Source§

const ZERO: Self = 0

Source§

const MAX: Self = Self::MAX

Source§

const DANGLING: Self::NonZero = <Self::NonZero>::MAX

👎Deprecated:

will be removed in the next major release

Source§

type NonZero = NonZero<u32>

👎Deprecated:

will be removed in the next major release

Source§

type InlineStrRepr = [u8; 12]

Available on crate feature typesize only.
Source§

fn to_usize(self) -> usize

Implementors§