pub trait AsMutBits<T> where
T: BitStore, {
fn as_mut_bits<O>(&mut self) -> &mut BitSlice<T, O>ⓘNotable traits for &BitSlice<T, O>impl<T, O> Read for &BitSlice<T, O> where
T: BitStore,
O: BitOrder,
BitSlice<T, O>: BitField, impl<T, O> Write for &mut BitSlice<T, O> where
T: BitStore,
O: BitOrder,
BitSlice<T, O>: BitField,
where
O: BitOrder;
fn try_as_mut_bits<O>(
&mut self
) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>
where
O: BitOrder;
}
Expand description
Mutable Bit View
This trait is an analogue to the AsMut
trait, in that it enables any type to
provide a view of a mutable bit-slice.
It does not require an AsMut<[T: BitStore]>
implementation, but a blanket
implementation for all AsMut<[T: BitStore]>
is provided. This allows you to
choose whether to implement only one of AsMutBits<T>
or AsMut<[T]>
, and gain
a bit-slice view through either choice.
Usage
The .as_mut_bits<_>()
method has the same usage patterns as
BitView::view_bits_mut
.
Notes
You are not forbidden from creating multiple views with different element types to the same region, but doing so is likely to cause inconsistent and surprising behavior.
Refrain from implementing this trait with more than one storage argument unless you are sure that you can uphold the memory region requirements of all of them, and are aware of the behavior conflicts that may arise.
Required Methods
Views self
as a mutable bit-slice region with the O
ordering.
fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
fn try_as_mut_bits<O>(&mut self) -> Result<&mut BitSlice<T, O>, BitSpanError<T>> where
O: BitOrder,
Attempts to view self
as a mutable bit-slice region with the O
ordering.
This may return an error if self
is too long to view as a bit-slice.