mirror of
https://github.com/storytold/materialcraft.git
synced 2026-11-20 22:40:59 +01:00
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.
28 lines
859 B
Rust
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) }
|
|
}
|
|
}
|