Struct dma_buf::MappedDmaBuf

source ·
pub struct MappedDmaBuf { /* private fields */ }
Expand description

A DmaBuf mapped in memory

Implementations§

source§

impl MappedDmaBuf

source

pub fn read<A, F, R>(&self, f: F, arg: Option<A>) -> Result<R, BufferError>
where F: Fn(&[u8], Option<A>) -> Result<R, Box<dyn Error>>,

Calls a closure to read the buffer content

DMA-Buf requires the user-space to call the DMA_BUF_IOCTL_SYNC ioctl before and after any CPU access to a buffer in order to maintain the cache coherency. The closure will be run with those primitives called for a read access from the CPU.

The result of the closure will be returned.

§Errors

Will return [Error] if the underlying ioctl or the closure fails

source

pub fn readwrite<A, F, R>( &mut self, f: F, arg: Option<A> ) -> Result<R, BufferError>
where F: Fn(&mut [u8], Option<A>) -> Result<R, Box<dyn Error>>,

Calls a closure to read from and write to the buffer content

DMA-Buf requires the user-space to call the DMA_BUF_IOCTL_SYNC ioctl before and after any CPU access to a buffer in order to maintain the cache coherency. The closure will be run with those primitives called for a read and write access from the CPU.

The result of the closure will be returned on success. On failure, the closure must return Error::Closure

§Errors

Will return [Error] if the underlying ioctl or the closure fails

source

pub fn write<A, F>(&mut self, f: F, arg: Option<A>) -> Result<(), BufferError>
where F: Fn(&mut [u8], Option<A>) -> Result<(), Box<dyn Error>>,

Calls a closure to read from and write to the buffer content

DMA-Buf requires the user-space to call the DMA_BUF_IOCTL_SYNC ioctl before and after any CPU access to a buffer in order to maintain the cache coherency. The closure will be run with those primitives called for a read and write access from the CPU.

The closure must return () on success. On failure, the closure must return Error::Closure.

§Errors

Will return [Error] if the underlying ioctl or the closure fails

Trait Implementations§

source§

impl AsFd for MappedDmaBuf

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl AsRawFd for MappedDmaBuf

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for MappedDmaBuf

source§

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

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

impl Drop for MappedDmaBuf

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.