Skip to main content

arcbox_virtio_blk/
backend.rs

1//! Async block I/O backend trait.
2
3/// Async block I/O backend trait.
4#[async_trait::async_trait]
5pub trait AsyncBlockBackend: Send + Sync {
6    /// Reads data from the given sector.
7    async fn read(&self, sector: u64, buf: &mut [u8]) -> std::io::Result<usize>;
8
9    /// Writes data to the given sector.
10    async fn write(&self, sector: u64, buf: &[u8]) -> std::io::Result<usize>;
11
12    /// Flushes pending writes.
13    async fn flush(&self) -> std::io::Result<()>;
14
15    /// Returns the capacity in sectors.
16    fn capacity(&self) -> u64;
17
18    /// Returns whether the device is read-only.
19    fn is_read_only(&self) -> bool;
20}