Skip to main content

File

Struct File 

Source
pub struct File(/* private fields */);
Expand description

A file-system path that’s either stored on the host system’s file system or in the vendored file system.

§Ordering

Ordering is based on the file’s salsa-assigned id and not on its values. The id may change between runs.

Implementations§

Source§

impl File

Source

pub fn ingredient(db: &dyn Database) -> &IngredientImpl<Self>

Source

pub fn ingredient_mut( zalsa_mut: &mut Zalsa, ) -> (&mut IngredientImpl<Self>, &mut Runtime)

Source§

impl File

Source

pub fn new<Db_>(db: &Db_, path: FilePath) -> Self
where Db_: ?Sized + Database,

Source

pub fn builder(path: FilePath) -> <Self as HasBuilder>::Builder

Source

pub fn path<'db, Db_>(self, db: &'db Db_) -> &'db FilePath
where Db_: ?Sized + Database,

The path of the file (immutable).

Source

pub fn permissions<'db, Db_>(self, db: &'db Db_) -> Option<u32>
where Db_: ?Sized + Database,

The unix permissions of the file. Only supported on unix systems. Always None on Windows or when the file has been deleted.

Source

pub fn revision<'db, Db_>(self, db: &'db Db_) -> FileRevision
where Db_: ?Sized + Database,

The path revision. A file or directory has changed if the revisions don’t compare equal.

Source

pub fn status<'db, Db_>(self, db: &'db Db_) -> FileStatus
where Db_: ?Sized + Database,

The status of the file.

Salsa doesn’t support deleting inputs. The only way to signal dependent queries that the file has been deleted is to change the status to Deleted.

Source

pub fn source_text_override<'db, Db_>( self, db: &'db Db_, ) -> &'db Option<SourceText>
where Db_: ?Sized + Database,

Overrides the result of source_text.

This is useful when running queries after modifying a file’s content but before the content is written to disk. For example, to verify that the applied fixes didn’t introduce any new errors.

The override gets automatically removed the next time the file changes.

Source

pub fn set_path<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FilePath> + use<'db, Db_>
where Db_: ?Sized + Database,

Source

pub fn set_permissions<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = Option<u32>> + use<'db, Db_>
where Db_: ?Sized + Database,

Source

pub fn set_revision<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FileRevision> + use<'db, Db_>
where Db_: ?Sized + Database,

Source

pub fn set_status<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FileStatus> + use<'db, Db_>
where Db_: ?Sized + Database,

Source

pub fn set_source_text_override<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = Option<SourceText>> + use<'db, Db_>
where Db_: ?Sized + Database,

Source

pub fn default_debug_fmt(this: Self, f: &mut Formatter<'_>) -> Result
where for<'__trivial_bounds> FilePath: Debug, for<'__trivial_bounds> Option<u32>: Debug, for<'__trivial_bounds> FileRevision: Debug, for<'__trivial_bounds> FileStatus: Debug, for<'__trivial_bounds> Option<SourceText>: Debug,

Default debug formatting for this struct (may be useful if you define your own Debug impl)

Source§

impl File

Source

pub fn read_to_string(&self, db: &dyn Db) -> Result<String>

Reads the content of the file into a String.

Reading the same file multiple times isn’t guaranteed to return the same content. It’s possible that the file has been modified in between the reads.

Source

pub fn read_to_notebook(&self, db: &dyn Db) -> Result<Notebook, NotebookError>

Reads the content of the file into a Notebook.

Reading the same file multiple times isn’t guaranteed to return the same content. It’s possible that the file has been modified in between the reads.

Source

pub fn sync_path(db: &mut dyn Db, path: &SystemPath)

Refreshes the file metadata by querying the file system if needed.

Directory listings are invalidated if the path’s file status changed, its prior status is unknown, or if path is itself a directory.

Source

pub fn sync_path_only(db: &mut dyn Db, path: &SystemPath)

Refreshes only the file metadata by querying the file system if needed.

This specifically does not invalidate any directory listings.

Source

pub fn sync_virtual_path(db: &mut dyn Db, path: &SystemVirtualPath)

Increments the revision for the virtual file at path.

Source

pub fn sync(self, db: &mut dyn Db)

Syncs the File’s state with the state of the file on the system.

Source

pub fn exists(self, db: &dyn Db) -> bool

Returns true if the file exists.

Source

pub fn is_stub(self, db: &dyn Db) -> bool

Returns true if the file should be analyzed as a type stub.

Source

pub fn is_package_stub(self, db: &dyn Db) -> bool

Returns true if the file is an __init__.pyi

Source

pub fn is_package(self, db: &dyn Db) -> bool

Returns true if the file is an __init__.pyi

Source

pub fn source_type(self, db: &dyn Db) -> PySourceType

Trait Implementations§

Source§

impl AsId for File

Source§

fn as_id(&self) -> Id

Source§

impl Clone for File

Source§

fn clone(&self) -> File

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 Configuration for File

Source§

const LOCATION: Location

Source§

const DEBUG_NAME: &'static str = "File"

Source§

const FIELD_DEBUG_NAMES: &'static [&'static str]

