Expand description
§Page Loader
Runtime file-loading pipeline for v2 JSON-UI specs (Phase 119).
This module exposes load_cached, a cache-aware loader that:
- Canonicalizes the input path (
fs::canonicalize) — used as the cache key. - Reads the file contents (
fs::read_to_string). - Parses into a
SpecviaSpec::from_json(structural validation). - Validates against
global_catalog().validate(&spec)(component + envelope). - Inserts
(Arc<Spec>, mtime)into a process-levelOnceLock<RwLock<HashMap>>.
In production (reload_if_changed = false), entries are never evicted after
first load. In development (reload_if_changed = true), each request performs
a single fs::metadata(path).modified() syscall — if the mtime has advanced
past the cached mtime, the entry is reloaded. No background thread, no
notify crate (119-CONTEXT D-03).
Errors are returned as LoadError with three variants: Io (read or
canonicalize), Parse (structural), Catalog (component schema).
The cache follows the same OnceLock<RwLock<...>> pattern used by
crate::catalog::global_catalog and crate::layout::global_registry.
Enums§
- Load
Error - Errors returned by
load_cachedand related loader entry points.
Functions§
- load_
cached - Load a spec from
path, using the process-level cache.