diff --git a/block/src/disk_file.rs b/block/src/disk_file.rs index f76a99662..9e057bd05 100644 --- a/block/src/disk_file.rs +++ b/block/src/disk_file.rs @@ -139,3 +139,20 @@ pub trait AsyncDiskFile: DiskFile + Unpin { /// fallback implementations) may ignore this value. fn new_async_io(&self, ring_depth: u32) -> BlockResult>; } + +/// 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 AsyncFullDiskFile for T {}