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

source

pub const FLAG1: Self = _

Documentation for the first field.

source

pub const FLAG2: Self = _

Documentation for the first field.

source

pub const MASK0: Self = _

source§

impl ExampleBitfieldCustom

§Custom fields operations

source

pub const fn without_fields() -> Self

Returns a new ExampleBitfieldCustom with none of the fields set.

source

pub const fn with_all_fields() -> Self

Returns a new ExampleBitfieldCustom with all the fields set.

source

pub const fn are_all_fields(self) -> bool

Returns true if it all the fields are set.

source§

impl ExampleBitfieldCustom

§FLAG1 single field operations

source

pub const fn with_field_flag1() -> Self

Returns a new ExampleBitfieldCustom with FLAG1 field set.

source

pub const fn is_field_flag1(self) -> bool

Returns true if the FLAG1 field is set.

source

pub const fn bits_field_flag1(self) -> u32

Returns the size of the field in bits.

source

pub const fn get_field_flag1(self) -> Self

Gets a copy of self with only the bits of FLAG1 field.

source

pub const fn get_field_value_flag1(self) -> Self

Gets the value of the bits of FLAG1 field.

source

pub const fn set_field_flag1(self) -> Self

Returns a copy of self with the FLAG1 field set.

source

pub fn mut_set_field_flag1(&mut self)

Sets the FLAG1 field.

source

pub const fn set_field_value_flag1(self, value: u16) -> Self

Sets the given value into the bits of FLAG1 field.

source

pub const fn unset_field_flag1(self) -> Self

Returns a copy of self with the FLAG1 field set.

source

pub fn mut_unset_field_flag1(&mut self)

Unsets the FLAG1 field.

source

pub const fn flip_field_flag1(self) -> Self

Returns a copy of self with the FLAG1 field flipped.

source

pub fn mut_flip_field_flag1(&mut self)

Flips the FLAG1 field.

source§

impl ExampleBitfieldCustom

§FLAG2 single field operations

source

pub const fn with_field_flag2() -> Self

Returns a new ExampleBitfieldCustom with FLAG2 field set.

source

pub const fn is_field_flag2(self) -> bool

Returns true if the FLAG2 field is set.

source

pub const fn bits_field_flag2(self) -> u32

Returns the size of the field in bits.

source

pub const fn get_field_flag2(self) -> Self

Gets a copy of self with only the bits of FLAG2 field.

source

pub const fn get_field_value_flag2(self) -> Self

Gets the value of the bits of FLAG2 field.

source

pub const fn set_field_flag2(self) -> Self

Returns a copy of self with the FLAG2 field set.

source

pub fn mut_set_field_flag2(&mut self)

Sets the FLAG2 field.

source

pub const fn set_field_value_flag2(self, value: u16) -> Self

Sets the given value into the bits of FLAG2 field.

source

pub const fn unset_field_flag2(self) -> Self

Returns a copy of self with the FLAG2 field set.

source

pub fn mut_unset_field_flag2(&mut self)

Unsets the FLAG2 field.

source

pub const fn flip_field_flag2(self) -> Self

Returns a copy of self with the FLAG2 field flipped.

source

pub fn mut_flip_field_flag2(&mut self)

Flips the FLAG2 field.

source§

impl ExampleBitfieldCustom

§MASK0 single field operations

source

pub const fn with_field_mask0() -> Self

Returns a new ExampleBitfieldCustom with MASK0 field set.

source

pub const fn is_field_mask0(self) -> bool

Returns true if the MASK0 field is set.

source

pub const fn bits_field_mask0(self) -> u32

Returns the size of the field in bits.

source

pub const fn get_field_mask0(self) -> Self

Gets a copy of self with only the bits of MASK0 field.

source

pub const fn get_field_value_mask0(self) -> Self

Gets the value of the bits of MASK0 field.

source

pub const fn set_field_mask0(self) -> Self

Returns a copy of self with the MASK0 field set.

source

pub fn mut_set_field_mask0(&mut self)

Sets the MASK0 field.

source

pub const fn set_field_value_mask0(self, value: u16) -> Self

Sets the given value into the bits of MASK0 field.

source

pub const fn unset_field_mask0(self) -> Self

Returns a copy of self with the MASK0 field set.

source

pub fn mut_unset_field_mask0(&mut self)

Unsets the MASK0 field.

source

pub const fn flip_field_mask0(self) -> Self

Returns a copy of self with the MASK0 field flipped.

source

pub fn mut_flip_field_mask0(&mut self)

Flips the MASK0 field.

Trait Implementations§

source§

impl Binary for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl Clone for ExampleBitfieldCustom

source§

fn clone(&self) -> ExampleBitfieldCustom

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 ExampleBitfieldCustom

source§

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

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

impl Default for ExampleBitfieldCustom

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for ExampleBitfieldCustom

source§

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

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

impl Hash for ExampleBitfieldCustom

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 LowerExp for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl LowerHex for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl Octal for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl Ord for ExampleBitfieldCustom

source§

fn cmp(&self, other: &ExampleBitfieldCustom) -> 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 + PartialOrd,

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

impl PartialEq for ExampleBitfieldCustom

source§

fn eq(&self, other: &ExampleBitfieldCustom) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ExampleBitfieldCustom

source§

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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl UpperExp for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl UpperHex for ExampleBitfieldCustom

source§

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

Formats the value using the given formatter.
source§

impl Copy for ExampleBitfieldCustom

source§

impl Eq for ExampleBitfieldCustom

source§

impl StructuralPartialEq for ExampleBitfieldCustom

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Also for T

source§

fn also_mut<F: FnOnce(&mut Self)>(self, f: F) -> Self

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
source§

fn also_ref<F: FnOnce(&Self)>(self, f: F) -> Self

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
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, Res> Apply<Res> for T
where T: ?Sized,

source§

fn apply<F: FnOnce(Self) -> Res>(self, f: F) -> Res
where Self: Sized,

Apply a function which takes the parameter by value.
source§

fn apply_ref<F: FnOnce(&Self) -> Res>(&self, f: F) -> Res

Apply a function which takes the parameter by shared reference.
source§

fn apply_mut<F: FnOnce(&mut Self) -> Res>(&mut self, f: F) -> Res

Apply a function which takes the parameter by exclusive reference.
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> ByteSize for T

source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
source§

const PTR_SIZE: usize = 8usize

The size of a pointer in bytes, for the current platform.
source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between PTR_SIZE and BYTE_SIZE. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> ExtAny for T
where T: Any,

source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. 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> Mem for T
where T: ?Sized,

source§

const NEEDS_DROP: bool = _

Whether dropping values of this type matters.
source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters.
source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor.
source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor.
source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self.
source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self.
source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one.
source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8].
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.