Struct mycelium_bitfield::pack::Packing8

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

Wraps a u8 to add methods for packing bit ranges specified by Pack8.

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

Implementations§

source§

impl Packing8

source

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

Wrap a u8 to add methods for packing bit ranges using Pack8.

source

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

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

source

pub const fn bits(self) -> u8

Finish packing bits into self, returning the wrapped value.

Trait Implementations§

source§

impl Binary for Packing8

source§

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

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

impl Clone for Packing8

source§

fn clone(&self) -> Packing8

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 Packing8

source§

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

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

impl From<Packing8> for u8

source§

fn from(packing: Packing8) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Packing8

source§

fn from(bits: u8) -> Self

Converts to this type from the input type.
source§

impl LowerHex for Packing8

source§

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

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

impl PartialEq for Packing8

source§

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

source§

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

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

impl Copy for Packing8

source§

impl Eq for Packing8

source§

impl StructuralPartialEq for Packing8

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.