Skip to main content

Files

Struct Files 

Source
pub struct Files { /* private fields */ }
Expand description

Lookup table that maps file paths to salsa interned File instances.

Implementations§

Source§

impl Files

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn sync_all_recursive<P, I>(db: &mut dyn Db, paths: I)
where P: AsRef<SystemPath>, I: IntoIterator<Item = P>,

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.

Source

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§

Source§

impl Clone for Files

Source§

fn clone(&self) -> Files

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Files

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Files

Source§

fn default() -> Files

Returns the “default value” for a type. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Lookup<T> for T

Source§

fn into_owned(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more