1pub mod config;
18pub mod storage;
19
20pub use config::BackendConfig;
21pub use storage::{
22 build_backend, LocalStorage, PgCacheConn, PgStorageBackend, PgTable, RedisBackend, RedisConn,
23 S3Storage, StorageBackend, StorageIndex, TieredBackend, TieredTier, WritePolicy,
24 TIERED_BACKEND_TIER,
25};
26
27#[cfg(feature = "redis-client")]
28pub use storage::RedisConnectionManager;
29
30#[cfg(feature = "postgres")]
31pub use storage::SqlxPgCacheConn;
32
33#[derive(Debug, thiserror::Error)]
35pub enum StoreError {
36 #[error("io error: {0}")]
38 Io(#[from] std::io::Error),
39
40 #[error("path not found: {0}")]
42 PathNotFound(String),
43
44 #[error("signing error: {0}")]
46 Signing(String),
47
48 #[error("not implemented: {0}")]
50 NotImplemented(&'static str),
51
52 #[error("narinfo error: {0}")]
54 NarInfo(String),
55}
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn store_error_display_path_not_found() {
63 let e = StoreError::PathNotFound("/nix/store/abc".to_string());
64 assert!(format!("{e}").contains("/nix/store/abc"));
65 }
66
67 #[test]
68 fn store_error_display_io() {
69 let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "missing");
70 let e = StoreError::Io(io_err);
71 assert!(format!("{e}").contains("missing"));
72 }
73
74 #[test]
75 fn store_error_display_signing() {
76 let e = StoreError::Signing("bad key".to_string());
77 assert!(format!("{e}").contains("bad key"));
78 }
79
80 #[test]
81 fn store_error_display_not_implemented() {
82 let e = StoreError::NotImplemented("redis L1");
83 assert!(format!("{e}").contains("redis L1"));
84 }
85
86 #[test]
87 fn store_error_display_narinfo() {
88 let e = StoreError::NarInfo("parse failed".to_string());
89 assert!(format!("{e}").contains("parse failed"));
90 }
91}