pub struct ExampleBitfieldCustom { /* private fields */ }
Expand description
An example created with bitfield!
,
with public custom fields but no extra methods.
use devela::data::bitfield;
bitfield! {
(custom)
/// An example created with [`bitfield!`],
/// with public custom fields but no extra methods.
pub struct ExampleBitfieldCustom(u16) {
/// Documentation for the first field.
FLAG1: 0;
/// Documentation for the second field.
FLAG2: 1;
MASK: 0, 1;
}
}
let mut b = ExampleBitfieldCustom::with_field_mask();
assert![b.is_field_mask()];
assert![b.is_field_flag1()];
assert![b.is_field_flag2()];
let _c = b.unset_field_flag1();
Implementations§
source§impl ExampleBitfieldCustom
impl ExampleBitfieldCustom
§Custom fields operations
sourcepub const fn without_fields() -> Self
pub const fn without_fields() -> Self
Returns a new ExampleBitfieldCustom
with none of the fields set.
sourcepub const fn with_all_fields() -> Self
pub const fn with_all_fields() -> Self
Returns a new ExampleBitfieldCustom
with all the fields set.
sourcepub const fn are_all_fields(self) -> bool
pub const fn are_all_fields(self) -> bool
Returns true
if it all the fields are set.
source§impl ExampleBitfieldCustom
impl ExampleBitfieldCustom
§FLAG1
single field operations
sourcepub const fn with_field_flag1() -> Self
pub const fn with_field_flag1() -> Self
Returns a new ExampleBitfieldCustom
with FLAG1
field set.
sourcepub const fn is_field_flag1(self) -> bool
pub const fn is_field_flag1(self) -> bool
Returns true
if the FLAG1
field is set.
sourcepub const fn bits_field_flag1(self) -> u32
pub const fn bits_field_flag1(self) -> u32
Returns the size of the field in bits.
sourcepub const fn get_field_flag1(self) -> Self
pub const fn get_field_flag1(self) -> Self
Gets a copy of self
with only the bits of FLAG1
field.
sourcepub const fn get_field_value_flag1(self) -> Self
pub const fn get_field_value_flag1(self) -> Self
Gets the value of the bits of FLAG1
field.
sourcepub const fn set_field_flag1(self) -> Self
pub const fn set_field_flag1(self) -> Self
Returns a copy of self
with the FLAG1
field set.
sourcepub fn mut_set_field_flag1(&mut self)
pub fn mut_set_field_flag1(&mut self)
Sets the FLAG1
field.
sourcepub const fn set_field_value_flag1(self, value: u16) -> Self
pub const fn set_field_value_flag1(self, value: u16) -> Self
Sets the given value
into the bits of FLAG1
field.
sourcepub const fn unset_field_flag1(self) -> Self
pub const fn unset_field_flag1(self) -> Self
Returns a copy of self
with the FLAG1
field set.
sourcepub fn mut_unset_field_flag1(&mut self)
pub fn mut_unset_field_flag1(&mut self)
Unsets the FLAG1
field.
sourcepub const fn flip_field_flag1(self) -> Self
pub const fn flip_field_flag1(self) -> Self
Returns a copy of self
with the FLAG1
field flipped.
sourcepub fn mut_flip_field_flag1(&mut self)
pub fn mut_flip_field_flag1(&mut self)
Flips the FLAG1
field.
source§impl ExampleBitfieldCustom
impl ExampleBitfieldCustom
§FLAG2
single field operations
sourcepub const fn with_field_flag2() -> Self
pub const fn with_field_flag2() -> Self
Returns a new ExampleBitfieldCustom
with FLAG2
field set.
sourcepub const fn is_field_flag2(self) -> bool
pub const fn is_field_flag2(self) -> bool
Returns true
if the FLAG2
field is set.
sourcepub const fn bits_field_flag2(self) -> u32
pub const fn bits_field_flag2(self) -> u32
Returns the size of the field in bits.
sourcepub const fn get_field_flag2(self) -> Self
pub const fn get_field_flag2(self) -> Self
Gets a copy of self
with only the bits of FLAG2
field.
sourcepub const fn get_field_value_flag2(self) -> Self
pub const fn get_field_value_flag2(self) -> Self
Gets the value of the bits of FLAG2
field.
sourcepub const fn set_field_flag2(self) -> Self
pub const fn set_field_flag2(self) -> Self
Returns a copy of self
with the FLAG2
field set.
sourcepub fn mut_set_field_flag2(&mut self)
pub fn mut_set_field_flag2(&mut self)
Sets the FLAG2
field.
sourcepub const fn set_field_value_flag2(self, value: u16) -> Self
pub const fn set_field_value_flag2(self, value: u16) -> Self
Sets the given value
into the bits of FLAG2
field.
sourcepub const fn unset_field_flag2(self) -> Self
pub const fn unset_field_flag2(self) -> Self
Returns a copy of self
with the FLAG2
field set.
sourcepub fn mut_unset_field_flag2(&mut self)
pub fn mut_unset_field_flag2(&mut self)
Unsets the FLAG2
field.
sourcepub const fn flip_field_flag2(self) -> Self
pub const fn flip_field_flag2(self) -> Self
Returns a copy of self
with the FLAG2
field flipped.
sourcepub fn mut_flip_field_flag2(&mut self)
pub fn mut_flip_field_flag2(&mut self)
Flips the FLAG2
field.
source§impl ExampleBitfieldCustom
impl ExampleBitfieldCustom
§MASK0
single field operations
sourcepub const fn with_field_mask0() -> Self
pub const fn with_field_mask0() -> Self
Returns a new ExampleBitfieldCustom
with MASK0
field set.
sourcepub const fn is_field_mask0(self) -> bool
pub const fn is_field_mask0(self) -> bool
Returns true
if the MASK0
field is set.
sourcepub const fn bits_field_mask0(self) -> u32
pub const fn bits_field_mask0(self) -> u32
Returns the size of the field in bits.
sourcepub const fn get_field_mask0(self) -> Self
pub const fn get_field_mask0(self) -> Self
Gets a copy of self
with only the bits of MASK0
field.
sourcepub const fn get_field_value_mask0(self) -> Self
pub const fn get_field_value_mask0(self) -> Self
Gets the value of the bits of MASK0
field.
sourcepub const fn set_field_mask0(self) -> Self
pub const fn set_field_mask0(self) -> Self
Returns a copy of self
with the MASK0
field set.
sourcepub fn mut_set_field_mask0(&mut self)
pub fn mut_set_field_mask0(&mut self)
Sets the MASK0
field.
sourcepub const fn set_field_value_mask0(self, value: u16) -> Self
pub const fn set_field_value_mask0(self, value: u16) -> Self
Sets the given value
into the bits of MASK0
field.
sourcepub const fn unset_field_mask0(self) -> Self
pub const fn unset_field_mask0(self) -> Self
Returns a copy of self
with the MASK0
field set.
sourcepub fn mut_unset_field_mask0(&mut self)
pub fn mut_unset_field_mask0(&mut self)
Unsets the MASK0
field.
sourcepub const fn flip_field_mask0(self) -> Self
pub const fn flip_field_mask0(self) -> Self
Returns a copy of self
with the MASK0
field flipped.
sourcepub fn mut_flip_field_mask0(&mut self)
pub fn mut_flip_field_mask0(&mut self)
Flips the MASK0
field.
Trait Implementations§
source§impl Binary for ExampleBitfieldCustom
impl Binary for ExampleBitfieldCustom
source§impl Clone for ExampleBitfieldCustom
impl Clone for ExampleBitfieldCustom
source§fn clone(&self) -> ExampleBitfieldCustom
fn clone(&self) -> ExampleBitfieldCustom
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExampleBitfieldCustom
impl Debug for ExampleBitfieldCustom
source§impl Default for ExampleBitfieldCustom
impl Default for ExampleBitfieldCustom
source§impl Display for ExampleBitfieldCustom
impl Display for ExampleBitfieldCustom
source§impl Hash for ExampleBitfieldCustom
impl Hash for ExampleBitfieldCustom
source§impl LowerExp for ExampleBitfieldCustom
impl LowerExp for ExampleBitfieldCustom
source§impl LowerHex for ExampleBitfieldCustom
impl LowerHex for ExampleBitfieldCustom
source§impl Octal for ExampleBitfieldCustom
impl Octal for ExampleBitfieldCustom
source§impl Ord for ExampleBitfieldCustom
impl Ord for ExampleBitfieldCustom
source§fn cmp(&self, other: &ExampleBitfieldCustom) -> Ordering
fn cmp(&self, other: &ExampleBitfieldCustom) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ExampleBitfieldCustom
impl PartialEq for ExampleBitfieldCustom
source§fn eq(&self, other: &ExampleBitfieldCustom) -> bool
fn eq(&self, other: &ExampleBitfieldCustom) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ExampleBitfieldCustom
impl PartialOrd for ExampleBitfieldCustom
source§fn partial_cmp(&self, other: &ExampleBitfieldCustom) -> Option<Ordering>
fn partial_cmp(&self, other: &ExampleBitfieldCustom) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl UpperExp for ExampleBitfieldCustom
impl UpperExp for ExampleBitfieldCustom
source§impl UpperHex for ExampleBitfieldCustom
impl UpperHex for ExampleBitfieldCustom
impl Copy for ExampleBitfieldCustom
impl Eq for ExampleBitfieldCustom
impl StructuralPartialEq for ExampleBitfieldCustom
Auto Trait Implementations§
impl Freeze for ExampleBitfieldCustom
impl RefUnwindSafe for ExampleBitfieldCustom
impl Send for ExampleBitfieldCustom
impl Sync for ExampleBitfieldCustom
impl Unpin for ExampleBitfieldCustom
impl UnwindSafe for ExampleBitfieldCustom
Blanket Implementations§
source§impl<T> Also for T
impl<T> Also for T
source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ByteSize for T
impl<T> ByteSize for T
source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> ExtAny for Twhere
T: Any,
impl<T> ExtAny for Twhere
T: Any,
source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
source§impl<T> Mem for Twhere
T: ?Sized,
impl<T> Mem for Twhere
T: ?Sized,
source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters.source§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor.source§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
self
with other, returning the previous value of self
.source§fn mem_take(&mut self) -> Selfwhere
Self: Default,
fn mem_take(&mut self) -> Selfwhere
Self: Default,
self
with its default value, returning the previous value of self
.source§fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
self
and other
without deinitializing either one.source§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.