storage_kit/error.rs
1//! Error type for Storage Kit — covers both the content-addressed storage
2//! engine (`addressing`, `fragment`, `store`) and the transport `backend`
3//! layer. Merged 2026-08-23 when the engine relocated here from
4//! `bitchain` (design decision): the variants below are
5//! the union of the old `bitchain::BitchainError` (engine-facing) and this
6//! crate's own `StorageError` (backend-facing) — the `Bitchain(#[from] …)`
7//! wrapper variant is gone since this crate no longer depends on
8//! `bitchain` (the dependency direction inverted: `bitchain` now depends
9//! on `storage-kit`, not the other way around).
10
11use thiserror::Error;
12
13#[derive(Debug, Error)]
14pub enum StorageError {
15 #[error("hash mismatch: expected {expected}, got {actual}")]
16 HashMismatch { expected: String, actual: String },
17
18 #[error("not found: {0}")]
19 NotFound(String),
20
21 #[error("corrupt pack: {0}")]
22 CorruptPack(String),
23
24 #[error("corrupt manifest: {0}")]
25 CorruptManifest(String),
26
27 #[error("invalid address: {0}")]
28 InvalidAddress(String),
29
30 #[error("partition boundary violation: {0}")]
31 PartitionBoundary(String),
32
33 /// The format-reservations spec §3.7:
34 /// `PartitionStore::open` no longer creates a partition on first use.
35 /// Returned when no `partition.json` exists for the requested partition.
36 #[error("partition not provisioned: {0}")]
37 PartitionNotProvisioned(String),
38
39 /// Spec §3.7: `PartitionStore::create` is the only place a partition
40 /// directory is ever created, and it refuses to provision over an
41 /// existing record.
42 #[error("partition already provisioned: {0}")]
43 PartitionAlreadyProvisioned(String),
44
45 #[error("compression: {0}")]
46 Compression(String),
47
48 #[error("backend: {0}")]
49 Backend(String),
50
51 #[error("io: {0}")]
52 Io(#[from] std::io::Error),
53
54 #[error("serde: {0}")]
55 Serde(#[from] serde_json::Error),
56}
57
58pub type Result<T> = std::result::Result<T, StorageError>;