ferripfs_blockstore/
lib.rs1mod block;
19mod caching;
20mod cid_utils;
21mod flatfs;
22mod gc;
23mod traits;
24
25pub use block::*;
26pub use caching::*;
27pub use cid_utils::*;
28pub use flatfs::*;
29pub use gc::*;
30pub use traits::*;
31
32use thiserror::Error;
33
34#[derive(Debug, Error)]
36pub enum BlockstoreError {
37 #[error("Block not found: {0}")]
38 NotFound(String),
39
40 #[error("Invalid CID: {0}")]
41 InvalidCid(String),
42
43 #[error("Invalid multihash type: {0}")]
44 InvalidMultihash(String),
45
46 #[error("Hash mismatch: expected {expected}, got {actual}")]
47 HashMismatch { expected: String, actual: String },
48
49 #[error("IO error: {0}")]
50 Io(#[from] std::io::Error),
51
52 #[error("Repository error: {0}")]
53 Repo(#[from] ferripfs_repo::RepoError),
54
55 #[error("CID error: {0}")]
56 Cid(String),
57
58 #[error("GC blocked: {0}")]
59 GcBlocked(String),
60}
61
62pub type BlockstoreResult<T> = Result<T, BlockstoreError>;
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68
69 #[test]
70 fn test_error_display() {
71 let err = BlockstoreError::NotFound("QmTest".to_string());
72 assert!(err.to_string().contains("not found"));
73 }
74}