Struct mycelium_bitfield::pack::Packing16

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

Wraps a u16 to add methods for packing bit ranges specified by Pack16.

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

Implementations§

source§

impl Packing16

source

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

Wrap a u16 to add methods for packing bit ranges using Pack16.

source

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

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

source

pub const fn bits(self) -> u16

Finish packing bits into self, returning the wrapped value.

Trait Implementations§

source§

impl Binary for Packing16

source§

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

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

impl Clone for Packing16

source§

fn clone(&self) -> Packing16

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 Packing16

source§

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

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

impl From<Packing16> for u16

source§

fn from(packing: Packing16) -> Self

Converts to this type from the input type.
source§

impl From<u16> for Packing16

source§

fn from(bits: u16) -> Self

Converts to this type from the input type.
source§

impl LowerHex for Packing16

source§

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

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

impl PartialEq for Packing16

source§

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

source§

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

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

impl Copy for Packing16

source§

impl Eq for Packing16

source§

impl StructuralPartialEq for Packing16

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.