pub struct CacheStore { /* private fields */ }Expand description
A file-based cache store for scan findings.
Implementations§
Source§impl CacheStore
impl CacheStore
pub fn new(project_root: &Path) -> Self
Sourcepub fn with_dir(dir: PathBuf) -> Self
pub fn with_dir(dir: PathBuf) -> Self
Create a cache store that writes directly to the given directory
instead of appending .slopguard-cache.
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.
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.
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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