pub struct ValidationCache { /* private fields */ }Expand description
A disk-backed cache for JSON Schema validation results.
Results are keyed by SHA-256(crate_version + file_content + schema_json + validate_formats_byte).
Cache files are stored as <cache_dir>/<sha256-hex>.json.
Implementations§
Source§impl ValidationCache
impl ValidationCache
pub fn new(cache_dir: PathBuf, skip_read: bool) -> Self
Sourcepub async fn lookup(
&self,
key: &CacheKey<'_>,
) -> (Option<Vec<ValidationError>>, ValidationCacheStatus)
pub async fn lookup( &self, key: &CacheKey<'_>, ) -> (Option<Vec<ValidationError>>, ValidationCacheStatus)
Look up a cached validation result.
Returns (Some(errors), Hit) on cache hit.
Returns (None, Miss) on cache miss or when skip_read is set.
key.schema_hash should be obtained from schema_hash — pass the same
value for all files in a schema group to avoid redundant serialization.
Sourcepub async fn store(&self, key: &CacheKey<'_>, errors: &[ValidationError])
pub async fn store(&self, key: &CacheKey<'_>, errors: &[ValidationError])
Store a validation result to the disk cache.
Always writes regardless of skip_read, so running with
--force-validation repopulates the cache for future runs.
key.schema_hash should be obtained from schema_hash — pass the same
value for all files in a schema group to avoid redundant serialization.
Trait Implementations§
Source§impl Clone for ValidationCache
impl Clone for ValidationCache
Source§fn clone(&self) -> ValidationCache
fn clone(&self) -> ValidationCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more