BitfieldStruct24

Struct BitfieldStruct24 

Source
pub struct BitfieldStruct24 { /* private fields */ }
Expand description

A bitfield struct 24 bits wide.

This type is narrower than its primitive type—there is no from_primitive method, and TryFrom<u32> is provided for fallible conversion.

§Declaration

bitfield! {
    #[lsb_first]
    pub struct BitfieldStruct24: 24 {
        /// A 1-bit field with [`U1`] accessors.
        pub bit: 1,
        /// A 1-bit field with [`bool`] accessors.
        pub flag: 1 as bool,
        /// A 5-bit field with [`U5`] accessors.
        pub multi_bit: 5,
        /// A 3-bit field with [`CustomBitint3`] accessors.
        pub custom_bitint: 3 as CustomBitint3,
        /// An 8-bit field with [`CustomPrimitive8`] accessors.
        pub custom_primitive: 8 as CustomPrimitive8,
        ..
    }
}

This type is a generated bitfield struct. The bitint type is U24 and the primitive type is u32.

§Fields

§bit

A 1-bit field with U1 accessors.

§flag

A 1-bit field with bool accessors.

§multi_bit

A 5-bit field with U5 accessors.

§custom_bitint

A 3-bit field with CustomBitint3 accessors.

§custom_primitive

An 8-bit field with CustomPrimitive8 accessors.

Implementations§

Source§

impl BitfieldStruct24

Source

pub const ZERO: Self

The type’s zero value.

Source

pub const fn zero() -> Self

Returns the type’s zero value.

This method is a const variant of Bitfield::zero.

Source

pub const fn new(value: u32) -> Option<Self>

Creates a bitfield value from a primitive value if it is in range for the bitint type.

This method is a const variant of Bitfield::new.

Source

pub const fn new_masked(value: u32) -> Self

Creates a bitfield value by masking off the upper bits of a primitive value.

This method is a const variant of Bitfield::new_masked.

Source

pub const unsafe fn new_unchecked(value: u32) -> Self

Creates a bitfield value from a primitive value without checking whether it is in range for the bitint type.

This method is a const variant of Bitfield::new_unchecked.

§Safety

The value must be in range for the bitint type, as determined by UBitint::is_in_range.

Source

pub const fn from_bitint(value: U24) -> Self

Creates a bitfield value from a bitint value.

This is a zero-cost conversion.

Source

pub const fn to_bitint(self) -> U24

Converts the value to a bitint.

This is a zero-cost conversion.

Source

pub const fn to_primitive(self) -> u32

Converts the value to the primitive type.

The result is in range for the bitint type, as determined by UBitint::is_in_range.

This zero-cost conversion is a convenience alias for converting through the bitint type.

Source

pub fn bit(self) -> U1

Extracts the bit field.

§Field

A 1-bit field with U1 accessors.

Source

pub fn with_bit(self, value: U1) -> Self

Creates a new value with the given bit field.

§Field

A 1-bit field with U1 accessors.

Source

pub fn map_bit(self, f: impl FnOnce(U1) -> U1) -> Self

Creates a new value by mapping the bit field to a new one.

§Field

A 1-bit field with U1 accessors.

Source

pub fn set_bit(&mut self, value: U1)

Sets the bit field.

§Field

A 1-bit field with U1 accessors.

Source

pub fn replace_bit(&mut self, value: U1) -> U1

Replaces the bit field and returns the old value.

§Field

A 1-bit field with U1 accessors.

Source

pub fn update_bit(&mut self, f: impl FnOnce(U1) -> U1) -> U1

Updates the bit field using a function and returns the old value.

§Field

A 1-bit field with U1 accessors.

Source

pub fn flag(self) -> bool

Extracts the flag field.

§Field

A 1-bit field with bool accessors.

Source

pub fn with_flag(self, value: bool) -> Self

Creates a new value with the given flag field.

§Field

A 1-bit field with bool accessors.

Source

pub fn map_flag(self, f: impl FnOnce(bool) -> bool) -> Self

Creates a new value by mapping the flag field to a new one.

§Field

A 1-bit field with bool accessors.

Source

pub fn set_flag(&mut self, value: bool)

Sets the flag field.

§Field

A 1-bit field with bool accessors.

Source

pub fn replace_flag(&mut self, value: bool) -> bool

Replaces the flag field and returns the old value.

§Field

A 1-bit field with bool accessors.

Source

pub fn update_flag(&mut self, f: impl FnOnce(bool) -> bool) -> bool

Updates the flag field using a function and returns the old value.

§Field

A 1-bit field with bool accessors.

Source

pub fn multi_bit(self) -> U5

Extracts the multi_bit field.

§Field

A 5-bit field with U5 accessors.

Source

pub fn with_multi_bit(self, value: U5) -> Self

