pub struct PackingUsize(/* private fields */);
Expand description

Wraps a usize to add methods for packing bit ranges specified by PackUsize.

See the module-level documentation for details on using packing specs.

Implementations§

source§

impl PackingUsize

source

pub const fn new(bits: usize) -> Self

Wrap a usize to add methods for packing bit ranges using PackUsize.

source

pub const fn pack_truncating(self, value: usize, packer: &PackUsize) -> Self

Pack bits from value into self, using the range specified by packer.

Any bits in value outside the range specified by packer are ignored.

source

pub const fn pack_from_src(self, value: usize, pair: &PairUsize) -> Self

Pack bits from src into self, using the packing pair specified by pair, with self serving as the “destination” member of the pair, and src serving as the “source” member of the pair.

source

pub const fn pack_from_dst(self, value: usize, pair: &PairUsize) -> Self

Pack bits from dst into self, using the packing pair specified by pair, with self serving as the “siyrce” member of the pair, and dst serving as the “destination” member of the pair.

source

pub fn pack<T: FromBits<usize>, F>( self, value: T, packer: &PackUsize<T, F> ) -> Self

Pack bits from value into self, using the range specified by packer.

Panics

If value contains bits outside the range specified by packer.

source

pub const fn set_all<T, F>(self, packer: &PackUsize<T, F>) -> Self

Set all bits in the range specified by packer to 1 in self.

source

pub const fn unset_all<T, F>(self, packer: &PackUsize<T, F>) -> Self

Set all bits in the range specified by packer to 0 in self.

source

pub const fn contains_any<T, F>(self, packer: &PackUsize<T, F>) -> bool

Returns true if any bits specified by packer are set in self.

source

pub const fn contains_all<T, F>(self, packer: &PackUsize<T, F>) -> bool

Returns true if any bits specified by packer are set in self.

source

pub const fn bits(self) -> usize

Finish packing bits into self, returning the wrapped value.

Trait Implementations§

source§

impl Binary for PackingUsize

source§

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

Formats the value using the given formatter.
source§

impl Clone for PackingUsize

source§

fn clone(&self) -> PackingUsize

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 Debug for PackingUsize

source§

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

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

impl From<PackingUsize> for usize

source§

fn from(packing: PackingUsize) -> Self

Converts to this type from the input type.
source§

impl From<usize> for PackingUsize

source§

fn from(bits: usize) -> Self

Converts to this type from the input type.
source§

impl LowerHex for PackingUsize

source§

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

Formats the value using the given formatter.
source§

impl PartialEq for PackingUsize

source§

fn eq(&self, other: &PackingUsize) -> 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 UpperHex for PackingUsize

source§

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

Formats the value using the given formatter.
source§

impl Copy for PackingUsize

source§

impl Eq for PackingUsize

source§

impl StructuralEq for PackingUsize

source§

impl StructuralPartialEq for PackingUsize

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<T, U> TryFrom<U> for T
where 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 T
where 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.