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