pub struct Files { /* private fields */ }Expand description
Lookup table that maps file paths to salsa interned File instances.
Implementations§
Source§impl Files
impl Files
Sourcepub fn freeze(&self)
pub fn freeze(&self)
Freezes all inputs on files created from now on.
Existing files retain their current durability. Callers should therefore call this before discovering any files if they need the freeze to apply to the entire project.
Sourcepub fn try_system(&self, db: &dyn Db, path: &SystemPath) -> Option<File>
pub fn try_system(&self, db: &dyn Db, path: &SystemPath) -> Option<File>
Tries to look up the file for the given system path, returns None if no such file exists yet
Sourcepub fn virtual_file(&self, db: &dyn Db, path: &SystemVirtualPath) -> VirtualFile
pub fn virtual_file(&self, db: &dyn Db, path: &SystemVirtualPath) -> VirtualFile
Create a new virtual file at the given path and store it for future lookups.
This will always create a new file, overwriting any existing file at path in the internal
storage.
Sourcepub fn try_virtual_file(&self, path: &SystemVirtualPath) -> Option<VirtualFile>
pub fn try_virtual_file(&self, path: &SystemVirtualPath) -> Option<VirtualFile>
Tries to look up a virtual file by its path. Returns None if no such file exists yet.
Sourcepub fn root(&self, db: &dyn Db, path: &SystemPath) -> Option<FileRoot>
pub fn root(&self, db: &dyn Db, path: &SystemPath) -> Option<FileRoot>
Looks up the closest root for path. Returns None if path isn’t enclosed by any source root.
Roots can be nested, in which case the closest root is returned.
Sourcepub fn try_add_root(
&self,
db: &dyn Db,
path: &SystemPath,
kind: FileRootKind,
) -> FileRoot
pub fn try_add_root( &self, db: &dyn Db, path: &SystemPath, kind: FileRootKind, ) -> FileRoot
Adds a new root for path and returns the root.
The root isn’t added nor is the file root’s kind updated if a root for path already exists.
Sourcepub fn sync_all_recursive<P, I>(db: &mut dyn Db, paths: I)
pub fn sync_all_recursive<P, I>(db: &mut dyn Db, paths: I)
Refreshes the state of all known files under paths recursively.
The most common use case is to update the Files state after removing or moving directories.
§Performance
Refreshing the state of files recursively is expensive. It requires iterating over all known files
and making system calls to get the latest status of matching files.
That’s why File::sync_path is preferred if it is known that the path is a file.
Sourcepub fn sync_all(db: &mut dyn Db)
pub fn sync_all(db: &mut dyn Db)
Refreshes the state of all known files.
This is a last-resort method that should only be used when more granular updates aren’t possible (for example, because the file watcher failed to observe some changes). Use responsibly!
§Performance
Refreshing the state of every file is expensive. It requires iterating over all known files and issuing a system call to get the latest status of each file.
Trait Implementations§
impl RefUnwindSafe for Files
Auto Trait Implementations§
impl !UnwindSafe for Files
impl Freeze for Files
impl Send for Files
impl Sync for Files
impl Unpin for Files
impl UnsafeUnpin for Files
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> 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