Struct ubits::example::ExampleField
source · [−]pub struct ExampleField(_);Expand description
Optional docstring for my example bit field.
Implementations
sourceimpl ExampleField
impl ExampleField
Constant values describing ExampleField.
sourcepub const BITS: usize
pub const BITS: usize
Number of bits in an instance of ExampleField.
sourcepub const BYTES: usize
pub const BYTES: usize
Number of bytes used by an instance of ExampleField.
sourcepub const MAX: u8
pub const MAX: u8
Maximum valid integer for ExampleField.
sourceimpl ExampleField
impl ExampleField
Constructors for creating instances of ExampleField.
sourcepub fn new(value: u8) -> Self
pub fn new(value: u8) -> Self
Create a new instance of ExampleField from a u8 value.
sourcepub fn zeros() -> Self
pub fn zeros() -> Self
Create a new instance of ExampleField from 0.
sourcepub fn ones() -> Self
pub fn ones() -> Self
Create a new instance of ExampleField from the maximum possible integer value.
sourcepub fn from_binary_str(value: &str) -> Self
pub fn from_binary_str(value: &str) -> Self
Create a new instance of ExampleField from a binary string.
sourcepub fn from_binary_string(value: String) -> Self
pub fn from_binary_string(value: String) -> Self
Create a new instance of ExampleField from a binary string.
sourceimpl ExampleField
impl ExampleField
Current state of this bitfield.
sourceimpl ExampleField
impl ExampleField
Field accessors by index for ExampleField.
sourcepub fn get_index(&self, index: u8) -> bool
pub fn get_index(&self, index: u8) -> bool
Returns the value of the bit at the supplied index as a boolean.
sourcepub fn clear_index(&mut self, index: u8)
pub fn clear_index(&mut self, index: u8)
Sets the value of the bit at the supplied index to 0.
sourcepub fn toggle_index(&mut self, index: u8)
pub fn toggle_index(&mut self, index: u8)
Flips the value of the bit at the supplied index.
sourceimpl ExampleField
impl ExampleField
Named field accessors by ExampleFlags for ExampleField.
sourcepub fn get(&self, flag: ExampleFlags) -> bool
pub fn get(&self, flag: ExampleFlags) -> bool
Returns the value of the bit at the supplied flag as a boolean.
sourcepub fn set(&mut self, flag: ExampleFlags) -> &mut Self
pub fn set(&mut self, flag: ExampleFlags) -> &mut Self
Sets the value of the bit at the supplied flag to 1.
sourcepub fn clear(&mut self, flag: ExampleFlags) -> &mut Self
pub fn clear(&mut self, flag: ExampleFlags) -> &mut Self
Sets the value of the bit at the supplied flag to 0.
sourcepub fn toggle(&mut self, flag: ExampleFlags) -> &mut Self
pub fn toggle(&mut self, flag: ExampleFlags) -> &mut Self
Flips the value of the bit at the supplied flag.
sourceimpl ExampleField
impl ExampleField
Combinators for ExampleField.
sourcepub fn diff(&self, other: Self) -> Self
pub fn diff(&self, other: Self) -> Self
Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.
sourcepub fn combine(&self, other: Self) -> Self
pub fn combine(&self, other: Self) -> Self
Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.
sourcepub fn intersect(&self, other: Self) -> Self
pub fn intersect(&self, other: Self) -> Self
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.
sourceimpl ExampleField
impl ExampleField
Conversion methods.
sourcepub fn into_diff(self, other: Self) -> Self
pub fn into_diff(self, other: Self) -> Self
Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.
sourcepub fn into_combined(self, other: Self) -> Self
pub fn into_combined(self, other: Self) -> Self
Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.
sourcepub fn into_intersection(self, other: Self) -> Self
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
sourceimpl Binary for ExampleField
impl Binary for ExampleField
sourceimpl BitAnd<ExampleField> for ExampleField
impl BitAnd<ExampleField> for ExampleField
sourceimpl BitAnd<ExampleFlags> for ExampleField
impl BitAnd<ExampleFlags> for ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the & operator.
sourcefn bitand(self, rhs: ExampleFlags) -> Self::Output
fn bitand(self, rhs: ExampleFlags) -> Self::Output
Performs the & operation. Read more
sourceimpl BitAnd<ExampleFlags> for &ExampleField
impl BitAnd<ExampleFlags> for &ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the & operator.
sourcefn bitand(self, rhs: ExampleFlags) -> Self::Output
fn bitand(self, rhs: ExampleFlags) -> Self::Output
Performs the & operation. Read more
sourceimpl BitAnd<ExampleFlags> for &mut ExampleField
impl BitAnd<ExampleFlags> for &mut ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the & operator.
sourcefn bitand(self, rhs: ExampleFlags) -> Self::Output
fn bitand(self, rhs: ExampleFlags) -> Self::Output
Performs the & operation. Read more
sourceimpl BitAndAssign<ExampleField> for ExampleField
impl BitAndAssign<ExampleField> for ExampleField
sourcefn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the &= operation. Read more
sourceimpl BitAndAssign<ExampleFlags> for ExampleField
impl BitAndAssign<ExampleFlags> for ExampleField
sourcefn bitand_assign(&mut self, rhs: ExampleFlags)
fn bitand_assign(&mut self, rhs: ExampleFlags)
Performs the &= operation. Read more
sourceimpl BitOr<ExampleField> for ExampleField
impl BitOr<ExampleField> for ExampleField
sourceimpl BitOr<ExampleFlags> for ExampleField
impl BitOr<ExampleFlags> for ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the | operator.
sourcefn bitor(self, rhs: ExampleFlags) -> Self::Output
fn bitor(self, rhs: ExampleFlags) -> Self::Output
Performs the | operation. Read more
sourceimpl BitOr<ExampleFlags> for &ExampleField
impl BitOr<ExampleFlags> for &ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the | operator.
sourcefn bitor(self, rhs: ExampleFlags) -> Self::Output
fn bitor(self, rhs: ExampleFlags) -> Self::Output
Performs the | operation. Read more
sourceimpl BitOr<ExampleFlags> for &mut ExampleField
impl BitOr<ExampleFlags> for &mut ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the | operator.
sourcefn bitor(self, rhs: ExampleFlags) -> Self::Output
fn bitor(self, rhs: ExampleFlags) -> Self::Output
Performs the | operation. Read more
sourceimpl BitOrAssign<ExampleField> for ExampleField
impl BitOrAssign<ExampleField> for ExampleField
sourcefn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the |= operation. Read more
sourceimpl BitOrAssign<ExampleFlags> for ExampleField
impl BitOrAssign<ExampleFlags> for ExampleField
sourcefn bitor_assign(&mut self, rhs: ExampleFlags)
fn bitor_assign(&mut self, rhs: ExampleFlags)
Performs the |= operation. Read more
sourceimpl BitXor<ExampleField> for ExampleField
impl BitXor<ExampleField> for ExampleField
sourceimpl BitXor<ExampleFlags> for ExampleField
impl BitXor<ExampleFlags> for ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the ^ operator.
sourcefn bitxor(self, rhs: ExampleFlags) -> Self::Output
fn bitxor(self, rhs: ExampleFlags) -> Self::Output
Performs the ^ operation. Read more
sourceimpl BitXor<ExampleFlags> for &ExampleField
impl BitXor<ExampleFlags> for &ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the ^ operator.
sourcefn bitxor(self, rhs: ExampleFlags) -> Self::Output
fn bitxor(self, rhs: ExampleFlags) -> Self::Output
Performs the ^ operation. Read more
sourceimpl BitXor<ExampleFlags> for &mut ExampleField
impl BitXor<ExampleFlags> for &mut ExampleField
type Output = ExampleField
type Output = ExampleField
The resulting type after applying the ^ operator.
sourcefn bitxor(self, rhs: ExampleFlags) -> Self::Output
fn bitxor(self, rhs: ExampleFlags) -> Self::Output
Performs the ^ operation. Read more
sourceimpl BitXorAssign<ExampleField> for ExampleField
impl BitXorAssign<ExampleField> for ExampleField
sourcefn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the ^= operation. Read more
sourceimpl BitXorAssign<ExampleFlags> for ExampleField
impl BitXorAssign<ExampleFlags> for ExampleField
sourcefn bitxor_assign(&mut self, rhs: ExampleFlags)
fn bitxor_assign(&mut self, rhs: ExampleFlags)
Performs the ^= operation. Read more
sourceimpl Debug for ExampleField
impl Debug for ExampleField
sourceimpl Default for ExampleField
impl Default for ExampleField
sourceimpl From<ExampleFlags> for ExampleField
impl From<ExampleFlags> for ExampleField
Returns a field instance from a flag.
sourcefn from(value: ExampleFlags) -> ExampleField
fn from(value: ExampleFlags) -> ExampleField
Performs the conversion.
sourceimpl From<u8> for ExampleField
impl From<u8> for ExampleField
Returns a field instance from value of its underlying type.
sourcefn from(value: u8) -> ExampleField
fn from(value: u8) -> ExampleField
Performs the conversion.
sourceimpl PartialEq<ExampleField> for ExampleField
impl PartialEq<ExampleField> for ExampleField
sourcefn eq(&self, other: &ExampleField) -> bool
fn eq(&self, other: &ExampleField) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &ExampleField) -> bool
fn ne(&self, other: &ExampleField) -> bool
This method tests for !=.
impl StructuralPartialEq for ExampleField
Auto Trait Implementations
impl RefUnwindSafe for ExampleField
impl Send for ExampleField
impl Sync for ExampleField
impl Unpin for ExampleField
impl UnwindSafe for ExampleField
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more