pub fn load_cached_spec<P: AsRef<Path>>(
cache_dir: P,
spec_name: &str,
) -> Result<CachedSpec, Error>Expand description
Loads a cached OpenAPI specification from the binary cache with optimized version checking.
This function uses a global cache metadata file for fast version checking before loading the full specification, significantly improving performance.
After version checks pass, validates the spec file fingerprint (mtime, size, content hash)
against the cached metadata. If the spec file has been modified since caching, returns
Error::cache_stale with a suggestion to reinitialize.
§Arguments
cache_dir- The directory containing cached spec filesspec_name- The name of the spec to load (without binary extension)
§Returns
Ok(CachedSpec)- The loaded and deserialized specificationErr(Error)- If the file doesn’t exist, deserialization fails, or cache is stale
§Errors
Returns an error if the cache file doesn’t exist, deserialization fails, or the spec file has been modified since the cache was built