| 1 |
# Bit Indices |
| 2 |
|
| 3 |
This module provides well-typed counters for working with bit-storage registers. |
| 4 |
The session types encode a strict chain of custody for translating semantic |
| 5 |
indices within [`BitSlice`] regions into real effects in memory. |
| 6 |
|
| 7 |
The main advantage of types within this module is that they provide |
| 8 |
register-dependent range requirements for counter values, making it impossible |
| 9 |
to have an index out of bounds for a register. They also create a sequence of |
| 10 |
type transformations that assure the library about the continued validity of |
| 11 |
each value in its surrounding context. |
| 12 |
|
| 13 |
By eliminating public constructors from arbitrary integers, `bitvec` can |
| 14 |
guarantee that only it can produce initial values, and only trusted functions |
| 15 |
can transform their numeric values or types, until the program reaches the |
| 16 |
property that it requires. This chain of assurance means that memory operations |
| 17 |
can be confident in the correctness of their actions and effects. |
| 18 |
|
| 19 |
## Type Sequence |
| 20 |
|
| 21 |
The library produces [`BitIdx`] values from region computation. These types |
| 22 |
cannot be publicly constructed, and are only ever the result of pointer |
| 23 |
analysis. As such, they rely on the correctness of the memory regions provided |
| 24 |
to library entry points, and those entry points can leverage the Rust type |
| 25 |
system to ensure safety there. |
| 26 |
|
| 27 |
`BitIdx` is transformed to [`BitPos`] through the [`BitOrder`] trait. The |
| 28 |
[`order`] module provides verification functions that implementors can use to |
| 29 |
demonstrate correctness. `BitPos` is the basis type that describes memory |
| 30 |
operations, and is used to create the selection masks [`BitSel`] and |
| 31 |
[`BitMask`]. |
| 32 |
|
| 33 |
## Usage |
| 34 |
|
| 35 |
The types in this module should only be used by client crates in their test |
| 36 |
suites. They have no other purpose, and conjuring values for them is potentially |
| 37 |
memory-unsafe. |
| 38 |
|
| 39 |
[`BitIdx`]: self::BitIdx |
| 40 |
[`BitMask`]: self::BitMask |
| 41 |
[`BitOrder`]: crate::order::BitOrder |
| 42 |
[`BitPos`]: self::BitPos |
| 43 |
[`BitSel`]: self::BitSel |
| 44 |
[`BitSlice`]: crate::slice::BitSlice |
| 45 |
[`order`]: crate::order |