Struct virtio_device::queue::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>,

§

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.