[−][src]Trait bitvec::prelude::BitAccess
Access interface for shared/mutable memory access.
&BitSlice
and &mut BitSlice
contexts must route through their Access
associated type, which implements this trait, in order to perform any access
to underlying memory. This trait extends the Radium
element-wise shared
mutable access with single-bit operations suited for use by BitSlice
.
Provided methods
fn clear_bit<C>(&self, place: BitIdx<T>) where
C: Cursor,
C: Cursor,
Set a single bit in an element low.
BitAccess::set
calls this when its value
is false
; it
unconditionally writes a 0
bit into the electrical position that
place
controls according to the Cursor
parameter C
.
Type Parameters
C
: ACursor
implementation which translatesplace
into a usable bit-mask.
Parameters
&self
: A shared reference to underlying memory.place
: A semantic bit index in theself
element.
fn clear_bits(&self, mask: T)
Writes the low bits of the mask into the underlying element.
Parameters
&self
mask
: Any value. The low bits of the mask will be written into*self
; the high bits will preserve their value in*self
.
fn set_bit<C>(&self, place: BitIdx<T>) where
C: Cursor,
C: Cursor,
Set a single bit in an element high.
BitAccess::set
calls this when its value
is true
; it
unconditionally writes a 1
bit into the electrical position that
place
controls according to the Cursor
parameter C
.
Type Parameters
C
: ACursor
implementation which translatesplace
into a usable bit-mask.
Parameters
&self
: A shared reference to underlying memory.place
: A semantic bit index in theself
element.
fn set_bits(&self, mask: T)
Writes the high bits of the mask into the underlying element.
Parameters
&self
mask
: Any value. The high bits of the mask will be written into*self
; the low bits will preserve their value in*self
.
fn invert_bit<C>(&self, place: BitIdx<T>) where
C: Cursor,
C: Cursor,
Invert a single bit in an element.
Type Parameters
C
: ACursor
implementation which translatesplace
into a usable bit-mask.
Parameters
&self
: A shared reference to underlying memory.place
: A semantic bit index in theself
element.
fn get<C>(&self, place: BitIdx<T>) -> bool where
C: Cursor,
C: Cursor,
Retrieve a single bit from an element.
Type Parameters
C
: ACursor
implementation which translatesplace
into a usable bit-mask.
Parameters
&self
: A shared reference to underlying memory.place
: A semantic bit index in theself
element.
fn set<C>(&self, place: BitIdx<T>, value: bool) where
C: Cursor,
C: Cursor,
Set a single bit in an element to some value.
Type Parameters
C
: ACursor
implementation which translatesplace
into a usable bit-mask.
Parameters
&self
: A shared reference to underlying memory.place
: A semantic bit index in theself
element.value
: The value to which the bit controlled byplace
shall be set.
fn load(&self) -> T
Read a value out of a contended memory element and into a local scope.
Parameters
&self
: A shared reference to underlying memory.
Returns
The value of *self
. This value is only useful when access is
uncontended by multiple BitSlice
regions.
fn store(&self, value: T)
Stores a value into a contended memory element.
Parameters
&self
: A shared reference to underlying memory.value
: The new value to write into*self
.
unsafe fn as_slice_mut(this: &[Self]) -> &mut [T]
Converts a slice of BitAccess
to a mutable slice of BitStore
.
Safety
This can only be called on wholly owned, uncontended, regions.