Struct packable::bounded::BoundedU8

source ·
pub struct BoundedU8<const MIN: u8, const MAX: u8>(/* private fields */);
Expand description

Wrapper type for a u8, providing minimum and maximum value bounds.

Implementations§

source§

impl<const MIN: u8, const MAX: u8> BoundedU8<MIN, MAX>

source

pub const MIN: u8 = MIN

Minimum bounded value.

source

pub const MAX: u8 = MAX

Maximum bounded value.

source

pub const fn get(self) -> u8

Returns the value as a primitive type.

Trait Implementations§

source§

impl<const MIN: u8, const MAX: u8> Bounded for BoundedU8<MIN, MAX>

§

type Bounds = u8

The type used to define the bounds.
source§

impl<const MIN: u8, const MAX: u8> Clone for BoundedU8<MIN, MAX>

source§

fn clone(&self) -> BoundedU8<MIN, MAX>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const MIN: u8, const MAX: u8> Debug for BoundedU8<MIN, MAX>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<const MIN: u8, const MAX: u8> Default for BoundedU8<MIN, MAX>

This implementation returns the closest bounded integer to zero.

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<const MIN: u8, const MAX: u8> From<BoundedU8<MIN, MAX>> for u8

source§

fn from(wrapper: BoundedU8<MIN, MAX>) -> Self

Converts to this type from the input type.
source§

impl<const MIN: u8, const MAX: u8> Hash for BoundedU8<MIN, MAX>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<const MIN: u8, const MAX: u8> Ord for BoundedU8<MIN, MAX>

source§

fn cmp(&self, other: &BoundedU8<MIN, MAX>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<const MIN: u8, const MAX: u8> Packable for BoundedU8<MIN, MAX>

§

type UnpackError = InvalidBoundedU8<MIN, MAX>

The error type that can be returned if some semantic error occurs while unpacking. Read more
§

type UnpackVisitor = <u8 as Packable>::UnpackVisitor

FIXME: docs
source§

fn pack<P: Packer>(&self, packer: &mut P) -> Result<(), P::Error>

Packs this value into the given Packer.
source§

fn unpack<U: Unpacker, const VERIFY: bool>( unpacker: &mut U, visitor: &Self::UnpackVisitor ) -> Result<Self, UnpackError<Self::UnpackError, U::Error>>

Unpacks this value from the given Unpacker. The VERIFY generic parameter can be used to skip additional syntactic checks.
source§

impl<const MIN: u8, const MAX: u8> PartialEq for BoundedU8<MIN, MAX>

source§

fn eq(&self, other: &BoundedU8<MIN, MAX>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const MIN: u8, const MAX: u8> PartialOrd for BoundedU8<MIN, MAX>

source§

fn partial_cmp(&self, other: &BoundedU8<MIN, MAX>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const MIN: u8, const MAX: u8> TryFrom<u8> for BoundedU8<MIN, MAX>

§

type Error = InvalidBoundedU8<MIN, MAX>

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<const MIN: u8, const MAX: u8> TryFrom<usize> for BoundedU8<MIN, MAX>

§

type Error = TryIntoBoundedU8Error<MIN, MAX>

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<const MIN: u8, const MAX: u8> Copy for BoundedU8<MIN, MAX>

source§

impl<const MIN: u8, const MAX: u8> Eq for BoundedU8<MIN, MAX>

source§

impl<const MIN: u8, const MAX: u8> StructuralEq for BoundedU8<MIN, MAX>

source§

impl<const MIN: u8, const MAX: u8> StructuralPartialEq for BoundedU8<MIN, MAX>

Auto Trait Implementations§

§

impl<const MIN: u8, const MAX: u8> RefUnwindSafe for BoundedU8<MIN, MAX>

§

impl<const MIN: u8, const MAX: u8> Send for BoundedU8<MIN, MAX>

§

impl<const MIN: u8, const MAX: u8> Sync for BoundedU8<MIN, MAX>

§

impl<const MIN: u8, const MAX: u8> Unpin for BoundedU8<MIN, MAX>

§

impl<const MIN: u8, const MAX: u8> UnwindSafe for BoundedU8<MIN, MAX>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<P> PackableExt for Pwhere P: Packable,

source§

fn unpack_verified<T>( bytes: T, visitor: &<P as Packable>::UnpackVisitor ) -> Result<P, UnpackError<<P as Packable>::UnpackError, UnexpectedEOF>>where T: AsRef<[u8]>,

Unpacks this value from a type that implements [AsRef<[u8]>].

source§

fn unpack_unverified<T>( bytes: T ) -> Result<P, UnpackError<<P as Packable>::UnpackError, UnexpectedEOF>>where T: AsRef<[u8]>,

Unpacks this value from a type that implements [AsRef<[u8]>] skipping some syntatical checks.

source§

fn packed_len(&self) -> usize

Returns the length in bytes of the value after being packed. The returned value always matches the number of bytes written using pack.
source§

fn pack_to_vec(&self) -> Vec<u8>

Convenience method that packs this value into a Vec<u8>.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.