pub struct SymbolCache { /* private fields */ }Expand description
Shared symbol cache that can be pre-warmed in a background thread and read by all parser instances.
Implementations§
Source§impl SymbolCache
impl SymbolCache
pub fn new() -> Self
Sourcepub fn set_project_root(&mut self, project_root: PathBuf)
pub fn set_project_root(&mut self, project_root: PathBuf)
Set the project root used for disk persistence.
Sourcepub fn set_project_root_for_generation(
&mut self,
generation: u64,
project_root: PathBuf,
) -> bool
pub fn set_project_root_for_generation( &mut self, generation: u64, project_root: PathBuf, ) -> bool
Set the project root only when the caller still belongs to the active cache generation.
Sourcepub fn insert(
&mut self,
path: PathBuf,
mtime: SystemTime,
size: u64,
content_hash: Hash,
symbols: Vec<Symbol>,
)
pub fn insert( &mut self, path: PathBuf, mtime: SystemTime, size: u64, content_hash: Hash, symbols: Vec<Symbol>, )
Insert pre-warmed symbols for a file.
Sourcepub fn insert_for_generation(
&mut self,
generation: u64,
path: PathBuf,
mtime: SystemTime,
size: u64,
content_hash: Hash,
symbols: Vec<Symbol>,
) -> bool
pub fn insert_for_generation( &mut self, generation: u64, path: PathBuf, mtime: SystemTime, size: u64, content_hash: Hash, symbols: Vec<Symbol>, ) -> bool
Insert symbols only when the caller still belongs to the active cache generation.
Sourcepub fn get(&self, path: &Path, mtime: SystemTime) -> Option<Vec<Symbol>>
pub fn get(&self, path: &Path, mtime: SystemTime) -> Option<Vec<Symbol>>
Return cached symbols when the source file is still fresh.
Sourcepub fn symbol_count_if_metadata_matches(
&self,
path: &Path,
mtime: SystemTime,
size: u64,
) -> Option<usize>
pub fn symbol_count_if_metadata_matches( &self, path: &Path, mtime: SystemTime, size: u64, ) -> Option<usize>
Return a cached symbol count when file metadata exactly matches the cache entry.
This is the fast path for directory file-tree summaries: when mtime and size are unchanged, callers can use the count without cloning symbols or re-reading the file to verify a content hash.
Sourcepub fn contains_path_with_mtime(&self, path: &Path, mtime: SystemTime) -> bool
pub fn contains_path_with_mtime(&self, path: &Path, mtime: SystemTime) -> bool
Whether the cache has a still-valid entry for the given file mtime.
Sourcepub fn load_from_disk(
&mut self,
storage_dir: &Path,
project_key: &str,
current_root: &Path,
) -> usize
pub fn load_from_disk( &mut self, storage_dir: &Path, project_key: &str, current_root: &Path, ) -> usize
Load valid symbol entries from disk, dropping only entries whose source file changed.
Sourcepub fn load_from_disk_for_generation(
&mut self,
generation: u64,
storage_dir: &Path,
project_key: &str,
current_root: &Path,
) -> usize
pub fn load_from_disk_for_generation( &mut self, generation: u64, storage_dir: &Path, project_key: &str, current_root: &Path, ) -> usize
Load valid symbol entries from disk only when the caller still belongs to the active cache generation.
Sourcepub fn invalidate(&mut self, path: &Path)
pub fn invalidate(&mut self, path: &Path)
Invalidate cached symbols for a specific file.
Sourcepub fn reset(&mut self) -> u64
pub fn reset(&mut self) -> u64
Clear all entries and advance the generation to ignore stale background writers.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current generation token.
Sourcepub fn contains_key(&self, path: &Path) -> bool
pub fn contains_key(&self, path: &Path) -> bool
Whether the cache has an entry for a file.
Trait Implementations§
Source§impl Clone for SymbolCache
impl Clone for SymbolCache
Source§fn clone(&self) -> SymbolCache
fn clone(&self) -> SymbolCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for SymbolCache
impl Default for SymbolCache
Source§fn default() -> SymbolCache
fn default() -> SymbolCache
Auto Trait Implementations§
impl Freeze for SymbolCache
impl RefUnwindSafe for SymbolCache
impl Send for SymbolCache
impl Sync for SymbolCache
impl Unpin for SymbolCache
impl UnsafeUnpin for SymbolCache
impl UnwindSafe for SymbolCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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