virtio_device::queue

Struct Queue

Source
pub struct Queue<'a, N> { /* private fields */ }
Expand description

Representation of a virtqueue.

Aside from construction of the queue the only provided method is to retrieve the [next_chain] (Queue::next_chain) if one has been published by the driver. The DescChain, if one is returned, implements a custom drop to return the chain to the queue, and hence to the driver.

Implementations§

Source§

impl<'a, N> Queue<'a, N>

Source

pub fn new(mem: QueueMemory<'a>, notify: N) -> Option<Self>

Constructs a new Queue from memory descriptions.

Takes a QueueMemory, which is just a list of memory regions, for which to create a queue out of. This internally creates a Driver and [Device] (ring::Device) from the provided regions.

The rings are assumed to not have yet been used and so the used and avail indices will start at 0. There is presently no way to construct a Queue around rings that have already been in use.

Source

pub fn new_from_rings( driver: Driver<'a>, device: Device<'a>, notify: N, ) -> Option<Self>

Construct a new Queue from provided rings.

Consumes a Driver and Device to create a Queue. It is expected that new will typically be more useful to automate the ring construction.

Has the same initial ring state assumptions as new.

Source§

impl<'a, N: DriverNotify> Queue<'a, N>

Source

pub fn next_chain<'b>(&'b self) -> Option<DescChain<'a, 'b, N>>

Return any available DescChain.

Polls the available ring for any queued descriptor chain, and if found returns a DescChain abstraction around it.

It is the responsibility of the device to know, presumably via the transport level queue notifications, when a descriptor chain might be available and to call this polling function.

The DescChain is automatically returned the driver, via the used ring, when it is dropped.

Auto Trait Implementations§

§

impl<'a, N> !Freeze for Queue<'a, N>

§

impl<'a, N> !RefUnwindSafe for Queue<'a, N>

§

impl<'a, N> !Send for Queue<'a, N>

§

impl<'a, N> !Sync for Queue<'a, N>

§

impl<'a, N> Unpin for Queue<'a, N>
where N: Unpin,

§

impl<'a, N> UnwindSafe for Queue<'a, N>
where N: 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.