Trait bitvec::store::BitStore[][src]

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
, { ... } }

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>[src]

The register type used in the slice region underlying a BitSlice handle. It is always an unsigned integer.

type Access: BitAccess<Item = Self::Mem> + BitStore<Mem = Self::Mem>[src]

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.

type Alias: BitStore<Mem = Self::Mem>[src]

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.

type Unalias: BitStore<Mem = Self::Mem>[src]

The inverse of Alias. It is used when a BitSlice removes the conditions that required a T -> T::Alias transition.

Loading content...

Required methods

fn load_value(&self) -> Self::Mem[src]

Loads a value out of the memory system according to the ::Access rules.

fn store_value(&mut self, value: Self::Mem)[src]

Stores a value into the memory system according to the ::Access rules.

Loading content...

Provided methods

fn get_bit<O>(&self, index: BitIdx<Self::Mem>) -> bool where
    O: BitOrder
[src]

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 within Self::Mem to use for looking up the bit at index.

Parameters

  • &self
  • index: The semantic index of the bit in *self to read.

Returns

The value of the bit in *self at index.

Loading content...

Implementations on Foreign Types

impl BitStore for u8[src]

type Mem = Self

type Access = Cell<u8>

The unsigned integers will only be BitStore type parameters for handles to unaliased memory, following the normal Rust reference rules.

type Alias = BitSafeU8

type Unalias = Self

impl BitStore for Cell<u8>[src]

type Mem = u8

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for u16[src]

type Mem = Self

type Access = Cell<u16>

The unsigned integers will only be BitStore type parameters for handles to unaliased memory, following the normal Rust reference rules.

type Alias = BitSafeU16

type Unalias = Self

impl BitStore for Cell<u16>[src]

type Mem = u16

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for u32[src]

type Mem = Self

type Access = Cell<u32>

The unsigned integers will only be BitStore type parameters for handles to unaliased memory, following the normal Rust reference rules.

type Alias = BitSafeU32

type Unalias = Self

impl BitStore for Cell<u32>[src]

type Mem = u32

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for u64[src]

type Mem = Self

type Access = Cell<u64>

The unsigned integers will only be BitStore type parameters for handles to unaliased memory, following the normal Rust reference rules.

type Alias = BitSafeU64

type Unalias = Self

impl BitStore for Cell<u64>[src]

type Mem = u64

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for usize[src]

type Mem = Self

type Access = Cell<usize>

The unsigned integers will only be BitStore type parameters for handles to unaliased memory, following the normal Rust reference rules.

type Alias = BitSafeUsize

type Unalias = Self

impl BitStore for Cell<usize>[src]

type Mem = usize

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for AtomicU8[src]

type Mem = u8

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for AtomicU16[src]

type Mem = u16

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for AtomicU32[src]

type Mem = u32

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for AtomicU64[src]

type Mem = u64

type Access = Self

type Alias = Self

type Unalias = Self

impl BitStore for AtomicUsize[src]

type Mem = usize

type Access = Self

type Alias = Self

type Unalias = Self

Loading content...

Implementors

impl BitStore for BitSafeU8[src]

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 Mem = u8

type Access = Self::Rad

type Alias = Self

type Unalias = u8

impl BitStore for BitSafeU16[src]

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 Mem = u16

type Access = Self::Rad

type Alias = Self

type Unalias = u16

impl BitStore for BitSafeU32[src]

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 Mem = u32

type Access = Self::Rad

type Alias = Self

type Unalias = u32

impl BitStore for BitSafeU64[src]

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 Mem = u64

type Access = Self::Rad

type Alias = Self

type Unalias = u64

impl BitStore for BitSafeUsize[src]

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 Mem = usize

type Access = Self::Rad

type Alias = Self

type Unalias = usize

Loading content...