pub trait FileIdCache {
// Required methods
fn cached_file_id(&self, path: &Path) -> Option<&FileId>;
fn add_path(&mut self, path: &Path, recursive_mode: RecursiveMode);
fn remove_path(&mut self, path: &Path);
// Provided method
fn rescan(&mut self, roots: &[(PathBuf, RecursiveMode)]) { ... }
}
Expand description
The interface of a file ID cache.
This trait can be implemented for an existing cache, if it already holds FileId
s.
Required Methods§
Sourcefn cached_file_id(&self, path: &Path) -> Option<&FileId>
fn cached_file_id(&self, path: &Path) -> Option<&FileId>
Get a FileId
from the cache for a given path
.
If the path is not cached, None
should be returned and there should not be any attempt to read the file ID from disk.
Sourcefn add_path(&mut self, path: &Path, recursive_mode: RecursiveMode)
fn add_path(&mut self, path: &Path, recursive_mode: RecursiveMode)
Add a new path to the cache or update its value.
This will be called if a new file or directory is created or if an existing file is overridden.
Sourcefn remove_path(&mut self, path: &Path)
fn remove_path(&mut self, path: &Path)
Remove a path from the cache.
This will be called if a file or directory is deleted.
Provided Methods§
Sourcefn rescan(&mut self, roots: &[(PathBuf, RecursiveMode)])
fn rescan(&mut self, roots: &[(PathBuf, RecursiveMode)])
Re-scan all paths.
This will be called if the notification back-end has dropped events.