pub enum DmaSubSliceMutImmut<'a, T: ImmutableFromIntoBytes> {
Immutable(DmaSubSlice<'a, T>),
Mutable(DmaSubSliceMut<'a, T>),
}Expand description
A buffer that can be safely used for read-only DMA operations, backed by
either a SubSliceMutImmut.
Creating a DmaSubSliceMutImmut over a SubSliceMutImmut ensures that
all prior Rust writes to the active region of this slice are observable by
any DMA operations initiated through an MMIO write operation, where that
MMIO write is performed after constructing the DmaSubSliceMutImmut.
For this guarantee to hold, the DmaSubSliceMutImmut struct must exist for
the duration of the entire DMA operation, until the Rust program has
observed that the operation is complete (such as by reading a status bit in
memory or an MMIO register).
DmaSliceMutImmut may wrap an immutable, shared Rust slice
reference. Furthermore, in contrast to DmaSubSliceMut,
DmaSubSliceMutImmut may not expose writes performed by a DMA operation
back to Rust. As such, its contents must not be modified by the DMA
operation. For a DMA operation that may write to the active range of the
supplied sub slice, use DmaSubSliceMut instead.
Variants§
Immutable(DmaSubSlice<'a, T>)
Mutable(DmaSubSliceMut<'a, T>)
Implementations§
Source§impl<'a, T: ImmutableFromIntoBytes> DmaSubSliceMutImmut<'a, T>
impl<'a, T: ImmutableFromIntoBytes> DmaSubSliceMutImmut<'a, T>
Sourcepub fn new(
sub_slice: SubSliceMutImmut<'_, T>,
fence: impl DmaFence,
) -> DmaSubSliceMutImmut<'_, T>
pub fn new( sub_slice: SubSliceMutImmut<'_, T>, fence: impl DmaFence, ) -> DmaSubSliceMutImmut<'_, T>
Create a DmaSubSliceMutImmut from a SubSliceMutImmut.
This function uses the supplied fence object to ensure that all prior
writes to slice are exposed to any DMA operations initiated by an MMIO
read or write operation after this function returns, and which finish
before the resulting DmaSubSlice is dropped.
Sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Returns the pointer to the first element of the currently accessible
portion of the wrapped SubSlice.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the currently accessible range of the wrapped
SubSlice.
Sourcepub fn take(self) -> SubSliceMutImmut<'a, T>
pub fn take(self) -> SubSliceMutImmut<'a, T>
Reconstruct the original SubSliceMutImmut.
This function must be called only when the Rust program has observed that the DMA operation over the buffer is complete (such as by reading a status bit in memory or an MMIO register). Otherwise, any future reads by the DMA peripheral may not be consistent with the buffer contents.