Skip to main content

shardline_cache/
disabled.rs

1use crate::{AsyncReconstructionCache, ReconstructionCacheFuture, ReconstructionCacheKey};
2
3/// No-op reconstruction cache adapter.
4#[derive(Debug, Clone, Default)]
5pub struct DisabledReconstructionCache;
6
7impl DisabledReconstructionCache {
8    /// Creates a disabled reconstruction cache adapter.
9    #[must_use]
10    pub const fn new() -> Self {
11        Self
12    }
13}
14
15impl AsyncReconstructionCache for DisabledReconstructionCache {
16    fn ready(&self) -> ReconstructionCacheFuture<'_, ()> {
17        Box::pin(async { Ok(()) })
18    }
19
20    fn get<'operation>(
21        &'operation self,
22        _key: &'operation ReconstructionCacheKey,
23    ) -> ReconstructionCacheFuture<'operation, Option<Vec<u8>>> {
24        Box::pin(async { Ok(None) })
25    }
26
27    fn put<'operation>(
28        &'operation self,
29        _key: &'operation ReconstructionCacheKey,
30        _payload: &'operation [u8],
31    ) -> ReconstructionCacheFuture<'operation, ()> {
32        Box::pin(async { Ok(()) })
33    }
34
35    fn delete<'operation>(
36        &'operation self,
37        _key: &'operation ReconstructionCacheKey,
38    ) -> ReconstructionCacheFuture<'operation, bool> {
39        Box::pin(async { Ok(false) })
40    }
41}