Skip to main content

DmaAlignedRef

Struct DmaAlignedRef 

Source
pub struct DmaAlignedRef<'a, T>(/* private fields */)
where
    T: ?Sized;
Available on crate feature unstable only.
Expand description

A shared reference to an InternalMemory object.

Unlike DmaAlignedMut, a DmaAlignedRef only allows reading the value and invalidating its cache lines (discarding the CPU-cached copy so a subsequent read observes data written by DMA). It can neither mutate the value nor write it back, so it can be obtained from a shared borrow and used to poll DMA-written, interior-mutable state (e.g. a descriptor’s ownership bit) without exclusive access.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Implementations§

Source§

impl<'a, T: ?Sized> DmaAlignedRef<'a, T>

Source

pub fn new(ptr: &'a T) -> Result<Self, DmaBufError>

Creates a new DmaAlignedRef from a shared reference, if it’s provably compatible.

In internal memory, the address and size of the value must be at least 4 byte aligned.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub const unsafe fn new_unchecked(ptr: &'a T) -> Self

Creates a new DmaAlignedRef from any shared reference.

§Safety

The caller must ensure that the reference is properly aligned for the memory region it occupies and the cachelines occupied by the reference do not overlap with any other data that can be corrupted by a cacheline invalidation operation.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn into_inner(self) -> &'a T

Converts this object into a shared reference.

Trait Implementations§

Source§

impl<'a, T> Debug for DmaAlignedRef<'a, T>
where T: ?Sized + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, T: ?Sized> Deref for DmaAlignedRef<'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for DmaAlignedRef<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for DmaAlignedRef<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for DmaAlignedRef<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Sync for DmaAlignedRef<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for DmaAlignedRef<'a, T>
where T: ?Sized,

§

impl<'a, T> UnsafeUnpin for DmaAlignedRef<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for DmaAlignedRef<'a, T>
where T: RefUnwindSafe + ?Sized,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.