1#![deny(unsafe_code)]
2#![warn(missing_docs)]
3pub mod cid;
7pub mod file;
8#[cfg(feature = "s3")]
9pub mod s3;
10
11pub use cid::compute_cid;
12
13use async_trait::async_trait;
14
15#[derive(Debug, thiserror::Error)]
17pub enum BlobError {
18 #[error("blob not found: {0}")]
20 NotFound(String),
21 #[error("blob store error: {0}")]
23 Storage(#[from] anyhow::Error),
24}
25
26#[async_trait]
28pub trait BlobStore: Send + Sync + 'static {
29 async fn put(&self, data: &[u8]) -> Result<String, BlobError>;
31 async fn get(&self, cid: &str) -> Result<Vec<u8>, BlobError>;
33 async fn exists(&self, cid: &str) -> Result<bool, BlobError>;
35 async fn delete(&self, cid: &str) -> Result<(), BlobError>;
37}