Struct mycelium_bitfield::pack::Packing128

source ·
pub struct Packing128(/* private fields */);
Expand description

Wraps a u128 to add methods for packing bit ranges specified by Pack128.

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

Implementations§

source§

impl Packing128

source

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

Wrap a u128 to add methods for packing bit ranges using Pack128.

source

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

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

source

pub const fn bits(self) -> u128

Finish packing bits into self, returning the wrapped value.

Trait Implementations§

source§

impl Binary for Packing128

source§

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

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

impl Clone for Packing128

source§

fn clone(&self) -> Packing128

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 Packing128

source§

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

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

impl From<Packing128> for u128

source§

fn from(packing: Packing128) -> Self

Converts to this type from the input type.
source§

impl From<u128> for Packing128

source§

fn from(bits: u128) -> Self

Converts to this type from the input type.
source§

impl LowerHex for Packing128

source§

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

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

impl PartialEq for Packing128

source§

fn eq(&self, other: &Packing128) -> bool

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

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

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

impl UpperHex for Packing128

source§

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

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

impl Copy for Packing128

source§

impl Eq for Packing128

source§

impl StructuralPartialEq for Packing128

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.