pub fn load_cached(
path: &Path,
reload_if_changed: bool,
) -> Result<Arc<Spec>, LoadError>Expand description
Load a spec from path, using the process-level cache.
§Parameters
path— filesystem path to a v2 JSON-UI spec file.reload_if_changed— whentrue, checks the file’s mtime against the cached mtime; if the file has changed, evicts and reloads. Set this from!Config::is_production()at the framework integration layer.
§Returns
Ok(Arc<Spec>) on cache hit or successful load. The Arc is cloned from
the cache entry — callers who need an owned Spec (e.g. for
Spec::merge_data) must call (*arc).clone() to get a Spec
(119-RESEARCH §Pitfall 1).
§Errors
LoadError::Io— file missing, unreadable, or canonicalize fails.LoadError::Parse— file contents are not a structurally valid Spec.LoadError::Catalog— spec parses but fails catalog validation.
§Concurrency
Reads use a shared read lock. Writes (first load, reload) briefly acquire a write lock AFTER parsing and validation have completed — no fallible code runs inside the write guard, so the lock cannot be poisoned by a panic-throwing parser (119-RESEARCH §Pitfall 2).