#[repr(C)]pub struct Descriptor { /* private fields */ }
Expand description
A virtio descriptor constraints with C representation.
§Example
use virtio_queue::{desc::{split::Descriptor as SplitDescriptor, RawDescriptor}, Queue, QueueOwnedT};
use vm_memory::{GuestAddress, GuestMemoryMmap};
let m = &GuestMemoryMmap::<()>::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap();
// Populate the queue with descriptor chains and update the available ring accordingly.
let mut queue = populate_queue(m);
let mut i = queue.iter(m).unwrap();
let mut c = i.next().unwrap();
// Get the first descriptor and access its fields.
let desc = c.next().unwrap();
let _addr = desc.addr();
let _len = desc.len();
let _flags = desc.flags();
let _next = desc.next();
let _is_write_only = desc.is_write_only();
let _has_next = desc.has_next();
let _refers_to_ind_table = desc.refers_to_indirect_table();
A virtio split descriptor constraints with C representation.
Implementations§
Source§impl Descriptor
impl Descriptor
Sourcepub fn new(addr: u64, len: u32, flags: u16, next: u16) -> Self
pub fn new(addr: u64, len: u32, flags: u16, next: u16) -> Self
Create a new descriptor.
§Arguments
addr
- the guest physical address of the descriptor buffer.len
- the length of the descriptor buffer.flags
- theflags
for the descriptor.next
- thenext
field of the descriptor.
Sourcepub fn addr(&self) -> GuestAddress
pub fn addr(&self) -> GuestAddress
Return the guest physical address of the descriptor buffer.
Sourcepub fn flags(&self) -> u16
pub fn flags(&self) -> u16
Return the flags for this descriptor, including next, write and indirect bits.
Sourcepub fn refers_to_indirect_table(&self) -> bool
pub fn refers_to_indirect_table(&self) -> bool
Check whether this descriptor refers to a buffer containing an indirect descriptor table.
Sourcepub fn is_write_only(&self) -> bool
pub fn is_write_only(&self) -> bool
Check if the driver designated this as a write only descriptor.
If this is false, this descriptor is read only. Write only means the the emulated device can write and the driver can read.
Trait Implementations§
Source§impl ByteValued for Descriptor
impl ByteValued for Descriptor
Source§fn from_slice(data: &[u8]) -> Option<&Self>
fn from_slice(data: &[u8]) -> Option<&Self>
Converts a slice of raw data into a reference of
Self
. Read moreSource§fn from_mut_slice(data: &mut [u8]) -> Option<&mut Self>
fn from_mut_slice(data: &mut [u8]) -> Option<&mut Self>
Converts a mutable slice of raw data into a mutable reference of
Self
. Read moreSource§fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Converts a mutable reference to
self
into a mutable slice of bytes. Read moreSource§fn as_bytes(&mut self) -> VolatileSlice<'_>
fn as_bytes(&mut self) -> VolatileSlice<'_>
Converts a mutable reference to
self
into a VolatileSlice
. This is
useful because VolatileSlice
provides a Bytes<usize>
implementation. Read moreSource§impl Clone for Descriptor
impl Clone for Descriptor
Source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Descriptor
impl Debug for Descriptor
Source§impl Default for Descriptor
impl Default for Descriptor
Source§fn default() -> Descriptor
fn default() -> Descriptor
Returns the “default value” for a type. Read more
Source§impl From<Descriptor> for RawDescriptor
impl From<Descriptor> for RawDescriptor
Source§fn from(desc: Descriptor) -> Self
fn from(desc: Descriptor) -> Self
Converts to this type from the input type.
Source§impl From<RawDescriptor> for Descriptor
impl From<RawDescriptor> for Descriptor
Source§fn from(desc: RawDescriptor) -> Descriptor
fn from(desc: RawDescriptor) -> Descriptor
Converts to this type from the input type.
impl Copy for Descriptor
Auto Trait Implementations§
impl Freeze for Descriptor
impl RefUnwindSafe for Descriptor
impl Send for Descriptor
impl Sync for Descriptor
impl Unpin for Descriptor
impl UnwindSafe for Descriptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more