Files
materialcraft/crates/engine/src/library_cache_prefs.rs
T
chasse20 1a7225c8c2 Auto: Reuse SBS parsing and fix stale preview cache failures
Integrate main's read limits and preserve the font, evaluator, converter,
and measured preview repairs. Complete the scoped type, comment, and
spacing cleanup.

Reuse one validated XML document for library layout and graph reads.
Associate cache maintenance completion with its submitted revision so
old failures cannot consume new settings or clear requests.
2026-11-14 22:52:26 +00:00

28 lines
859 B
Rust

use serde::{Deserialize, Serialize};
/// Disposable library thumbnails; independent of package contents and undo history.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct LibraryCachePrefs {
/// Zero disables disk persistence.
pub disk_mib: u32,
pub max_previews: u32,
}
impl Default for LibraryCachePrefs {
fn default() -> Self {
Self { disk_mib: 64, max_previews: 4096 }
}
}
impl LibraryCachePrefs {
pub const MAX_DISK_MIB: u32 = 65_536;
// Bound directory scans and metadata allocations even with externally supplied settings
pub const MAX_PREVIEWS: u32 = 65_536;
pub fn sanitized(self) -> Self {
Self { disk_mib: self.disk_mib.min(Self::MAX_DISK_MIB), max_previews: self.max_previews.clamp(1, Self::MAX_PREVIEWS) }
}
}