#![allow(clippy::missing_errors_doc)]
pub mod kv;
mod rust_plan;
mod store;
pub use kv::{
is_valid_namespace, Key, KvError, KvResult, KvStore, INLINE_THRESHOLD, MAX_VALUE_BYTES,
};
pub use rust_plan::{
restore_rust_plan_local, rust_plan_bundle_dir, rust_plan_cache_key, save_rust_plan_local,
RustArtifactBundleManifest, RustArtifactClass, RustArtifactPlanV1, RustBundledArtifact,
RustPlanArtifactEffectiveness, RustPlanCompatibility, RustPlanError, RustPlanInputs,
RustPlanMode, RustPlanOperation, RustPlanPackages, RustPlanSkippedSample, RustPlanSummary,
RustToolchainIdentity, RUST_ARTIFACT_CACHE_SCHEMA_VERSION, RUST_ARTIFACT_PLAN_SCHEMA_VERSION,
};
pub use store::{ArtifactIndex, ArtifactStore};
use std::path::Path;
use zccache_core::NormalizedPath;
#[derive(Debug, Clone)]
pub struct ArtifactStoreConfig {
pub cache_dir: NormalizedPath,
pub max_size: u64,
}
pub struct ArtifactStoreLegacy {
config: ArtifactStoreConfig,
}
impl ArtifactStoreLegacy {
pub fn open(config: ArtifactStoreConfig) -> zccache_core::Result<Self> {
std::fs::create_dir_all(&config.cache_dir)?;
Ok(Self { config })
}
#[must_use]
pub fn artifact_path(&self, key: &zccache_hash::ContentHash) -> NormalizedPath {
let shards = key.shard_prefix(2, 1);
self.config
.cache_dir
.join("artifacts")
.join(&shards[0])
.join(&shards[1])
.join(key.to_hex())
}
#[must_use]
pub fn contains(&self, key: &zccache_hash::ContentHash) -> bool {
self.artifact_path(key).exists()
}
#[must_use]
pub fn cache_dir(&self) -> &Path {
&self.config.cache_dir
}
}