1use std::{future::Future, pin::Pin};
2
3use crate::{ReconstructionCacheError, ReconstructionCacheKey};
4
5pub type ReconstructionCacheFuture<'operation, T> =
7 Pin<Box<dyn Future<Output = Result<T, ReconstructionCacheError>> + Send + 'operation>>;
8
9pub trait AsyncReconstructionCache: Send + Sync {
11 fn ready(&self) -> ReconstructionCacheFuture<'_, ()>;
13
14 fn get<'operation>(
16 &'operation self,
17 key: &'operation ReconstructionCacheKey,
18 ) -> ReconstructionCacheFuture<'operation, Option<Vec<u8>>>;
19
20 fn put<'operation>(
22 &'operation self,
23 key: &'operation ReconstructionCacheKey,
24 payload: &'operation [u8],
25 ) -> ReconstructionCacheFuture<'operation, ()>;
26
27 fn delete<'operation>(
29 &'operation self,
30 key: &'operation ReconstructionCacheKey,
31 ) -> ReconstructionCacheFuture<'operation, bool>;
32}