pub struct OutlineCache { /* private fields */ }Expand description
Outline + parse cache keyed by (canonical path, mtime). If the file changes, mtime changes and the old entry is never hit again.
Implementations§
Source§impl OutlineCache
impl OutlineCache
pub fn new() -> Self
Sourcepub fn get_or_compute(
&self,
path: &Path,
mtime: SystemTime,
compute: impl FnOnce() -> String,
) -> Arc<str>
pub fn get_or_compute( &self, path: &Path, mtime: SystemTime, compute: impl FnOnce() -> String, ) -> Arc<str>
Get cached outline or compute and cache it. Accepts &Path (not &PathBuf).
Uses entry() API to avoid TOCTOU race between get and insert.
Sourcepub fn get_or_parse(
&self,
path: &Path,
mtime: SystemTime,
content: &str,
lang: &Language,
) -> Option<Tree>
pub fn get_or_parse( &self, path: &Path, mtime: SystemTime, content: &str, lang: &Language, ) -> Option<Tree>
Get cached parse tree or parse and cache it. Returns None if parsing fails or the language can’t be set. Tree is cheap-clone (refcount internally).
Callers must pass content that matches mtime — stale content + fresh mtime
would poison the cache. In practice both come from the same fs::metadata read.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OutlineCache
impl !RefUnwindSafe for OutlineCache
impl Send for OutlineCache
impl Sync for OutlineCache
impl Unpin for OutlineCache
impl UnsafeUnpin for OutlineCache
impl UnwindSafe for OutlineCache
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