pub trait Transport {
Show 19 methods
// Required methods
fn device_type(&self) -> DeviceType;
fn read_device_features(&mut self) -> u64;
fn write_driver_features(&mut self, driver_features: u64);
fn max_queue_size(&mut self, queue: u16) -> u32;
fn notify(&mut self, queue: u16);
fn get_status(&self) -> DeviceStatus;
fn set_status(&mut self, status: DeviceStatus);
fn set_guest_page_size(&mut self, guest_page_size: u32);
fn requires_legacy_layout(&self) -> bool;
fn queue_set(
&mut self,
queue: u16,
size: u32,
descriptors: PhysAddr,
driver_area: PhysAddr,
device_area: PhysAddr,
);
fn queue_unset(&mut self, queue: u16);
fn queue_used(&mut self, queue: u16) -> bool;
fn ack_interrupt(&mut self) -> InterruptStatus;
fn read_config_generation(&self) -> u32;
fn read_config_space<T: FromBytes + IntoBytes>(
&self,
offset: usize,
) -> Result<T>;
fn write_config_space<T: IntoBytes + Immutable>(
&mut self,
offset: usize,
value: T,
) -> Result<()>;
// Provided methods
fn begin_init<F: Flags<Bits = u64> + BitAnd<Output = F> + Debug>(
&mut self,
supported_features: F,
) -> F { ... }
fn finish_init(&mut self) { ... }
fn read_consistent<T>(&self, f: impl Fn() -> Result<T>) -> Result<T> { ... }
}Expand description
A VirtIO transport layer.
Required Methods§
Sourcefn device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
Gets the device type.
Sourcefn read_device_features(&mut self) -> u64
fn read_device_features(&mut self) -> u64
Reads device features.
Sourcefn write_driver_features(&mut self, driver_features: u64)
fn write_driver_features(&mut self, driver_features: u64)
Writes device features.
Sourcefn max_queue_size(&mut self, queue: u16) -> u32
fn max_queue_size(&mut self, queue: u16) -> u32
Gets the max size of the given queue.
Sourcefn get_status(&self) -> DeviceStatus
fn get_status(&self) -> DeviceStatus
Gets the device status.
Sourcefn set_status(&mut self, status: DeviceStatus)
fn set_status(&mut self, status: DeviceStatus)
Sets the device status.
Sourcefn set_guest_page_size(&mut self, guest_page_size: u32)
fn set_guest_page_size(&mut self, guest_page_size: u32)
Sets the guest page size.
Sourcefn requires_legacy_layout(&self) -> bool
fn requires_legacy_layout(&self) -> bool
Returns whether the transport requires queues to use the legacy layout.
Ref: 2.6.2 Legacy Interfaces: A Note on Virtqueue Layout
Sourcefn queue_set(
&mut self,
queue: u16,
size: u32,
descriptors: PhysAddr,
driver_area: PhysAddr,
device_area: PhysAddr,
)
fn queue_set( &mut self, queue: u16, size: u32, descriptors: PhysAddr, driver_area: PhysAddr, device_area: PhysAddr, )
Sets up the given queue.
Sourcefn queue_unset(&mut self, queue: u16)
fn queue_unset(&mut self, queue: u16)
Disables and resets the given queue.
Sourcefn queue_used(&mut self, queue: u16) -> bool
fn queue_used(&mut self, queue: u16) -> bool
Returns whether the queue is in use, i.e. has a nonzero PFN or is marked as ready.
Sourcefn ack_interrupt(&mut self) -> InterruptStatus
fn ack_interrupt(&mut self) -> InterruptStatus
Acknowledges an interrupt.
Returns true on success.
Sourcefn read_config_generation(&self) -> u32
fn read_config_generation(&self) -> u32
Reads the configuration space generation.
Sourcefn read_config_space<T: FromBytes + IntoBytes>(
&self,
offset: usize,
) -> Result<T>
fn read_config_space<T: FromBytes + IntoBytes>( &self, offset: usize, ) -> Result<T>
Reads a value from the device config space.
Sourcefn write_config_space<T: IntoBytes + Immutable>(
&mut self,
offset: usize,
value: T,
) -> Result<()>
fn write_config_space<T: IntoBytes + Immutable>( &mut self, offset: usize, value: T, ) -> Result<()>
Writes a value to the device config space.
Provided Methods§
Sourcefn begin_init<F: Flags<Bits = u64> + BitAnd<Output = F> + Debug>(
&mut self,
supported_features: F,
) -> F
fn begin_init<F: Flags<Bits = u64> + BitAnd<Output = F> + Debug>( &mut self, supported_features: F, ) -> F
Begins initializing the device.
Ref: virtio 3.1.1 Device Initialization
Returns the negotiated set of features.
Sourcefn finish_init(&mut self)
fn finish_init(&mut self)
Finishes initializing the device.
Sourcefn read_consistent<T>(&self, f: impl Fn() -> Result<T>) -> Result<T>
fn read_consistent<T>(&self, f: impl Fn() -> Result<T>) -> Result<T>
Safely reads multiple fields from config space by ensuring that the config generation is the same before and after all reads, and retrying if not.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.