pub struct ExtractionCache { /* private fields */ }Expand description
In-memory extraction cache that can be loaded from and saved to disk
Implementations§
Source§impl ExtractionCache
impl ExtractionCache
Sourcepub fn load(
project_dir: &Path,
macro_prefix: &str,
vars: &HashMap<String, Value>,
cache_dir: Option<&Path>,
) -> Self
pub fn load( project_dir: &Path, macro_prefix: &str, vars: &HashMap<String, Value>, cache_dir: Option<&Path>, ) -> Self
Load the cache from disk, or create an empty one. Entries are discarded when the dlin version, macro prefix hash, or vars hash doesn’t match.
When cache_dir is None, the cache is stored under
<project_dir>/.dlin_cache/extraction_cache.json. When cache_dir is
provided, the cache file is placed directly inside it.
Sourcepub fn fresh(
project_dir: &Path,
macro_prefix: &str,
vars: &HashMap<String, Value>,
cache_dir: Option<&Path>,
) -> Self
pub fn fresh( project_dir: &Path, macro_prefix: &str, vars: &HashMap<String, Value>, cache_dir: Option<&Path>, ) -> Self
Create an empty cache that ignores any existing on-disk entries but
still writes results to disk on save.
Used by --refresh-cache to rebuild the cache from scratch.
Sourcepub fn get(&self, path: &Path, project_dir: &Path) -> Option<&JinjaExtraction>
pub fn get(&self, path: &Path, project_dir: &Path) -> Option<&JinjaExtraction>
Look up a cached extraction for the given file path.
Returns None if not cached or if the file has been modified.
Sourcepub fn insert(
&mut self,
path: &Path,
project_dir: &Path,
extraction: &JinjaExtraction,
)
pub fn insert( &mut self, path: &Path, project_dir: &Path, extraction: &JinjaExtraction, )
Insert an extraction result into the cache.
Auto Trait Implementations§
impl Freeze for ExtractionCache
impl RefUnwindSafe for ExtractionCache
impl Send for ExtractionCache
impl Sync for ExtractionCache
impl Unpin for ExtractionCache
impl UnsafeUnpin for ExtractionCache
impl UnwindSafe for ExtractionCache
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