pub mod config;
pub mod env_expand;
pub mod storage;
pub use config::BackendConfig;
pub use env_expand::{expand_env_vars, ExpandEnvError};
pub use storage::{
advertised_nar_url, advertised_url_line, build_backend, bytes_stream, collect_nar,
empty_stream, file_stream, is_addressable_nar_path, is_servable_narinfo, referrer_of,
spool_or_buffer,
whole_value_stream, BytesNarSource,
FileNarSource, LocalStorage, MemNarRefIndex, NarRefIndex, NarRefKey, NarRefScan, NarResidency,
NarSource, NarStream, PgCacheConn, PgStorageBackend, PgTable, RedisBackend, RedisConn,
S3Storage, SpooledNarSource, StorageBackend, StorageIndex, TieredBackend, TieredTier,
WritePolicy, DEFAULT_INGEST_MEMORY_CAP, NAR_CHUNK_BYTES, NAR_REF_PREFIX, 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),
#[error("value too large: refused at {at_least}+ bytes against a {limit}-byte cap")]
TooLarge {
limit: u64,
at_least: u64,
},
#[error("schema missing: {0}")]
SchemaMissing(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"));
}
}