pub struct FileCache<T> { /* private fields */ }Expand description
Parsed results per file, valid while the file’s Sig is unchanged.
Implementations§
Source§impl<T> FileCache<T>
impl<T> FileCache<T>
Sourcepub fn get_or_parse(
&self,
path: &Path,
sig: Sig,
parse: impl FnOnce() -> T,
) -> Arc<T> ⓘ
pub fn get_or_parse( &self, path: &Path, sig: Sig, parse: impl FnOnce() -> T, ) -> Arc<T> ⓘ
The cached result for path if its signature still matches sig,
otherwise run parse and remember the result.
Sourcepub fn prune(&self, keep: &HashSet<PathBuf>)
pub fn prune(&self, keep: &HashSet<PathBuf>)
Forget files that no longer exist / are no longer in scope.
Sourcepub fn prune_under(&self, root: &Path, keep: &HashSet<PathBuf>)
pub fn prune_under(&self, root: &Path, keep: &HashSet<PathBuf>)
Forget cached files below root that are not in keep (deleted or out of
scope), leaving every other root’s entries alone.
Sourcepub fn stats(&self) -> (usize, usize)
pub fn stats(&self) -> (usize, usize)
(hits, misses) since creation — what tests (and --bench) look at.
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for FileCache<T>
impl<T> RefUnwindSafe for FileCache<T>
impl<T> Send for FileCache<T>
impl<T> Sync for FileCache<T>
impl<T> Unpin for FileCache<T>
impl<T> UnsafeUnpin for FileCache<T>
impl<T> UnwindSafe for FileCache<T>
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