Trait bitvec::store::BitStore

source ·
pub trait BitStore: 'static + 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>;

    const ZERO: Self;
    const ALIGNED_TO_SIZE: [(); 1];
    const ALIAS_WIDTH: [(); 1];

    // Required methods
    fn new(value: Self::Mem) -> Self;
    fn load_value(&self) -> Self::Mem;
    fn store_value(&mut self, value: Self::Mem);

    // Provided method
    fn get_bit<O>(&self, index: BitIdx<Self::Mem>) -> bool
       where O: BitOrder { ... }
}
Expand description

§Bit Storage

This trait drives bitvec’s ability to view memory as a collection of discrete bits. It combines awareness of storage element width, memory-bus access requirements, element contention, and buffer management, into a type-system graph that the rest of the crate can use to abstract away concerns about memory representation or access rules.

It is responsible for extending the standard Rust &/&mut shared/exclusion rules to apply to individual bits while avoiding violating those rules when operating on real memory so that Rust and LLVM cannot find fault with the object code it produces.

§Implementors

This is implemented on three type families:

The BitSlice region, and all structures composed atop it, can be built out of regions of memory that have this trait implementation.

§Associated Types

The associated types attached to each implementation create a closed graph of type transitions used to manage alias conditions. When a bit-slice region determines that an aliasing or unaliasing event has occurred, it transitions along the type graph in order to maintain correct operations in memory. The methods that cause type transitions can be found in BitSlice and domain.

Required Associated Constants§

source

const ZERO: Self

The zero constant.

source

const ALIGNED_TO_SIZE: [(); 1]

All implementors are required to have their alignment match their size.

Use mem::aligned_to_size::<Self>() to prove this.

source

const ALIAS_WIDTH: [(); 1]

All implementors are required to have Self and Self::Alias be equal in representation. This is true by fiat for all types except the unsigned integers.

Use mem::layout_eq::<Self, Self::Alias>() to prove this.

Required Associated Types§

source

type Mem: BitRegister + BitStore<Mem = Self::Mem>

The element type used in the memory region underlying a BitSlice. It is always one of the unsigned integer fundamentals.

source

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

A type that selects the appropriate load/store instructions when accessing the memory bus. It determines what instructions are used when moving a Self::Mem value between the processor and the memory system.

This must be at least able to manage aliasing.

source

type Alias: BitStore<Mem = Self::Mem>

A sibling BitStore implementor that is known to be alias-safe. It is used when a BitSlice introduces multiple handles that view the same memory location, and at least one of them has write capabilities to it. It must have the same underlying memory type, and can only change access patterns or public-facing usage.

source

type Unalias: BitStore<Mem = Self::Mem>

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

Required Methods§

source

fn new(value: Self::Mem) -> Self

Wraps a raw memory value as a BitStore type.

source

fn load_value(&self) -> Self::Mem

Loads a value out of the memory system according to the ::Access rules. This may be called when the value is aliased by a write-capable reference.

source

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

Stores a value into the memory system. This is only called when there are no other handles to the value, and it may bypass ::Access constraints.

Provided Methods§

source

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

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 governing the lookup.
§Parameters
  • index: The semantic index of a bit in *self.
§Returns

The value of the bit in *self at BitOrder::at(index).

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BitStore for u8

source§

type Access = Cell<u8>

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

source§

const ZERO: Self = 0u8

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u8

source§

type Alias = BitSafeU8

source§

type Unalias = u8

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for u16

source§

type Access = Cell<u16>

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

source§

const ZERO: Self = 0u16

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u16

source§

type Alias = BitSafeU16

source§

type Unalias = u16

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for u32

source§

type Access = Cell<u32>

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

source§

const ZERO: Self = 0u32

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u32

source§

type Alias = BitSafeU32

source§

type Unalias = u32

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for u64

source§

type Access = Cell<u64>

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

source§

const ZERO: Self = 0u64

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u64

source§

type Alias = BitSafeU64

source§

type Unalias = u64

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for usize

source§

type Access = Cell<usize>

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

source§

const ZERO: Self = 0usize

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = usize

source§

type Alias = BitSafeUsize

source§

type Unalias = usize

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for Cell<u8>

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u8

source§

type Access = Cell<u8>

source§

type Alias = Cell<u8>

source§

type Unalias = Cell<u8>

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for Cell<u16>

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u16

source§

type Access = Cell<u16>

source§

type Alias = Cell<u16>

source§

type Unalias = Cell<u16>

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for Cell<u32>

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u32

source§

type Access = Cell<u32>

source§

type Alias = Cell<u32>

source§

type Unalias = Cell<u32>

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for Cell<u64>

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u64

source§

type Access = Cell<u64>

source§

type Alias = Cell<u64>

source§

type Unalias = Cell<u64>

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for Cell<usize>

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = usize

source§

type Access = Cell<usize>

source§

type Alias = Cell<usize>

source§

type Unalias = Cell<usize>

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for AtomicU8

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u8

source§

type Access = AtomicU8

source§

type Alias = AtomicU8

source§

type Unalias = AtomicU8

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for AtomicU16

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u16

source§

type Access = AtomicU16

source§

type Alias = AtomicU16

source§

type Unalias = AtomicU16

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for AtomicU32

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u32

source§

type Access = AtomicU32

source§

type Alias = AtomicU32

source§

type Unalias = AtomicU32

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for AtomicU64

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u64

source§

type Access = AtomicU64

source§

type Alias = AtomicU64

source§

type Unalias = AtomicU64

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

source§

impl BitStore for AtomicUsize

source§

const ZERO: Self = _

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = usize

source§

type Access = AtomicUsize

source§

type Alias = AtomicUsize

source§

type Unalias = AtomicUsize

source§

fn new(value: Self::Mem) -> Self

source§

fn load_value(&self) -> Self::Mem

source§

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

Implementors§

source§

impl BitStore for BitSafeU8

source§

const ZERO: Self = <Self as BitSafe>::ZERO

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u8

source§

type Access = <BitSafeU8 as BitSafe>::Rad

source§

type Alias = BitSafeU8

source§

type Unalias = u8

source§

impl BitStore for BitSafeU16

source§

const ZERO: Self = <Self as BitSafe>::ZERO

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u16

source§

type Access = <BitSafeU16 as BitSafe>::Rad

source§

type Alias = BitSafeU16

source§

type Unalias = u16

source§

impl BitStore for BitSafeU32

source§

const ZERO: Self = <Self as BitSafe>::ZERO

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u32

source§

type Access = <BitSafeU32 as BitSafe>::Rad

source§

type Alias = BitSafeU32

source§

type Unalias = u32

source§

impl BitStore for BitSafeU64

source§

const ZERO: Self = <Self as BitSafe>::ZERO

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = u64

source§

type Access = <BitSafeU64 as BitSafe>::Rad

source§

type Alias = BitSafeU64

source§

type Unalias = u64

source§

impl BitStore for BitSafeUsize

source§

const ZERO: Self = <Self as BitSafe>::ZERO

source§

const ALIGNED_TO_SIZE: [(); 1] = _

source§

const ALIAS_WIDTH: [(); 1] = _

source§

type Mem = usize

source§

type Access = <BitSafeUsize as BitSafe>::Rad

source§

type Alias = BitSafeUsize

source§

type Unalias = usize