Struct BitField

Source
pub struct BitField<T: PrimInt>(/* private fields */);
Expand description

A bitfield type.

Built on type of an unsigned integer. It uses the bits to represent the presence or absence of elements.

Implementations§

Source§

impl<T: PrimInt> BitField<T>

Source

pub fn set_bit(&mut self, bit_idx: BitFieldIndex) -> bool

Set the bit at BitFieldIndex to 1.

Does not check that the BitFieldIndex is not out of range.

Returns true if the value is changed.

Source

pub fn set_bit_checked(&mut self, bit_idx: BitFieldIndex) -> Option<bool>

Set the bit at BitFieldIndex to 1, if the index is in range..

Check that the BitFieldIndex is not out of range. Calls set_bit if the index is in range.

Returns Some(true) if the value is changed. Returns None if the index is out of range.

Source

pub fn unset_bit(&mut self, bit_idx: BitFieldIndex) -> bool

Source

pub fn unset_bit_checked(&mut self, bit_idx: BitFieldIndex) -> Option<bool>

Source

pub fn merge(&mut self, other: &Self) -> bool

Source§

impl<T: PrimInt> BitField<T>

Source

pub fn fill(nb_bits: BitFieldSize) -> Self

Source

pub fn fill_checked(nb_bits: BitFieldSize) -> Option<Self>

Source

pub fn full() -> Self

Source

pub fn empty() -> Self

Source

pub fn single_bit(bit_idx: BitFieldIndex) -> Self

Source

pub fn single_bit_checked(bit_idx: BitFieldIndex) -> Option<Self>

Source

pub fn all_but_single_bit(nb_bits: BitFieldSize, bit_idx: BitFieldIndex) -> Self

Source

pub fn all_but_single_bit_checked( nb_bits: BitFieldSize, bit_idx: BitFieldIndex, ) -> Option<Self>

Source

pub fn all_but_single_bit_full(bit_idx: BitFieldIndex) -> Self

Source

pub fn all_but_single_bit_full_checked(bit_idx: BitFieldIndex) -> Option<Self>

Source§

impl<T: PrimInt> BitField<T>

Source

pub const fn into_inner(self) -> T

Consumes the BitField, returning the wrapped value.

Source

pub fn nb_elements(&self) -> usize

Returns the number of elements present.

Source§

impl<T: PrimInt> BitField<T>

Source

pub const SIZE: BitFieldSize

The maximum number of elements that can be tracked.

Trait Implementations§

Source§

impl<T: PrimInt> BitAnd for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<T: PrimInt> BitAndAssign for BitField<T>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<T: PrimInt> BitOr for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<T: PrimInt> BitOrAssign for BitField<T>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<T: PrimInt> BitXor for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T: PrimInt> BitXorAssign for BitField<T>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<T: Clone + PrimInt> Clone for BitField<T>

Source§

fn clone(&self) -> BitField<T>

Returns a duplicate 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<T: Debug + PrimInt> Debug for BitField<T>

Source§

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

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

impl<T: PrimInt> Deref for BitField<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: PrimInt> DerefMut for BitField<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: PrimInt> From<T> for BitField<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + PrimInt> Hash for BitField<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PrimInt> Not for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T: Ord + PrimInt> Ord for BitField<T>

Source§

fn cmp(&self, other: &BitField<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + PrimInt> PartialEq for BitField<T>

Source§

fn eq(&self, other: &BitField<T>) -> 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<T: PartialOrd + PrimInt> PartialOrd for BitField<T>

Source§

fn partial_cmp(&self, other: &BitField<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PrimInt> Shl<u8> for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u8) -> Self::Output

Performs the << operation. Read more
Source§

impl<T: PrimInt> ShlAssign<u8> for BitField<T>

Source§

fn shl_assign(&mut self, rhs: u8)

Performs the <<= operation. Read more
Source§

impl<T: PrimInt> Shr<u8> for BitField<T>

Source§

type Output = BitField<T>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u8) -> Self::Output

Performs the >> operation. Read more
Source§

impl<T: PrimInt> ShrAssign<u8> for BitField<T>

Source§

fn shr_assign(&mut self, rhs: u8)

Performs the >>= operation. Read more
Source§

impl<T: Copy + PrimInt> Copy for BitField<T>

Source§

impl<T: Eq + PrimInt> Eq for BitField<T>

Source§

impl<T: PrimInt> StructuralPartialEq for BitField<T>

Auto Trait Implementations§

§

impl<T> Freeze for BitField<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for BitField<T>
where T: RefUnwindSafe,

§

impl<T> Send for BitField<T>
where T: Send,

§

impl<T> Sync for BitField<T>
where T: Sync,

§

impl<T> Unpin for BitField<T>
where T: Unpin,

§

impl<T> UnwindSafe for BitField<T>
where T: UnwindSafe,

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.