Skip to main content

Crate lintel_validation_cache

Crate lintel_validation_cache 

Source
Expand description

§lintel-validation-cache

Crates.io docs.rs GitHub License

Disk-backed cache for JSON Schema validation results. Caches the outcome of validating a file against a schema so that unchanged files can skip re-validation on subsequent runs.

Part of the Lintel project.

§How it works

Each cache entry is keyed by a SHA-256 digest of the file contents and schema URI. When a file hasn’t changed since the last run, the cached validation result is returned instantly — no parsing or schema evaluation needed.

§Usage

use lintel_validation_cache::{ValidationCache, CacheKey, schema_hash, ensure_cache_dir};

let cache = ValidationCache::new(ensure_cache_dir(), false);

// Compute a schema hash once per schema group
let schema = serde_json::json!({"type": "object"});
let hash = schema_hash(&schema);

// Cache key = SHA-256(file_content + schema_hash + validate_formats)
let ck = CacheKey { file_content: "file contents", schema_hash: &hash, validate_formats: true };
let key = ValidationCache::cache_key(&ck);
drop(key);

§License

Apache-2.0

Structs§

CacheKey
The cache lookup/store key: file content, schema hash, and format-validation flag.
ValidationCache
A disk-backed cache for JSON Schema validation results.
ValidationError
A single validation error with its location and schema context.

Enums§

ValidationCacheStatus
Whether a validation result was served from the disk cache or freshly computed.

Functions§

ensure_cache_dir
Return a usable cache directory for validation results, creating it if necessary.
schema_hash
Compute a SHA-256 hash of a schema Value.