pub struct ValidationCache { /* private fields */ }Expand description
The disk-backed pattern-validation cache.
Implementations§
Source§impl ValidationCache
impl ValidationCache
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Load (or start) the cache at path: a missing file starts empty
(LoadOutcome::Absent), a corrupt or unreadable file starts
empty (LoadOutcome::Corrupt), and entries stamped with another
engine version drop on load.
Sourcepub fn outcome(&self) -> &LoadOutcome
pub fn outcome(&self) -> &LoadOutcome
The load outcome (the caller logs it).
Sourcepub fn key(pattern: &str, ignore_case: bool) -> String
pub fn key(pattern: &str, ignore_case: bool) -> String
The reference _key: sha256 over the pattern, a 0x00 separator,
and the flags char (i when case-insensitive).
Sourcepub fn get(&self, pattern: &str, ignore_case: bool) -> Option<(bool, String)>
pub fn get(&self, pattern: &str, ignore_case: bool) -> Option<(bool, String)>
The cached verdict, None when the pattern was never certified.
Sourcepub fn put(&self, pattern: &str, ignore_case: bool, safe: bool, reason: &str)
pub fn put(&self, pattern: &str, ignore_case: bool, safe: bool, reason: &str)
Record one verdict and persist atomically (tmp file plus rename; a failed write leaves the in-memory entry and drops the persistence, the reference’s logged-but-survivable outcome).
Sourcepub fn validate_compat(&self, pattern: &str) -> (bool, String)
pub fn validate_compat(&self, pattern: &str) -> (bool, String)
The cached validation entry point (the validate_pattern_safety
compat shape): the cheap deterministic layers always re-run, the
empirical cost-verdict layer answers from the cache on a hit and
persists on a miss.
Sourcepub fn validate_with_flags(
&self,
pattern: &str,
ignore_case: bool,
) -> (bool, String)
pub fn validate_with_flags( &self, pattern: &str, ignore_case: bool, ) -> (bool, String)
ValidationCache::validate_compat with the flags char explicit
(a pattern validated under different flags caches separately).