pub trait File: Send + Sync {
// Required methods
fn as_local(&self) -> Option<&dyn LocalFile>;
fn mtime(&self) -> SystemTime;
fn path(&self) -> &Arc<Path>;
fn full_path(&self, cx: &AppContext) -> PathBuf;
fn file_name<'a>(&'a self, cx: &'a AppContext) -> &'a OsStr;
fn worktree_id(&self) -> usize;
fn is_deleted(&self) -> bool;
fn as_any(&self) -> &dyn Any;
fn to_proto(&self) -> File;
// Provided method
fn is_local(&self) -> bool { ... }
}
Required Methods§
fn as_local(&self) -> Option<&dyn LocalFile>
fn mtime(&self) -> SystemTime
sourcefn path(&self) -> &Arc<Path>
fn path(&self) -> &Arc<Path>
Returns the path of this file relative to the worktree’s root directory.
sourcefn full_path(&self, cx: &AppContext) -> PathBuf
fn full_path(&self, cx: &AppContext) -> PathBuf
Returns the path of this file relative to the worktree’s parent directory (this means it includes the name of the worktree’s root folder).
sourcefn file_name<'a>(&'a self, cx: &'a AppContext) -> &'a OsStr
fn file_name<'a>(&'a self, cx: &'a AppContext) -> &'a OsStr
Returns the last component of this handle’s absolute path. If this handle refers to the root of its worktree, then this method will return the name of the worktree itself.
sourcefn worktree_id(&self) -> usize
fn worktree_id(&self) -> usize
Returns the id of the worktree to which this file belongs.
This is needed for looking up project-specific settings.