From 85e4e5027c42afa79273221935ff8d1cc26c12d7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 12 Mar 2026 20:13:47 +0100 Subject: [PATCH] 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 --- block/src/disk_file.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/src/disk_file.rs b/block/src/disk_file.rs index 30efaff55..3f7edfabf 100644 --- a/block/src/disk_file.rs +++ b/block/src/disk_file.rs @@ -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; +}