Struct mycelium_bitfield::pack::PackingUsize
source · 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
impl PackingUsize
sourcepub const fn pack_truncating(self, value: usize, packer: &PackUsize) -> Self
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.
sourcepub const fn pack_from_src(self, value: usize, pair: &PairUsize) -> Self
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.
sourcepub const fn pack_from_dst(self, value: usize, pair: &PairUsize) -> Self
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.
sourcepub fn pack<T: FromBits<usize>, F>(
self,
value: T,
packer: &PackUsize<T, F>
) -> Self
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
.
sourcepub const fn set_all<T, F>(self, packer: &PackUsize<T, F>) -> Self
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
.
sourcepub const fn unset_all<T, F>(self, packer: &PackUsize<T, F>) -> Self
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
.
sourcepub const fn contains_any<T, F>(self, packer: &PackUsize<T, F>) -> bool
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
.
sourcepub const fn contains_all<T, F>(self, packer: &PackUsize<T, F>) -> bool
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
.
Trait Implementations§
source§impl Binary for PackingUsize
impl Binary for PackingUsize
source§impl Clone for PackingUsize
impl Clone for PackingUsize
source§fn clone(&self) -> PackingUsize
fn clone(&self) -> PackingUsize
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PackingUsize
impl Debug for PackingUsize
source§impl From<PackingUsize> for usize
impl From<PackingUsize> for usize
source§fn from(packing: PackingUsize) -> Self
fn from(packing: PackingUsize) -> Self
source§impl From<usize> for PackingUsize
impl From<usize> for PackingUsize
source§impl LowerHex for PackingUsize
impl LowerHex for PackingUsize
source§impl PartialEq for PackingUsize
impl PartialEq for PackingUsize
source§fn eq(&self, other: &PackingUsize) -> bool
fn eq(&self, other: &PackingUsize) -> bool
self
and other
values to be equal, and is used
by ==
.