DmaSliceMutImmut

Enum DmaSliceMutImmut 

Source
pub enum DmaSliceMutImmut<'a, T: ImmutableFromIntoBytes> {
    Immutable(DmaSlice<'a, T>),
    Mutable(DmaSliceMut<'a, T>),
}
Expand description

A buffer that can be safely used for read-only DMA operations, backed by either a shared (immutable) or unique (mutable) Rust slice.

Creating a DmaSliceMutImmut over a Rust slice ensures that all prior Rust writes to this slice are observable by any DMA operations initiated through an MMIO write operation, where that MMIO write is performed after constructing the DmaSliceMutImmut.

For this guarantee to hold, the DmaSliceMutImmut instance 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 DmaSliceMut, DmaSliceMutImmut 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 supplied buffer, use DmaSliceMut instead.

Variants§

§

Immutable(DmaSlice<'a, T>)

§

Mutable(DmaSliceMut<'a, T>)

Implementations§

Source§

impl<'a, T: ImmutableFromIntoBytes> DmaSliceMutImmut<'a, T>

Source

pub fn new(slice: &[T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>

Create a DmaSliceMutImmut from a shared, immutable Rust slice.

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 DmaSliceMutImmut is dropped.

Source

pub fn new_mut(slice: &mut [T], fence: impl DmaFence) -> DmaSliceMutImmut<'_, T>

Create a DmaSliceMutImmut from a unique, mutable Rust slice.

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 DmaSliceMutImmut is dropped.

Even though this method takes a unique, mutable Rust slice, DMA operations must not modify the buffers contents.

Source

pub fn as_ptr(&self) -> *const T

Returns the pointer to the first element of the wrapped slice reference.

Source

pub fn len(&self) -> usize

Returns the length of the wrapped slice reference.

Source

pub fn get(&self) -> &'a [T]

Retrieve the inner slice reference.

This is safe, as DmaSliceMutImmut can only be used for read-only DMA operations. The DMA hardware and software may read the underlying slice concurrently.

Trait Implementations§

Source§

impl<'a, T: Debug + ImmutableFromIntoBytes> Debug for DmaSliceMutImmut<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for DmaSliceMutImmut<'a, T>

§

impl<'a, T> RefUnwindSafe for DmaSliceMutImmut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for DmaSliceMutImmut<'a, T>

§

impl<'a, T> !Sync for DmaSliceMutImmut<'a, T>

§

impl<'a, T> Unpin for DmaSliceMutImmut<'a, T>

§

impl<'a, T> !UnwindSafe for DmaSliceMutImmut<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.