pub struct Cache { /* private fields */ }Expand description
A simple filesystem-based cache for audit results.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn new(config: &ProjectConfig) -> Result<Self, ForgeGuardError>
pub fn new(config: &ProjectConfig) -> Result<Self, ForgeGuardError>
Create a new cache instance.
Sourcepub fn store<T: Serialize>(
&self,
key: &str,
value: &T,
) -> Result<(), ForgeGuardError>
pub fn store<T: Serialize>( &self, key: &str, value: &T, ) -> Result<(), ForgeGuardError>
Store a value in the cache.
Sourcepub fn load<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, ForgeGuardError>
pub fn load<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, ForgeGuardError>
Load a value from the cache.
Sourcepub fn clear(&self) -> Result<(), ForgeGuardError>
pub fn clear(&self) -> Result<(), ForgeGuardError>
Clear all cached entries.
Sourcepub fn file_hash(path: &Path) -> Result<String, ForgeGuardError>
pub fn file_hash(path: &Path) -> Result<String, ForgeGuardError>
Compute a content hash for incremental file analysis. Returns a hex string of the file’s SHA-256 hash. Used to skip re-analysis of unchanged files.
Sourcepub fn is_file_unchanged(&self, file_path: &Path) -> bool
pub fn is_file_unchanged(&self, file_path: &Path) -> bool
Check if a file has changed since the last analysis using content hashing.
Returns true if the file is unchanged (cache hit).
Sourcepub fn record_file_hash(&self, file_path: &Path) -> Result<(), ForgeGuardError>
pub fn record_file_hash(&self, file_path: &Path) -> Result<(), ForgeGuardError>
Record a file hash for future incremental analysis. Call this after analyzing a file to mark it as processed.
Sourcepub fn filter_changed_files(&self, files: &[PathBuf]) -> Vec<PathBuf>
pub fn filter_changed_files(&self, files: &[PathBuf]) -> Vec<PathBuf>
Filter out files that have not changed since the last analysis. Returns only the files that need (re-)analysis.
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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