pub trait BitAccess: Radium where
<Self as Radium>::Item: BitRegister, {
fn clear_bits(&self, mask: BitMask<Self::Item>) { ... }
fn set_bits(&self, mask: BitMask<Self::Item>) { ... }
fn invert_bits(&self, mask: BitMask<Self::Item>) { ... }
fn write_bit<O>(&self, index: BitIdx<Self::Item>, value: bool)
where
O: BitOrder,
{ ... }
fn get_writers(
value: bool
) -> for<'a> fn(_: &'a Self, _: BitMask<Self::Item>) { ... }
}
Expand description
Abstracts over the instructions used when accessing a memory location.
This trait provides functions to manipulate bits in a referent memory register through the appropriate access instructions, so that use sites elsewhere in the crate can select their required behavior without changing their interface.
This is automatically implemented for all types that permit shared/mutable
memory access to memory registers through the radium
crate. Its use is
constrained in the store
module.
This trait is only ever used by bitvec
internals, and is never exposed
outside the crate. It must be marked as public so that it can be used as an
associated item in BitStore
, even though it is never made accessible.
Provided methods
fn clear_bits(&self, mask: BitMask<Self::Item>)
fn clear_bits(&self, mask: BitMask<Self::Item>)
Clears any number of bits in a memory register to 0
.
The mask provided to this method must be constructed from indices that are valid in the caller’s context. As the mask is already computed by the caller, this does not take an ordering type parameter.
Parameters
&self
mask
: A mask of any number of bits. This is a selection mask: all bits in the mask that are set to1
will be modified in the element at*self
.
Effects
All bits in *self
that are selected (set to 1
in the mask
) will be
cleared. All bits in *self
that are not selected (cleared to 0
in
the mask
) are unchanged.
Do not invert the mask
prior to calling this function in order to save
the unselected bits and clear the selected bits. BitMask
is a
selection type, not a bitwise-operation argument.
Sets any number of bits in a memory register to 1
.
The mask provided to this method must be constructed from indices that are valid in the caller’s context. As the mask is already computed by the caller, this does not take an ordering type parameter.
Parameters
&self
mask
: A mask of any number of bits. This is a selection mask: all bits in the mask that are set to1
will be modified in the element at*self
.
Effects
All bits in *self
that are selected (set to 1
in the mask
) will be
cleared. All bits in *self
that are not selected (cleared to 0
in
the mask
) are unchanged.
fn invert_bits(&self, mask: BitMask<Self::Item>)
fn invert_bits(&self, mask: BitMask<Self::Item>)
Inverts any number of bits in a memory register.
The mask provided to this method must be constructed from indices that are valid in the caller’s context. As the mask is already computed by the caller, this does not take an ordering type parameter.
Parameters
&self
mask
: A mask of any number of bits. This is a selection mask: all bits in the mask that are set to1
will be modified in the element at*self
.
Effects
All bits in *self
that are selected (set to 1
in the mask
) will be
inverted. All bits in *self
that are not selected (cleared to 0
in
the mask
) are unchanged.
Writes a value to one bit in a memory register.
Type Parameters
O
: A bit ordering.
Parameters
&self
index
: The semantic index of the bit in*self
to write.value
: The bit value to write into*self
atindex
.
Effects
The memory register at address self
has the bit corresponding to the
index
cursor under the O
order written with the new value
, and all
other bits are unchanged.
Gets the function that writes value
into all bits under a mask.
Parameters
value
: The bit that will be directly written by the returned function.
Returns
A function which, when applied to a reference and a mask, will write
value
into memory. If value
is false
, then this produces
clear_bits
; if it is true
, then this produces set_bits
.