qcow2_rs/
ops.rs

1use crate::error::Qcow2Result;
2#[rustversion::before(1.75)]
3use async_trait::async_trait;
4
5pub struct Qcow2OpsFlags {}
6
7impl Qcow2OpsFlags {
8    pub const FALLOCATE_ZERO_RAGE: u32 = 1_u32 << 0;
9}
10
11/// How read/write/discard are implemented, so that qcow2-rs can be
12/// used with multiple io engine.
13///
14/// these methods are called for reading data from image, writing data
15/// to image, and discarding range.
16#[rustversion::attr(before(1.75), async_trait(?Send))]
17#[rustversion::attr(since(1.75), allow(async_fn_in_trait))]
18pub trait Qcow2IoOps {
19    async fn read_to(&self, offset: u64, buf: &mut [u8]) -> Qcow2Result<usize>;
20    async fn write_from(&self, offset: u64, buf: &[u8]) -> Qcow2Result<()>;
21    async fn fallocate(&self, offset: u64, len: usize, flags: u32) -> Qcow2Result<()>;
22    async fn fsync(&self, offset: u64, len: usize, flags: u32) -> Qcow2Result<()>;
23}