pub struct CacheStore { /* private fields */ }Expand description
A file-based cache store for scan findings. Every entry is signed with the
store’s CacheKey; an unsigned or tampered entry reads as a miss.
Implementations§
Source§impl CacheStore
impl CacheStore
Sourcepub fn with_dir(dir: PathBuf, key: CacheKey) -> Self
pub fn with_dir(dir: PathBuf, key: CacheKey) -> Self
Create a cache store that writes directly to dir, signing its entries
with key.
Sourcepub fn scoped_to_rules(self, rules_hash: &str) -> Self
pub fn scoped_to_rules(self, rules_hash: &str) -> Self
Scope this store’s entries to a ruleset. Entries written by a scan with a different active ruleset use a different prefix, so a concurrent scan with fewer or disabled rules cannot serve its (correctly empty) result to a scan that expects the full ruleset to fire.
pub fn dir(&self) -> &Path
Sourcepub fn check_rules_changed(
&self,
current_hash: &str,
) -> Result<bool, CacheError>
pub fn check_rules_changed( &self, current_hash: &str, ) -> Result<bool, CacheError>
Check if the rules have changed since the last scan. If they have, invalidate the entire cache.
Sourcepub fn get(&self, file_hash: &str) -> Option<CacheEntry>
pub fn get(&self, file_hash: &str) -> Option<CacheEntry>
Look up a file’s cached scan result by its content hash. An entry whose signature does not verify is ignored.
Sourcepub fn put(&self, file_hash: &str, entry: &CacheEntry) -> Result<(), CacheError>
pub fn put(&self, file_hash: &str, entry: &CacheEntry) -> Result<(), CacheError>
Store a file’s scan result, identified by its content hash and signed with the store’s key.
Auto Trait Implementations§
impl Freeze for CacheStore
impl RefUnwindSafe for CacheStore
impl Send for CacheStore
impl Sync for CacheStore
impl Unpin for CacheStore
impl UnsafeUnpin for CacheStore
impl UnwindSafe for CacheStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more