pub trait Device: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn resources(&self) -> &[Resource];
fn access(
&self,
access: &BusAccess,
context: &mut dyn DeviceAccess,
) -> Result<BusResponse, DeviceError>;
}Expand description
The unified device trait.
Every emulated device (interrupt controller, UART, virtio-blk, …)
implements this trait. The device manager calls resources
at registration time for conflict detection and access
on the hot path whenever a vCPU exit is dispatched to this device.
Concrete collaboration between devices and architecture code should be
exposed through typed services registered with the VM device runtime, not
through production downcasts from Arc<dyn Device>.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Returns a human-readable name for this device (used in logging and diagnostics).
Sourcefn resources(&self) -> &[Resource]
fn resources(&self) -> &[Resource]
Returns the resources (MMIO windows, port ranges, system registers) this device requires.
The returned slice is a stable snapshot computed at device construction time. Callers may read it on both the registration path and the hot path without allocation.
Sourcefn access(
&self,
access: &BusAccess,
context: &mut dyn DeviceAccess,
) -> Result<BusResponse, DeviceError>
fn access( &self, access: &BusAccess, context: &mut dyn DeviceAccess, ) -> Result<BusResponse, DeviceError>
Handles a single bus access with runtime-scoped device context.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".