mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: disk_file: Add AsyncFullDiskFile trait
Marker trait combining FullDiskFile and AsyncDiskFile. Blanket impl covers any type implementing both supertraits. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
8623edb8aa
commit
dac8707c35
@@ -139,3 +139,20 @@ pub trait AsyncDiskFile: DiskFile + Unpin {
|
|||||||
/// fallback implementations) may ignore this value.
|
/// fallback implementations) may ignore this value.
|
||||||
fn new_async_io(&self, ring_depth: u32) -> BlockResult<Box<dyn AsyncIo>>;
|
fn new_async_io(&self, ring_depth: u32) -> BlockResult<Box<dyn AsyncIo>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Full capability async disk file trait.
|
||||||
|
///
|
||||||
|
/// Combines [`FullDiskFile`] (all optional capabilities) with
|
||||||
|
/// [`AsyncDiskFile`] (async I/O construction). This is the top level
|
||||||
|
/// trait for virtio block devices that need both feature negotiation
|
||||||
|
/// and async queue workers.
|
||||||
|
///
|
||||||
|
/// The type narrowing on [`AsyncDiskFile::try_clone`] is intentional:
|
||||||
|
/// clones only serve as data plane handles for queue workers, while
|
||||||
|
/// the original `AsyncFullDiskFile` handle remains the control plane
|
||||||
|
/// for feature negotiation and configuration.
|
||||||
|
pub trait AsyncFullDiskFile: FullDiskFile + AsyncDiskFile {}
|
||||||
|
|
||||||
|
/// Blanket implementation: any type implementing both [`FullDiskFile`]
|
||||||
|
/// and [`AsyncDiskFile`] automatically satisfies [`AsyncFullDiskFile`].
|
||||||
|
impl<T: FullDiskFile + AsyncDiskFile> AsyncFullDiskFile for T {}
|
||||||
|
|||||||
Reference in New Issue
Block a user