block: disk_file: Add DiskSize trait

Reported capacity of a disk image. Every format, be it
file backed, network, memory, exposes a logical size.
Single method logical_size() returning the virtual size
in bytes.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-12 20:13:47 +01:00
committed by Rob Bradford
parent a15bfcfee6
commit 85e4e5027c

View File

@@ -32,3 +32,13 @@
//!
//! Readonly accessors take `&self`. Only [`Resizable::resize`] requires
//! `&mut self`. Errors are returned as [`BlockResult`].
use std::fmt::Debug;
use crate::BlockResult;
/// Reported capacity of a disk image.
pub trait DiskSize: Send + Debug {
/// Virtual size of the disk image in bytes (reported capacity).
fn logical_size(&self) -> BlockResult<u64>;
}