ExampleField

Struct ExampleField 

Source
pub struct ExampleField(/* private fields */);
Expand description

Optional docstring for my example bit field.

Implementations§

Source§

impl ExampleField

Constant values describing ExampleField.

Source

pub const BITS: usize = 8usize

Number of bits in an instance of ExampleField.

Source

pub const BYTES: usize = 1usize

Number of bytes used by an instance of ExampleField.

Source

pub const MAX: u8 = 255u8

Maximum valid integer for ExampleField.

Source§

impl ExampleField

Constructors for creating instances of ExampleField.

Source

pub fn new(value: u8) -> Self

Create a new instance of ExampleField from a u8 value.

Source

pub fn zeros() -> Self

Create a new instance of ExampleField from 0.

Source

pub fn ones() -> Self

Create a new instance of ExampleField from the maximum possible integer value.

Source

pub fn from_binary_str(value: &str) -> Self

Create a new instance of ExampleField from a binary string.

Source

pub fn from_binary_string(value: String) -> Self

Create a new instance of ExampleField from a binary string.

Source§

impl ExampleField

Current state of this bitfield.

Source

pub fn as_integer(&self) -> u8

Returns the current field value as a u8

Source

pub fn as_binary(&self) -> String

Returns the current field value as a binary formatted string.

Source§

impl ExampleField

Field accessors by index for ExampleField.

Source

pub fn get_index(&self, index: u8) -> bool

Returns the value of the bit at the supplied index as a boolean.

Source

pub fn set_index(&mut self, index: u8)

Sets the value of the bit at the supplied index to 1.

Source

pub fn clear_index(&mut self, index: u8)

Sets the value of the bit at the supplied index to 0.

Source

pub fn toggle_index(&mut self, index: u8)

Flips the value of the bit at the supplied index.

Source§

impl ExampleField

Named field accessors by ExampleFlags for ExampleField.

Source

pub fn get(&self, flag: ExampleFlags) -> bool

Returns the value of the bit at the supplied flag as a boolean.

Source

pub fn set(&mut self, flag: ExampleFlags) -> &mut Self

Sets the value of the bit at the supplied flag to 1.

Source

pub fn clear(&mut self, flag: ExampleFlags) -> &mut Self

Sets the value of the bit at the supplied flag to 0.

Source

pub fn toggle(&mut self, flag: ExampleFlags) -> &mut Self

Flips the value of the bit at the supplied flag.

Source§

impl ExampleField

Combinators for ExampleField.

Source

pub fn diff(&self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.

Source

pub fn combine(&self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.

Source

pub fn intersect(&self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.

Source§

impl ExampleField

Conversion methods.

Source

pub fn into_diff(self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.

Source

pub fn into_combined(self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.

Source

pub fn into_intersection(self, other: Self) -> Self

Returns a new ExampleFieldwith ones for flags that were set on both inputs. Consumes self.

Trait Implementations§

Source§

impl Binary for ExampleField

Source§

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

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

impl BitAnd<ExampleFlags> for &ExampleField

Source§

type Output = ExampleField

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAnd<ExampleFlags> for &mut ExampleField

Source§

type Output = ExampleField

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAnd<ExampleFlags> for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAnd for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign<ExampleFlags> for ExampleField

Source§

fn bitand_assign(&mut self, rhs: ExampleFlags)

Performs the &= operation. Read more
Source§

impl BitAndAssign for ExampleField

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr<ExampleFlags> for &ExampleField

Source§

type Output = ExampleField

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOr<ExampleFlags> for &mut ExampleField

Source§

type Output = ExampleField

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOr<ExampleFlags> for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOr for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign<ExampleFlags> for ExampleField

Source§

fn bitor_assign(&mut self, rhs: ExampleFlags)

Performs the |= operation. Read more
Source§

impl BitOrAssign for ExampleField

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor<ExampleFlags> for &ExampleField

Source§

type Output = ExampleField

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXor<ExampleFlags> for &mut ExampleField

Source§

type Output = ExampleField

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXor<ExampleFlags> for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXor for ExampleField

Source§

type Output = ExampleField

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign<ExampleFlags> for ExampleField

Source§

fn bitxor_assign(&mut self, rhs: ExampleFlags)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for ExampleField

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for ExampleField

Source§

fn clone(&self) -> ExampleField

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 ExampleField

Source§

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

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

impl Default for ExampleField

Source§

fn default() -> Self

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

impl From<ExampleFlags> for ExampleField

Returns a field instance from a flag.

Source§

fn from(value: ExampleFlags) -> ExampleField

Converts to this type from the input type.
Source§

impl From<u8> for ExampleField

Returns a field instance from value of its underlying type.

Source§

fn from(value: u8) -> ExampleField

Converts to this type from the input type.
Source§

impl PartialEq for ExampleField

Source§

fn eq(&self, other: &ExampleField) -> 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 PartialOrd for ExampleField

Source§

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

Source§

impl StructuralPartialEq for ExampleField

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