Source§

const PERSIST: bool = false

Whether this struct should be persisted with the database.
Source§

type Singleton = NotSingleton

The singleton state for this input if any.
Source§

type Struct = File

The input struct (which wraps an Id)
Source§

type Fields = (FilePath, Option<u32>, FileRevision, FileStatus, Option<SourceText>)

A (possibly empty) tuple of the fields for this struct.
Source§

type Revisions = [Revision; 5]

Source§

type Durabilities = [Durability; 5]

Source§

fn heap_size(value: &Self::Fields) -> Option<usize>

Returns the size of any heap allocations in the output value, in bytes.
Source§

fn serialize<S: Serializer>( fields: &Self::Fields, serializer: S, ) -> Result<S::Ok, S::Error>

Serialize the fields using serde. Read more
Source§

fn deserialize<'de, D: Deserializer<'de>>( deserializer: D, ) -> Result<Self::Fields, D::Error>

Deserialize the fields using serde. Read more
Source§

impl Copy for File

Source§

impl Debug for File

Source§

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

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

impl Eq for File

Source§

impl From<File> for Span

Source§

fn from(file: File) -> Span

Converts to this type from the input type.
Source§

impl FromId for File

Source§

fn from_id(id: Id) -> Self

Source§

impl GetSize for File

Source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_heap_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines how many bytes this object occupies inside the heap while using a tracker. Read more
Source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
Source§

fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines the total size of the object while using a tracker. Read more
Source§

impl HasBuilder for File

Source§

type Builder = Builder_

Source§

impl HasJar for File

Source§

const KIND: JarKind = zalsa_::JarKind::Struct

The [JarKind] for Self::Jar.
Source§

type Jar = JarImpl<File>

The [Jar] associated with this ingredient.
Source§

impl Hash for File

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for File

Source§

fn cmp(&self, other: &File) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for File

Source§

fn eq(&self, other: &File) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for File

Source§

fn partial_cmp(&self, other: &File) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl SalsaStructInDb for File

Source§

const LEAF_TYPE_IDS: &'static [ConstTypeId]

The type IDs of all concrete (leaf) salsa struct types that this type can contain. Read more
Source§

type MemoIngredientMap = MemoIngredientSingletonIndex

Source§

fn lookup_ingredient_index(aux: &Zalsa) -> IngredientIndices

Lookup or create ingredient indices. Read more
Source§

fn entries(zalsa: &Zalsa) -> impl Iterator<Item = DatabaseKeyIndex> + '_

Returns the IDs of any instances of this struct in the database.
Source§

fn cast(id: Id, type_id: TypeId) -> Option<Self>

Plumbing to support nested salsa supertypes. Read more
Source§

unsafe fn memo_table( zalsa: &Zalsa, id: Id, current_revision: Revision, ) -> MemoTableWithTypes<'_>

Return the memo table associated with id. Read more
Source§

impl StructuralPartialEq for File

Source§

impl Update for File

Source§

unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool

Returns Read more

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnsafeUnpin for File

§

impl UnwindSafe for File

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HashEqLike<&T> for T
where T: Hash + Eq,

Source§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

Source§

fn eq(&self, data: &&T) -> bool

Source§

impl<T> HashEqLike<Cow<'_, T>> for T
where T: Hash + Eq + Clone,

Source§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

Source§

fn eq(&self, data: &Cow<'_, T>) -> bool

Source§

impl<T> HashEqLike<T> for T
where T: Hash + Eq,

Source§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

Source§

fn eq(&self, data: &T) -> bool

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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