pub trait BitStore: 'static + Sealed + Debug {
type Mem: BitRegister + BitStore<Mem = Self::Mem>;
type Access: BitAccess<Item = Self::Mem> + BitStore<Mem = Self::Mem>;
type Alias: BitStore<Mem = Self::Mem>;
type Unalias: BitStore<Mem = Self::Mem>;
fn load_value(&self) -> Self::Mem;
fn store_value(&mut self, value: Self::Mem);
fn get_bit<O>(&self, index: BitIdx<Self::Mem>) -> bool
where
O: BitOrder,
{ ... }
}
Expand description
Common interface for memory regions.
This trait is used to describe how BitSlice
regions interact with the memory
bus when reading to or writing from locations. It manages the behavior required
when locations are contended for write permissions by multiple handles, and
ensures that Rust’s &
/&mut
shared/exclusion system, as well as its
UnsafeCell
shared-mutation system, are upheld for individual bits as well as
for the memory operations that power the slice.
This trait is publicly implemented on the unsigned integers that implement
BitRegister
, their Cell
wrappers, and (if present) their atomic
variants. You may freely construct BitSlice
regions over elements or slices
of any of these types.
Shared BitSlice
references (&BitSlice<_, T: BitStore>
) permit multiple
handles to view the bits they describe. When T
is a Cell
or atom, these
handles may use the methods .set_aliased()
and .set_aliased_unchecked()
to modify memory; when T
is an ordinary integer, they may not.
Exclusive BitSlice
references (&mut BitSlice<_, T: BitStore>
) do not allow
any other handle to view the bits they describe. However, other handles may view
the memory locations containing their bits! When T
is a Cell
or
atom, no special behavior occurs. When T
is an ordinary integer, bitvec
detects the creation of multiple &mut BitSlice<_, T>
handles that do not alias
bits but do alias memory, and enforces that these handles use Cell
or atomic
behavior to access the underlying memory, even though individual bits in the
slices are not contended.
Integer Width Restricitons
Currently, bitvec
is only tested on 32- and 64- bit architectures. This
means that u8
, u16
, u32
, and usize
unconditionally implement BitStore
,
but u64
will only do so on 64-bit targets. This is a necessary restriction of
bitvec
internals. Please comment on Issue #76 if this affects you.
Associated Types
type Mem: BitRegister + BitStore<Mem = Self::Mem>
type Mem: BitRegister + BitStore<Mem = Self::Mem>
The register type used in the slice region underlying a BitSlice
handle. It is always an unsigned integer.
A type that selects appropriate load/store instructions used for
accessing the memory bus. It determines what instructions are used when
moving a Self::Mem
value between the processor and the memory system.
A sibling BitStore
implementor. It is used when a BitSlice
introduces multiple handles that view the same memory location, and at
least one of them has write permission to it.
Required methods
fn load_value(&self) -> Self::Mem
fn load_value(&self) -> Self::Mem
Loads a value out of the memory system according to the ::Access
rules.
fn store_value(&mut self, value: Self::Mem)
fn store_value(&mut self, value: Self::Mem)
Stores a value into the memory system according to the ::Access
rules.
Provided methods
Reads a single bit out of the memory system according to the ::Access
rules. This is lifted from BitAccess
so that it can be used
elsewhere without additional casts.
Type Parameters
O
: The ordering of bits withinSelf::Mem
to use for looking up the bit atindex
.
Parameters
&self
index
: The semantic index of the bit in*self
to read.
Returns
The value of the bit in *self
at index
.
Implementations on Foreign Types
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Mem = Self
type Alias = BitSafeU16
type Unalias = Self
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Mem = Self
type Alias = BitSafeU32
type Unalias = Self
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Mem = Self
type Alias = BitSafeU64
type Unalias = Self
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Mem = Self
type Alias = BitSafeUsize
type Unalias = Self
Implementors
This type is only ever produced by calling .split_at_mut()
on
BitSlice<_, T>
where T
is an unsigned integer. It cannot be
constructed as a base data source.
This type is only ever produced by calling .split_at_mut()
on
BitSlice<_, T>
where T
is an unsigned integer. It cannot be
constructed as a base data source.
This type is only ever produced by calling .split_at_mut()
on
BitSlice<_, T>
where T
is an unsigned integer. It cannot be
constructed as a base data source.
This type is only ever produced by calling .split_at_mut()
on
BitSlice<_, T>
where T
is an unsigned integer. It cannot be
constructed as a base data source.
This type is only ever produced by calling .split_at_mut()
on
BitSlice<_, T>
where T
is an unsigned integer. It cannot be
constructed as a base data source.