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

Wraps a u32 to add methods for packing bit ranges specified by Pack32.

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

Implementations§

source§

impl Packing32

source

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

Wrap a u32 to add methods for packing bit ranges using Pack32.

source

pub const fn pack_truncating(self, value: u32, packer: &Pack32) -> 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: u32, pair: &Pair32) -> 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: u32, pair: &Pair32) -> 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<u32>, F>(self, value: T, packer: &Pack32<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: &Pack32<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: &Pack32<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: &Pack32<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: &Pack32<T, F>) -> bool

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

source

pub const fn bits(self) -> u32

Finish packing bits into self, returning the wrapped value.

Trait Implementations§

source§

impl Binary for Packing32

source§

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

Formats the value using the given formatter.
source§

impl Clone for Packing32

source§

fn clone(&self) -> Packing32

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 Packing32

source§

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

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

impl From<Packing32> for u32

source§

fn from(packing: Packing32) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Packing32

source§

fn from(bits: u32) -> Self

Converts to this type from the input type.
source§

impl LowerHex for Packing32

source§

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

Formats the value using the given formatter.
source§

impl PartialEq for Packing32

source§

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

source§

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

Formats the value using the given formatter.
source§

impl Copy for Packing32

source§

impl Eq for Packing32

source§

impl StructuralEq for Packing32

source§

impl StructuralPartialEq for Packing32

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.