Expand description
Binary scene cache: TOML stays source of truth; _cache/ holds
content-hash-keyed, version-stamped binaries.
Pure logic lives here (hash, paths, encode/decode, stale matching);
lib.rs owns the filesystem flow (load_cached).
Structs§
- Cache
Header - Header carried by every cache file: which container and scene versions it was written with, plus the exact source it came from.
Enums§
- Cache
Status - How a scene load resolved: cache hit, clean miss (no usable cache), or rebuild (cache existed but was stale/corrupt/mismatched).
Constants§
- CACHE_
DIR_ NAME - Sibling directory next to each scene file holding its binaries.
- CACHE_
EXT - Extension for cache files:
<stem>.<content-hash>.bin. - CACHE_
VERSION - Cache container version. A bump rebuilds every cache from TOML instead of misreading it.
Functions§
- cache_
path_ for - Cache path for a scene file + hex content hash:
<scene_dir>/_cache/<stem>.<hash>.bin. The hash keys the cache, so any source change is a different file (old ones get pruned). - content_
hash - Lowercase hex content hash used in cache filenames.
- decode
- Decode a cache payload. Bad magic, truncation, trailing bytes, or a version stamp that is not the live one all fail loudly — the caller falls back to TOML and says so, never silently reinterprets.
- encode
- Encode a scene document as a cache payload stamped with the live
CACHE_VERSIONandFORMAT_VERSION. - encode_
with - Encode with explicit stamps (test hook: simulates version bumps without touching the live constants).
- fnv1a_
u64 - FNV-1a 64-bit over bytes (same function as
pite-assets, zero deps). - prune_
stale - Remove sibling caches for
scene_pathwhose hash differs fromkeep_hash_hex; returns removed paths. Best-effort: unreadable dirs or failed removals are ignored, never errors.