pub struct ExampleField(/* private fields */);Expand description
Optional docstring for my example bit field.
Implementations§
Source§impl ExampleField
Constant values describing ExampleField.
impl ExampleField
Constant values describing ExampleField.
Sourcepub const BITS: usize = 8
pub const BITS: usize = 8
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 = u8::MAX
pub const MAX: u8 = u8::MAX
Maximum valid integer for ExampleField.
Source§impl ExampleField
Constructors for creating instances of 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.
Source§impl ExampleField
Current state of this bitfield.
impl ExampleField
Current state of this bitfield.
Source§impl ExampleField
Field accessors by index for 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.
Source§impl ExampleField
Named field accessors by ExampleFlags for 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.
Source§impl ExampleField
Combinators for 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.
Source§impl ExampleField
Conversion methods.
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§
Source§impl Binary for ExampleField
impl Binary for ExampleField
Source§impl BitAnd for ExampleField
impl BitAnd for ExampleField
Source§impl BitAnd<ExampleFlags> for ExampleField
impl BitAnd<ExampleFlags> for ExampleField
Source§type Output = ExampleField
type Output = ExampleField
& operator.Source§impl BitAnd<ExampleFlags> for &ExampleField
impl BitAnd<ExampleFlags> for &ExampleField
Source§type Output = ExampleField
type Output = ExampleField
& operator.Source§impl BitAnd<ExampleFlags> for &mut ExampleField
impl BitAnd<ExampleFlags> for &mut ExampleField
Source§type Output = ExampleField
type Output = ExampleField
& operator.Source§impl BitAndAssign for ExampleField
impl BitAndAssign for ExampleField
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitAndAssign<ExampleFlags> for ExampleField
impl BitAndAssign<ExampleFlags> for ExampleField
Source§fn bitand_assign(&mut self, rhs: ExampleFlags)
fn bitand_assign(&mut self, rhs: ExampleFlags)
&= operation. Read moreSource§impl BitOr for ExampleField
impl BitOr for ExampleField
Source§impl BitOr<ExampleFlags> for ExampleField
impl BitOr<ExampleFlags> for ExampleField
Source§type Output = ExampleField
type Output = ExampleField
| operator.Source§impl BitOr<ExampleFlags> for &ExampleField
impl BitOr<ExampleFlags> for &ExampleField
Source§type Output = ExampleField
type Output = ExampleField
| operator.Source§impl BitOr<ExampleFlags> for &mut ExampleField
impl BitOr<ExampleFlags> for &mut ExampleField
Source§type Output = ExampleField
type Output = ExampleField
| operator.Source§impl BitOrAssign for ExampleField
impl BitOrAssign for ExampleField
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitOrAssign<ExampleFlags> for ExampleField
impl BitOrAssign<ExampleFlags> for ExampleField
Source§fn bitor_assign(&mut self, rhs: ExampleFlags)
fn bitor_assign(&mut self, rhs: ExampleFlags)
|= operation. Read moreSource§impl BitXor for ExampleField
impl BitXor for ExampleField
Source§impl BitXor<ExampleFlags> for ExampleField
impl BitXor<ExampleFlags> for ExampleField
Source§type Output = ExampleField
type Output = ExampleField
^ operator.Source§impl BitXor<ExampleFlags> for &ExampleField
impl BitXor<ExampleFlags> for &ExampleField
Source§type Output = ExampleField
type Output = ExampleField
^ operator.Source§impl BitXor<ExampleFlags> for &mut ExampleField
impl BitXor<ExampleFlags> for &mut ExampleField
Source§type Output = ExampleField
type Output = ExampleField
^ operator.Source§impl BitXorAssign for ExampleField
impl BitXorAssign for ExampleField
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl BitXorAssign<ExampleFlags> for ExampleField
impl BitXorAssign<ExampleFlags> for ExampleField
Source§fn bitxor_assign(&mut self, rhs: ExampleFlags)
fn bitxor_assign(&mut self, rhs: ExampleFlags)
^= operation. Read moreSource§impl Clone for ExampleField
impl Clone for ExampleField
Source§fn clone(&self) -> ExampleField
fn clone(&self) -> ExampleField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ExampleField
Source§impl Debug for ExampleField
impl Debug for ExampleField
Source§impl Default for ExampleField
impl Default for ExampleField
Source§impl From<ExampleFlags> for ExampleField
Returns a field instance from a flag.
impl From<ExampleFlags> for ExampleField
Returns a field instance from a flag.
Source§fn from(value: ExampleFlags) -> ExampleField
fn from(value: ExampleFlags) -> ExampleField
Source§impl From<u8> for ExampleField
Returns a field instance from value of its underlying type.
impl From<u8> for ExampleField
Returns a field instance from value of its underlying type.