add an AsyncReadChunk trait

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-06-12 11:38:21 +02:00
parent a609cf210e
commit 4d16badf6f
4 changed files with 93 additions and 4 deletions

View File

@ -1,3 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use anyhow::Error;
@ -52,3 +54,17 @@ impl ReadChunk for LocalChunkReader {
Ok(raw_data)
}
}
pub trait AsyncReadChunk {
/// Returns the encoded chunk data
fn read_raw_chunk<'a>(
&'a mut self,
digest: &'a [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<DataBlob, Error>> + Send + 'a>>;
/// Returns the decoded chunk data
fn read_chunk<'a>(
&'a mut self,
digest: &'a [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'a>>;
}