Module bitvec::field [−][src]
Expand description
Parallel bitfield access.
This module provides parallel, multiple-bit, access to a BitSlice
. This
functionality permits the use of BitSlice
as a library-level implementation of
the bitfield language feature found in C and C++.
The BitField
trait is not sealed against client implementation, as there is no
useful way to automatically use a BitOrder
implementation to provide a
universal behavior. As such, the trait has some requirements that the compiler
cannot enforce for client implementations.
Batch Behavior
The purpose of this trait is to provide access to arbitrary bit regions as if they were an ordinary memory location. As such, it is important for implementations of this trait to provide shift/mask register transfer behavior where possible, for as wide a span as possible in each action. Implementations of this trait should not use bit-by-bit iteration.
Register Bit Order Preservation
As a default assumption – user orderings may violate this, but should not – each element of slice memory used to store part of a value should not reorder the value bits. Transfer between slice memory and a CPU register should solely be an ordinary value load or store between memory and the register, and a shift/mask operation to select the part of the value that is live.
Endianness
The _le
and _be
methods of BitField
refer to the order in which
T: BitStore
elements of the slice are assigned significance when containing
fragments of a stored data value. Within any T
element, the order of its
constituent bytes is not governed by the BitField
trait method.
The provided BitOrder
implementors Lsb0
and Msb0
use the local machine’s
byte ordering. Other cursors may implement ordering of bytes within T
elements differently, for instance by calling .to_be_bytes
before store and
from_be_bytes
after load.
!
Traits
Performs C-style bitfield access through a BitSlice
.