Creates a new value with the given multi_bit field.

§Field

A 5-bit field with U5 accessors.

Source

pub fn map_multi_bit(self, f: impl FnOnce(U5) -> U5) -> Self

Creates a new value by mapping the multi_bit field to a new one.

§Field

A 5-bit field with U5 accessors.

Source

pub fn set_multi_bit(&mut self, value: U5)

Sets the multi_bit field.

§Field

A 5-bit field with U5 accessors.

Source

pub fn replace_multi_bit(&mut self, value: U5) -> U5

Replaces the multi_bit field and returns the old value.

§Field

A 5-bit field with U5 accessors.

Source

pub fn update_multi_bit(&mut self, f: impl FnOnce(U5) -> U5) -> U5

Updates the multi_bit field using a function and returns the old value.

§Field

A 5-bit field with U5 accessors.

Source

pub fn custom_bitint(self) -> CustomBitint3

Extracts the custom_bitint field.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn with_custom_bitint(self, value: CustomBitint3) -> Self

Creates a new value with the given custom_bitint field.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn map_custom_bitint( self, f: impl FnOnce(CustomBitint3) -> CustomBitint3, ) -> Self

Creates a new value by mapping the custom_bitint field to a new one.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn set_custom_bitint(&mut self, value: CustomBitint3)

Sets the custom_bitint field.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn replace_custom_bitint(&mut self, value: CustomBitint3) -> CustomBitint3

Replaces the custom_bitint field and returns the old value.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn update_custom_bitint( &mut self, f: impl FnOnce(CustomBitint3) -> CustomBitint3, ) -> CustomBitint3

Updates the custom_bitint field using a function and returns the old value.

§Field

A 3-bit field with CustomBitint3 accessors.

Source

pub fn custom_primitive(self) -> CustomPrimitive8

Extracts the custom_primitive field.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Source

pub fn with_custom_primitive(self, value: CustomPrimitive8) -> Self

Creates a new value with the given custom_primitive field.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Source

pub fn map_custom_primitive( self, f: impl FnOnce(CustomPrimitive8) -> CustomPrimitive8, ) -> Self

Creates a new value by mapping the custom_primitive field to a new one.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Source

pub fn set_custom_primitive(&mut self, value: CustomPrimitive8)

Sets the custom_primitive field.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Source

pub fn replace_custom_primitive( &mut self, value: CustomPrimitive8, ) -> CustomPrimitive8

Replaces the custom_primitive field and returns the old value.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Source

pub fn update_custom_primitive( &mut self, f: impl FnOnce(CustomPrimitive8) -> CustomPrimitive8, ) -> CustomPrimitive8

Updates the custom_primitive field using a function and returns the old value.

§Field

An 8-bit field with CustomPrimitive8 accessors.

Trait Implementations§

Source§

impl Bitfield for BitfieldStruct24

Available on doc only.
Source§

const ZERO: Self = Self::ZERO

The type’s zero value.
Source§

type Bitint = U24

The bitfield’s canonical integer representation.
Source§

type Primitive = u32

The bitint type’s primitive type.
Source§

fn new(value: u32) -> Option<Self>

Creates a bitfield value from a primitive value if it is in range for the bitint type.
Source§

fn new_masked(value: u32) -> Self

Creates a bitfield value by masking off the upper bits of a primitive value.
Source§

unsafe fn new_unchecked(value: u32) -> Self

Creates a bitfield value from a primitive value without checking whether it is in range for the bitint type. Read more
Source§

fn zero() -> Self

Returns the type’s zero value.
Source§

impl Clone for BitfieldStruct24

Available on doc only.
Source§

fn clone(&self) -> BitfieldStruct24

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 Debug for BitfieldStruct24

Available on doc only.
Source§

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

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

impl From<BitfieldStruct24> for U24

Available on doc only.
Source§

fn from(value: BitfieldStruct24) -> Self

Converts to this type from the input type.
Source§

impl From<BitfieldStruct24> for u32

Available on doc only.
Source§

fn from(value: BitfieldStruct24) -> Self

Converts to this type from the input type.
Source§

impl From<U24> for BitfieldStruct24

Available on doc only.
Source§

fn from(value: U24) -> Self

Converts to this type from the input type.
Source§

impl Hash for BitfieldStruct24

Available on doc only.
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 PartialEq for BitfieldStruct24

Available on doc only.
Source§

fn eq(&self, other: &BitfieldStruct24) -> 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 TryFrom<u32> for BitfieldStruct24

Available on doc only.
Source§

type Error = RangeError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for BitfieldStruct24

Available on doc only.
Source§

impl Eq for BitfieldStruct24

Available on doc only.
Source§

impl StructuralPartialEq for BitfieldStruct24

Available on doc only.

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§

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