nectar_primitives/store/
mod.rs1mod maybe_send;
7mod memory;
8mod retry;
9mod typed;
10
11pub use maybe_send::{MaybeSend, MaybeSync};
12pub use memory::MemoryStore;
13pub use retry::{RetryConfig, RetryingChunkGet, Sleeper};
14pub use typed::{ChunkGet, ChunkHas, ChunkPut};
15
16use crate::bmt::DEFAULT_BODY_SIZE;
17use crate::chunk::{AnyChunk, ChunkAddress};
18
19#[non_exhaustive]
21#[derive(Debug, thiserror::Error)]
22pub enum ChunkStoreError {
23 #[error("chunk not found: {0}")]
25 NotFound(ChunkAddress),
26 #[error("{0}")]
28 Other(#[source] Box<dyn std::error::Error + Send + Sync>),
29}
30
31impl ChunkStoreError {
32 pub const fn not_found(address: &ChunkAddress) -> Self {
34 Self::NotFound(*address)
35 }
36}
37
38#[derive(Debug)]
43pub struct NullLoader<const BODY_SIZE: usize = DEFAULT_BODY_SIZE>;
44
45impl<const BODY_SIZE: usize> ChunkGet<BODY_SIZE> for NullLoader<BODY_SIZE> {
46 type Error = ChunkStoreError;
47
48 async fn get(&self, address: &ChunkAddress) -> Result<AnyChunk<BODY_SIZE>, Self::Error> {
49 Err(ChunkStoreError::not_found(address))
50 }
51}