Struct mycelium_bitfield::pack::Packing32
source · 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
impl Packing32
sourcepub const fn pack_truncating(self, value: u32, packer: &Pack32) -> Self
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.
sourcepub const fn pack_from_src(self, value: u32, pair: &Pair32) -> Self
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.
sourcepub const fn pack_from_dst(self, value: u32, pair: &Pair32) -> Self
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.
sourcepub fn pack<T: FromBits<u32>, F>(self, value: T, packer: &Pack32<T, F>) -> Self
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
.
sourcepub const fn set_all<T, F>(self, packer: &Pack32<T, F>) -> Self
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
.
sourcepub const fn unset_all<T, F>(self, packer: &Pack32<T, F>) -> Self
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
.
sourcepub const fn contains_any<T, F>(self, packer: &Pack32<T, F>) -> bool
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
.
sourcepub const fn contains_all<T, F>(self, packer: &Pack32<T, F>) -> bool
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
.