pub mod config;
pub mod storage;
pub use config::BackendConfig;
pub use storage::{
build_backend, LocalStorage, PgCacheConn, PgStorageBackend, PgTable, RedisBackend, RedisConn,
S3Storage, StorageBackend, StorageIndex, TieredBackend, TieredTier, WritePolicy,
TIERED_BACKEND_TIER,
};
#[cfg(feature = "redis-client")]
pub use storage::RedisConnectionManager;
#[cfg(feature = "postgres")]
pub use storage::SqlxPgCacheConn;
#[derive(Debug, thiserror::Error)]
pub enum StoreError {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("path not found: {0}")]
PathNotFound(String),
#[error("signing error: {0}")]
Signing(String),
#[error("not implemented: {0}")]
NotImplemented(&'static str),
#[error("narinfo error: {0}")]
NarInfo(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn store_error_display_path_not_found() {
let e = StoreError::PathNotFound("/nix/store/abc".to_string());
assert!(format!("{e}").contains("/nix/store/abc"));
}
#[test]
fn store_error_display_io() {
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "missing");
let e = StoreError::Io(io_err);
assert!(format!("{e}").contains("missing"));
}
#[test]
fn store_error_display_signing() {
let e = StoreError::Signing("bad key".to_string());
assert!(format!("{e}").contains("bad key"));
}
#[test]
fn store_error_display_not_implemented() {
let e = StoreError::NotImplemented("redis L1");
assert!(format!("{e}").contains("redis L1"));
}
#[test]
fn store_error_display_narinfo() {
let e = StoreError::NarInfo("parse failed".to_string());
assert!(format!("{e}").contains("parse failed"));
}
}