Trait rfw_backend::BitStore [−][src]
pub trait BitStore: 'static + Sealed + Debug { type Mem: BitRegister + BitStore; type Access: BitAccess + BitStore; type Alias: BitStore; type Unalias: BitStore; 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
type Mem: BitRegister + BitStoreThe 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::MemLoads 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::Memto use for looking up the bit atindex.
Parameters
&selfindex: The semantic index of the bit in*selfto read.
Returns
The value of the bit in *self at index.
Implementations on Foreign Types
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.
type Access = <BitSafeU32 as BitSafe>::Radtype Alias = BitSafeU32This 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.
The unsigned integers will only be BitStore type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = BitSafeU16The unsigned integers will only be BitStore type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = BitSafeU32This 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.
type Access = <BitSafeU64 as BitSafe>::Radtype Alias = BitSafeU64The unsigned integers will only be BitStore type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = BitSafeU64This 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.
type Access = <BitSafeU16 as BitSafe>::Radtype Alias = BitSafeU16This 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.
type Access = <BitSafeUsize as BitSafe>::Radtype Alias = BitSafeUsizeThe unsigned integers will only be BitStore type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = BitSafeUsizeThe unsigned integers will only be BitStore type parameters
for handles to unaliased memory, following the normal Rust
reference rules.