use std::path::PathBuf;
use rspack_cacheable::{cacheable, utils::PortablePath, with::As};
use rspack_paths::Utf8PathBuf;
use super::SnapshotOptions;
pub type BuildDepsOptions = Vec<PathBuf>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MaxMemoryGenerations {
Disabled,
Infinity,
Finite(u32),
}
impl From<Option<u32>> for MaxMemoryGenerations {
fn from(value: Option<u32>) -> Self {
match value {
Some(0) => Self::Disabled,
Some(value) => Self::Finite(value),
None => Self::Infinity,
}
}
}
#[cacheable]
#[derive(Debug, Clone, Hash)]
pub enum StorageOptions {
FileSystem {
#[cacheable(with=As<PortablePath>)]
directory: Utf8PathBuf,
},
}
#[derive(Debug, Clone)]
pub struct PersistentCacheOptions {
pub build_dependencies: BuildDepsOptions,
pub version: String,
pub snapshot: SnapshotOptions,
pub storage: StorageOptions,
pub portable: bool,
pub readonly: bool,
pub max_age: u64,
pub max_memory_generations: MaxMemoryGenerations,
}