pub struct HashCache {
pub version: String,
pub min_block_size: usize,
pub git_commit: Option<String>,
pub created_at: u64,
pub hash_index: HashMap<u64, Vec<CodeLocation>>,
pub file_metadata: HashMap<String, FileCacheMetadata>,
}Expand description
The complete hash cache for a codebase
Fields§
§version: StringVersion of the cache format (for future compatibility)
min_block_size: usizeMinimum block size (tokens) used to build this cache
git_commit: Option<String>Git commit hash when cache was built (if available)
created_at: u64Timestamp when cache was created
hash_index: HashMap<u64, Vec<CodeLocation>>Map from rolling hash to all locations with that hash
file_metadata: HashMap<String, FileCacheMetadata>Metadata for all cached files (for invalidation)
Implementations§
Source§impl HashCache
impl HashCache
Sourcepub fn add_hash(&mut self, hash: u64, location: CodeLocation)
pub fn add_hash(&mut self, hash: u64, location: CodeLocation)
Add a hash entry to the cache
Sourcepub fn lookup(&self, hash: u64) -> Option<&Vec<CodeLocation>>
pub fn lookup(&self, hash: u64) -> Option<&Vec<CodeLocation>>
Look up all locations with a given hash
Sourcepub fn file_needs_rescan(&self, file_path: &str) -> bool
pub fn file_needs_rescan(&self, file_path: &str) -> bool
Check if a file needs to be rescanned (has changed since cache was built)
Sourcepub fn invalidate_file(&mut self, file_path: &str)
pub fn invalidate_file(&mut self, file_path: &str)
Remove all cache entries for a specific file
Sourcepub fn invalidate_stale_files(&mut self) -> HashSet<String>
pub fn invalidate_stale_files(&mut self) -> HashSet<String>
Drop cache entries for files whose metadata no longer matches disk.
Returns the set of file paths that were removed so callers can refresh the cache entries when needed.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HashCache
impl<'de> Deserialize<'de> for HashCache
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HashCache
impl RefUnwindSafe for HashCache
impl Send for HashCache
impl Sync for HashCache
impl Unpin for HashCache
impl UnwindSafe for HashCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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