mod maybe_send;
mod memory;
mod retry;
mod typed;
pub use maybe_send::{MaybeSend, MaybeSync};
pub use memory::MemoryStore;
pub use retry::{RetryConfig, RetryingChunkGet, Sleeper};
pub use typed::{ChunkGet, ChunkHas, ChunkPut};
use crate::bmt::DEFAULT_BODY_SIZE;
use crate::chunk::{AnyChunk, ChunkAddress};
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum ChunkStoreError {
#[error("chunk not found: {0}")]
NotFound(ChunkAddress),
#[error("{0}")]
Other(#[source] Box<dyn std::error::Error + Send + Sync>),
}
impl ChunkStoreError {
pub const fn not_found(address: &ChunkAddress) -> Self {
Self::NotFound(*address)
}
}
#[derive(Debug)]
pub struct NullLoader<const BODY_SIZE: usize = DEFAULT_BODY_SIZE>;
impl<const BODY_SIZE: usize> ChunkGet<BODY_SIZE> for NullLoader<BODY_SIZE> {
type Error = ChunkStoreError;
async fn get(&self, address: &ChunkAddress) -> Result<AnyChunk<BODY_SIZE>, Self::Error> {
Err(ChunkStoreError::not_found(address))
}
}