pub struct ExampleBitfieldCustom { /* private fields */ }
doc
or test
) and crate feature _bit_u8
only.Expand description
An example created with bitfield!
,
with public custom fields but no extra methods.
use devela::bitfield;
bitfield! {
(custom)
/// An example created with [`bitfield!`],
/// with public custom fields but no extra methods.
pub struct ExampleBitfieldCustom(u8) {
/// 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
§Custom fields operations
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
§FLAG1
single field operations
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
Whether the FLAG1
field is set.
Sourcepub const fn bits_field_flag1(self) -> u32 ⓘ
pub const fn bits_field_flag1(self) -> u32 ⓘ
The size in bits of the FLAG1
field.
Sourcepub const fn get_field_flag1(self) -> Self
pub const fn get_field_flag1(self) -> Self
A copy of self
with only the bits of FLAG1
field.
Sourcepub const fn set_field_flag1(self) -> Self
pub const fn set_field_flag1(self) -> Self
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 get_field_value_flag1(self) -> Self
pub const fn get_field_value_flag1(self) -> Self
The value at the bit range of FLAG1
field.
Sourcepub const fn set_field_value_flag1(self, value: u8) -> Self
pub const fn set_field_value_flag1(self, value: u8) -> Self
Sets the value
into the bitrange of FLAG1
field.
Sourcepub const fn unset_field_flag1(self) -> Self
pub const fn unset_field_flag1(self) -> Self
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
§FLAG2
single field operations
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
Whether the FLAG2
field is set.
Sourcepub const fn bits_field_flag2(self) -> u32 ⓘ
pub const fn bits_field_flag2(self) -> u32 ⓘ
The size in bits of the FLAG2
field.
Sourcepub const fn get_field_flag2(self) -> Self
pub const fn get_field_flag2(self) -> Self
A copy of self
with only the bits of FLAG2
field.
Sourcepub const fn set_field_flag2(self) -> Self
pub const fn set_field_flag2(self) -> Self
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 get_field_value_flag2(self) -> Self
pub const fn get_field_value_flag2(self) -> Self
The value at the bit range of FLAG2
field.
Sourcepub const fn set_field_value_flag2(self, value: u8) -> Self
pub const fn set_field_value_flag2(self, value: u8) -> Self
Sets the value
into the bitrange of FLAG2
field.
Sourcepub const fn unset_field_flag2(self) -> Self
pub const fn unset_field_flag2(self) -> Self
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
§MASK0
single field operations
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
Whether the MASK0
field is set.
Sourcepub const fn bits_field_mask0(self) -> u32 ⓘ
pub const fn bits_field_mask0(self) -> u32 ⓘ
The size in bits of the MASK0
field.
Sourcepub const fn get_field_mask0(self) -> Self
pub const fn get_field_mask0(self) -> Self
A copy of self
with only the bits of MASK0
field.
Sourcepub const fn set_field_mask0(self) -> Self
pub const fn set_field_mask0(self) -> Self
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 get_field_value_mask0(self) -> Self
pub const fn get_field_value_mask0(self) -> Self
The value at the bit range of MASK0
field.
Sourcepub const fn set_field_value_mask0(self, value: u8) -> Self
pub const fn set_field_value_mask0(self, value: u8) -> Self
Sets the value
into the bitrange of MASK0
field.
Sourcepub const fn unset_field_mask0(self) -> Self
pub const fn unset_field_mask0(self) -> Self
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§impl PartialOrd for ExampleBitfieldCustom
impl PartialOrd for ExampleBitfieldCustom
Source§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> 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> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.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> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more