Skip to main content

DBuff

Struct DBuff 

Source
pub struct DBuff { /* private fields */ }

Methods from Deref<Target = DArray<u8>>§

Source

pub fn dma_addr(&self) -> DmaAddr

获取 DMA 地址。

返回设备用于访问此 DMA 缓冲区的物理/DMA 地址。 将此地址传递给硬件设备以配置 DMA 操作。

§返回

DMA 地址

Source

pub fn len(&self) -> usize

获取数组长度(元素个数)。

§返回

数组中的元素个数

Source

pub fn is_empty(&self) -> bool

检查数组是否为空。

§返回

如果数组长度为 0 返回 true,否则返回 false

Source

pub fn bytes_len(&self) -> usize

获取数组的字节长度。

§返回

数组占用的总字节数

Source

pub fn read(&self, index: usize) -> Option<T>

读取指定索引的元素。

根据 DMA 方向自动处理缓存同步:

  • FromDevice/Bidirectional: 读取前使 CPU 缓存失效
  • ToDevice: 无缓存操作
§参数
  • index: 元素索引
§返回

如果索引有效返回 Some(T),否则返回 None

Source

pub fn set(&mut self, index: usize, value: T)

设置指定索引的元素值。

根据 DMA 方向自动处理缓存同步:

  • ToDevice/Bidirectional: 写入后刷新 CPU 缓存
  • FromDevice: 无缓存操作
§参数
  • index: 元素索引,必须在范围内
  • value: 要写入的值
§Panics

如果 index >= self.len() 则 panic

Source

pub fn iter(&self) -> DArrayIter<'_, T>

创建迭代器。

返回一个迭代器,按顺序读取数组元素。 每次读取都会自动处理缓存同步。

§返回

DArrayIter 迭代器

Source

pub fn copy_from_slice(&mut self, src: &[T])

从 slice 复制数据到数组。

复制完成后刷新整个数组的 CPU 缓存(ToDevice/Bidirectional)。

§参数
  • src: 源 slice,长度必须 <= self.len()
§Panics

如果 src.len() > self.len() 则 panic

Source

pub unsafe fn as_mut_slice(&mut self) -> &mut [T]

§Safety

slice will not auto do cache sync operations.

Source

pub fn as_ptr(&self) -> NonNull<T>

Trait Implementations§

Source§

impl Deref for DBuff

Source§

type Target = DArray<u8>

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl DerefMut for DBuff

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for DBuff

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for DBuff

Auto Trait Implementations§

§

impl Freeze for DBuff

§

impl !RefUnwindSafe for DBuff

§

impl !Sync for DBuff

§

impl Unpin for DBuff

§

impl UnsafeUnpin for DBuff

§

impl !UnwindSafe for DBuff

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

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