[−][src]Trait bitvec::store::BitStore
Common interface for memory regions.
This trait is implemented on the fundamental integers, their Cell
wrappers,
and (if present) their Atomic
variants. Users provide this type as a parameter
to their data structures in order to inform the structure of how it may access
the memory it describes.
Specifically, this has the davantage that a BitSlice<_, Cell<_>>
knows that it
has a view of memory that will not undergo concurrent modification. As such, it
can forego atomic accesses, and just use ordinary load/store instructions
without fear of causing observable race conditions.
The associated types Mem
and Alias
allow implementors to know the register
width of the memory they describe (Mem
) and to know the aliasing status of the
region.
Generic Programming
Generic programming with associated types is hard, especially when using them, as in this trait, to implement a closed graph of relationships between types.
For example, this trait is implemented such that for any given type T
,
T::Alias::Mem
== T::Mem
== T::NoAlias::Mem
, T::Alias::Alias == T::Alias
,
and T::NoAlias::NoAlias == T::NoAlias
. Unfortunately, the Rust type system
does not allow these relationships to be described, so generic programming that
performs type transitions will rapidly become uncomfortable to use.
Internally, bitvec
makes use of type-manipulation functions that are known to
be correct with respect to the implementations of BitStore
in order to ease
implementation of library methods.
You are not expected to do significant programming that is generic over the
BitStore
memory parameter. When using a concrete type, the compiler will
gladly reduce the abstract type associations into their instantiated selections,
allowing monomorphized code to be much more convenient than generic.
If you have a use case that involves generic programming over this trait, and you are encountering difficulties dealing with the type associations, please file an issue asking for support in this area.
Supertraits
This trait has trait requirements that better express its behavior:
Sealed
prevents it from being implemented by downstream libraries (Sealed
is a public trait in a private module, that only this crate can name).Sized
instructs the compiler that values of this type can be used as immediates.Debug
informs the compiler that other structures using this trait bound can correctly deriveDebug
.
Associated Types
type Mem: BitMemory + Into<Self> + BitStore
The register type that the implementor describes.
type Access: BitAccess<Self::Mem>
The modifier type over Self::Mem
used to perform memory access.
type Alias: BitStore + Radium<Self::Mem> + Radium<<Self::Alias as BitStore>::Mem>
A sibling BitStore
implementor that performs alias-aware memory
access.
While the associated type always has the same Mem
concrete type as
Self
, attempting to encode this requirement as `<Mem = Self::Mem>
causes Rust to enter an infinite recursion in the trait solver.
Instead, the two Radium
bounds inform the compiler that the Alias
is
irradiant over both the current memory and the destination memory types,
allowing generic type algebra to resolve correctly even though the fact
that Radium
is only implemented once is not guaranteed.
Implementations on Foreign Types
impl BitStore for u8
[src]
type Access = Cell<Self>
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = AtomicU8
In atomic builds, use atomic types for aliased access.
type Mem = Self
impl BitStore for AtomicU8
[src]
impl BitStore for u16
[src]
type Access = Cell<Self>
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = AtomicU16
In atomic builds, use atomic types for aliased access.
type Mem = Self
impl BitStore for AtomicU16
[src]
impl BitStore for u32
[src]
type Access = Cell<Self>
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = AtomicU32
In atomic builds, use atomic types for aliased access.
type Mem = Self
impl BitStore for AtomicU32
[src]
impl BitStore for usize
[src]
type Access = Cell<Self>
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = AtomicUsize
In atomic builds, use atomic types for aliased access.
type Mem = Self
impl BitStore for AtomicUsize
[src]
impl BitStore for u64
[src]
type Access = Cell<Self>
The unsigned integers will only be BitStore
type parameters
for handles to unaliased memory, following the normal Rust
reference rules.
type Alias = AtomicU64
In atomic builds, use atomic types for aliased access.
type Mem = Self
impl BitStore for AtomicU64
[src]
impl<M> BitStore for Cell<M> where
Self: Radium<M>,
M: BitMemory + BitStore,
[src]
Loading content...
Self: Radium<M>,
M: BitMemory + BitStore,