Skip to main content

DescriptorRing

Struct DescriptorRing 

Source
pub struct DescriptorRing<D, const N: usize> { /* private fields */ }
Expand description

Circular descriptor ring with wraparound index.

Implementations§

Source§

impl<D, const N: usize> DescriptorRing<D, N>

Source

pub const fn new(descriptors: [D; N]) -> Self

Create a new descriptor ring from an existing array.

Source

pub const fn len(&self) -> usize

Number of descriptors in the ring.

Source

pub const fn is_empty(&self) -> bool

Check if the ring is empty (always false for non-zero N).

Source

pub const fn current_index(&self) -> usize

Current index.

Source

pub fn advance(&mut self)

Advance the current index by one, wrapping around.

Source

pub fn advance_by(&mut self, count: usize)

Advance the current index by count, wrapping around.

Source

pub fn reset(&mut self)

Reset the current index to 0.

Source

pub fn current(&self) -> &D

Reference to the current descriptor.

Source

pub fn current_mut(&mut self) -> &mut D

Mutable reference to the current descriptor.

Source

pub fn get(&self, index: usize) -> &D

Reference to the descriptor at index (wraps around).

Source

pub fn get_mut(&mut self, index: usize) -> &mut D

Mutable reference to the descriptor at index (wraps around).

Source

pub fn base_addr(&self) -> *const D

Pointer to the first descriptor (for programming DMA base-address registers).

Source

pub fn iter(&self) -> impl Iterator<Item = &D>

Iterate over all descriptors.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut D>

Iterate mutably over all descriptors.

Auto Trait Implementations§

§

impl<D, const N: usize> Freeze for DescriptorRing<D, N>
where D: Freeze,

§

impl<D, const N: usize> RefUnwindSafe for DescriptorRing<D, N>
where D: RefUnwindSafe,

§

impl<D, const N: usize> Send for DescriptorRing<D, N>
where D: Send,

§

impl<D, const N: usize> Sync for DescriptorRing<D, N>
where D: Sync,

§

impl<D, const N: usize> Unpin for DescriptorRing<D, N>
where D: Unpin,

§

impl<D, const N: usize> UnsafeUnpin for DescriptorRing<D, N>
where D: UnsafeUnpin,

§

impl<D, const N: usize> UnwindSafe for DescriptorRing<D, N>
where D: UnwindSafe,

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.