Skip to main content

OwningQueue

Struct OwningQueue 

Source
pub struct OwningQueue<H: Hal, const SIZE: usize, const BUFFER_SIZE: usize> { /* private fields */ }
Available on crate feature alloc only.
Expand description

A wrapper around VirtQueue that owns all the buffers that are passed to the queue.

Implementations§

Source§

impl<H: Hal, const SIZE: usize, const BUFFER_SIZE: usize> OwningQueue<H, SIZE, BUFFER_SIZE>

Source

pub fn new(queue: VirtQueue<H, SIZE>) -> Result<Self>

Constructs a new OwningQueue wrapping around the given VirtQueue.

This will allocate SIZE buffers of BUFFER_SIZE bytes each and add them to the queue.

The caller is responsible for notifying the device if should_notify returns true.

Source

pub fn should_notify(&self) -> bool

Returns whether the driver should notify the device after adding a new buffer to the virtqueue.

This will be false if the device has suppressed notifications.

Source

pub fn set_dev_notify(&mut self, enable: bool)

Tells the device whether to send used buffer notifications.

Source

pub fn poll<T>( &mut self, transport: &mut impl Transport, handler: impl FnOnce(&[u8]) -> Result<Option<T>>, ) -> Result<Option<T>>

Checks whether there are any buffers which the device has marked as used so the driver should now process. If so, passes the first one to the handle function and then adds it back to the queue.

Returns an error if there is an error accessing the queue or handler returns an error. Returns Ok(None) if there are no pending buffers to handle, or if handler returns Ok(None).

If handler panics then the buffer will not be added back to the queue, so this should be avoided.

Trait Implementations§

Source§

impl<H: Debug + Hal, const SIZE: usize, const BUFFER_SIZE: usize> Debug for OwningQueue<H, SIZE, BUFFER_SIZE>

Source§

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

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

impl<H: Hal, const SIZE: usize, const BUFFER_SIZE: usize> Drop for OwningQueue<H, SIZE, BUFFER_SIZE>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<H: Hal, const SIZE: usize, const BUFFER_SIZE: usize> Send for OwningQueue<H, SIZE, BUFFER_SIZE>
where VirtQueue<H, SIZE>: Send,

Source§

impl<H: Hal, const SIZE: usize, const BUFFER_SIZE: usize> Sync for OwningQueue<H, SIZE, BUFFER_SIZE>
where VirtQueue<H, SIZE>: Sync,

Auto Trait Implementations§

§

impl<H, const SIZE: usize, const BUFFER_SIZE: usize> Freeze for OwningQueue<H, SIZE, BUFFER_SIZE>

§

impl<H, const SIZE: usize, const BUFFER_SIZE: usize> RefUnwindSafe for OwningQueue<H, SIZE, BUFFER_SIZE>
where H: RefUnwindSafe,

§

impl<H, const SIZE: usize, const BUFFER_SIZE: usize> Unpin for OwningQueue<H, SIZE, BUFFER_SIZE>
where H: Unpin,

§

impl<H, const SIZE: usize, const BUFFER_SIZE: usize> UnsafeUnpin for OwningQueue<H, SIZE, BUFFER_SIZE>

§

impl<H, const SIZE: usize, const BUFFER_SIZE: usize> UnwindSafe for OwningQueue<H, SIZE, BUFFER_SIZE>
where H: 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.