Skip to main content

ValidationCache

Struct ValidationCache 

Source
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

Source

pub fn new(cache_dir: PathBuf, skip_read: bool) -> Self

Source

pub async fn lookup( &self, file_content: &str, schema_hash: &str, validate_formats: bool, ) -> (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.

schema_hash should be obtained from schema_hash — pass the same value for all files in a schema group to avoid redundant serialization.

Source

pub async fn store( &self, file_content: &str, schema_hash: &str, validate_formats: bool, 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.

schema_hash should be obtained from schema_hash — pass the same value for all files in a schema group to avoid redundant serialization.

Source

pub fn cache_key( file_content: &str, schema_hash: &str, validate_formats: bool, ) -> String

Compute the SHA-256 cache key from file content, a pre-computed schema hash, and format flag.

The crate version is included in the hash so that upgrading lintel automatically invalidates stale cache entries.

Trait Implementations§

Source§

impl Clone for ValidationCache

Source§

fn clone(&self) -> ValidationCache

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.