Skip to main content

VirtioBufferRef

Struct VirtioBufferRef 

Source
pub struct VirtioBufferRef<'a> { /* private fields */ }
Expand description

Describes a buffer that can be submitted to a virtio queue.

A buffer describes the memory used by a virtio device to read the input and write the output for a task. The description is a list of VirtioMemoryRange. Each memory range must be contiguous in the PCI device’s addressable space.

The driver submits a buffer to ask the virtio device to perform a task. Submitting a buffer transfers the driver’s ownership of the buffer to the device. The device returns the buffer when it completes the task. Returning the buffer transfers ownership back to the driver.

For convenience, we say that a buffer is submitted when it is owned by the device. We also say that a memory range is submitted when the buffer that it belongs to is submitted. The device may only access the memory submitted buffers, which are the buffers that it owns.

The list of memory regions must first contain the regions storing the task’s input (using VirtioMemoryRangeAccess::Input), followed by the regions storing the task’s output (using VirtioMemoryRangeAccess::Output).

Implementations§

Source§

impl<'a> VirtioBufferRef<'a>

Source

pub const MAX_LENGTH: usize = 32768

The maximum number of contiguous memory regions in a buffer.

The upper bound is based on the fact that a buffer’s memory regions must fit in a virtqueue’s descriptor table, so the number of memory regions is capped by the virtqueue descriptor table size.

Source

pub fn new(range_list: &'a [VirtioMemoryRange]) -> VirtioBufferRef<'a>

Panics if the list of ranges is empty, or if a range with VirtioMemoryRangeAccess::Input access follows a range with VirtioMemoryRangeAccess::Output access.

Source

pub fn len(&self) -> NonZero<u16>

Returns the number of memory ranges in the buffer.

Trait Implementations§

Source§

impl<'a> AsRef<[VirtioMemoryRange]> for VirtioBufferRef<'a>

Source§

fn as_ref(&self) -> &[VirtioMemoryRange]

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

§

impl<'a> Freeze for VirtioBufferRef<'a>

§

impl<'a> RefUnwindSafe for VirtioBufferRef<'a>

§

impl<'a> Send for VirtioBufferRef<'a>

§

impl<'a> Sync for VirtioBufferRef<'a>

§

impl<'a> Unpin for VirtioBufferRef<'a>

§

impl<'a> UnsafeUnpin for VirtioBufferRef<'a>

§

impl<'a> UnwindSafe for VirtioBufferRef<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.