pub struct ValidationCache { /* private fields */ }Expand description
A disk-backed cache for JSON Schema validation results.
Results are keyed by SHA-256(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 fn lookup(
&self,
file_content: &str,
schema_hash: &str,
validate_formats: bool,
) -> (Option<Vec<(String, String)>>, ValidationCacheStatus)
pub fn lookup( &self, file_content: &str, schema_hash: &str, validate_formats: bool, ) -> (Option<Vec<(String, String)>>, ValidationCacheStatus)
Look up a cached validation result.
Returns (Some(errors), Hit) on cache hit, where each error is
(instance_path, message). Returns (None, Miss) on cache miss or
when skip_read is set.
schema_hash should be obtained from schema_hash — pass the same
value for all files in a schema group to avoid redundant serialization.
Sourcepub fn store(
&self,
file_content: &str,
schema_hash: &str,
validate_formats: bool,
errors: &[(String, String)],
)
pub fn store( &self, file_content: &str, schema_hash: &str, validate_formats: bool, errors: &[(String, String)], )
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.
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