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
impl File
pub fn ingredient(db: &dyn Database) -> &IngredientImpl<Self>
pub fn ingredient_mut( zalsa_mut: &mut Zalsa, ) -> (&mut IngredientImpl<Self>, &mut Runtime)
Source§impl File
impl File
pub fn new<Db_>(db: &Db_, path: FilePath) -> Self
pub fn builder(path: FilePath) -> <Self as HasBuilder>::Builder
Sourcepub fn permissions<'db, Db_>(self, db: &'db Db_) -> Option<u32>
pub fn permissions<'db, Db_>(self, db: &'db Db_) -> Option<u32>
The unix permissions of the file. Only supported on unix systems. Always None on Windows
or when the file has been deleted.
Sourcepub fn revision<'db, Db_>(self, db: &'db Db_) -> FileRevision
pub fn revision<'db, Db_>(self, db: &'db Db_) -> FileRevision
The path revision. A file or directory has changed if the revisions don’t compare equal.
Sourcepub fn status<'db, Db_>(self, db: &'db Db_) -> FileStatus
pub fn status<'db, Db_>(self, db: &'db Db_) -> FileStatus
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.
Sourcepub fn source_text_override<'db, Db_>(
self,
db: &'db Db_,
) -> &'db Option<SourceText>
pub fn source_text_override<'db, Db_>( self, db: &'db Db_, ) -> &'db Option<SourceText>
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.
pub fn set_path<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FilePath> + use<'db, Db_>
pub fn set_permissions<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = Option<u32>> + use<'db, Db_>
pub fn set_revision<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FileRevision> + use<'db, Db_>
pub fn set_status<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = FileStatus> + use<'db, Db_>
pub fn set_source_text_override<'db, Db_>( self, db: &'db mut Db_, ) -> impl Setter<FieldTy = Option<SourceText>> + use<'db, Db_>
Sourcepub fn default_debug_fmt(this: Self, f: &mut Formatter<'_>) -> Result
pub fn default_debug_fmt(this: Self, f: &mut Formatter<'_>) -> Result
Default debug formatting for this struct (may be useful if you define your own Debug impl)
Source§impl File
impl File
Sourcepub fn read_to_string(&self, db: &dyn Db) -> Result<String>
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.
Sourcepub fn read_to_notebook(&self, db: &dyn Db) -> Result<Notebook, NotebookError>
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.
Sourcepub fn sync_path(db: &mut dyn Db, path: &SystemPath)
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.
Sourcepub fn sync_path_only(db: &mut dyn Db, path: &SystemPath)
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.
Sourcepub fn sync_virtual_path(db: &mut dyn Db, path: &SystemVirtualPath)
pub fn sync_virtual_path(db: &mut dyn Db, path: &SystemVirtualPath)
Increments the revision for the virtual file at path.
Sourcepub fn sync(self, db: &mut dyn Db)
pub fn sync(self, db: &mut dyn Db)
Syncs the File’s state with the state of the file on the system.
Sourcepub fn is_stub(self, db: &dyn Db) -> bool
pub fn is_stub(self, db: &dyn Db) -> bool
Returns true if the file should be analyzed as a type stub.
Sourcepub fn is_package_stub(self, db: &dyn Db) -> bool
pub fn is_package_stub(self, db: &dyn Db) -> bool
Returns true if the file is an __init__.pyi
Sourcepub fn is_package(self, db: &dyn Db) -> bool
pub fn is_package(self, db: &dyn Db) -> bool
Returns true if the file is an __init__.pyi
pub fn source_type(self, db: &dyn Db) -> PySourceType
Trait Implementations§
Source§impl Configuration for File
impl Configuration for File
const LOCATION: Location
const DEBUG_NAME: &'static str = "File"
const FIELD_DEBUG_NAMES: &'static [&'static str]
Source§type Fields = (FilePath, Option<u32>, FileRevision, FileStatus, Option<SourceText>)
type Fields = (FilePath, Option<u32>, FileRevision, FileStatus, Option<SourceText>)
type Revisions = [Revision; 5]
type Durabilities = [Durability; 5]
Source§fn heap_size(value: &Self::Fields) -> Option<usize>
fn heap_size(value: &Self::Fields) -> Option<usize>
Source§fn serialize<S: Serializer>(
fields: &Self::Fields,
serializer: S,
) -> Result<S::Ok, S::Error>
fn serialize<S: Serializer>( fields: &Self::Fields, serializer: S, ) -> Result<S::Ok, S::Error>
serde. Read moreSource§fn deserialize<'de, D: Deserializer<'de>>(
deserializer: D,
) -> Result<Self::Fields, D::Error>
fn deserialize<'de, D: Deserializer<'de>>( deserializer: D, ) -> Result<Self::Fields, D::Error>
serde. Read moreimpl Copy for File
impl Eq for File
Source§impl GetSize for File
impl GetSize for File
Source§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_heap_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreSource§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreSource§impl Ord for File
impl Ord for File
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for File
impl PartialOrd for File
Source§impl SalsaStructInDb for File
impl SalsaStructInDb for File
Source§const LEAF_TYPE_IDS: &'static [ConstTypeId]
const LEAF_TYPE_IDS: &'static [ConstTypeId]
type MemoIngredientMap = MemoIngredientSingletonIndex
Source§fn lookup_ingredient_index(aux: &Zalsa) -> IngredientIndices
fn lookup_ingredient_index(aux: &Zalsa) -> IngredientIndices
Source§fn entries(zalsa: &Zalsa) -> impl Iterator<Item = DatabaseKeyIndex> + '_
fn entries(zalsa: &Zalsa) -> impl Iterator<Item = DatabaseKeyIndex> + '_
impl StructuralPartialEq for File
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> 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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> HashEqLike<&T> for T
impl<T> HashEqLike<&T> for T
Source§impl<T> HashEqLike<Cow<'_, T>> for T
impl<T> HashEqLike<Cow<'_, T>> for T
Source§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> 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