Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem:
    Debug
    + Send
    + Sync {
Show 15 methods // Required methods fn read_dir(&self, path: &Path) -> Result<Vec<FsEntry>>; fn create_dir_all(&self, path: &Path) -> Result<()>; fn create_file(&self, path: &Path) -> Result<()>; fn rename(&self, source: &Path, destination: &Path) -> Result<()>; fn copy_file(&self, source: &Path, destination: &Path) -> Result<()>; fn copy_dir(&self, source: &Path, destination: &Path) -> Result<()>; fn remove_file(&self, path: &Path) -> Result<()>; fn remove_dir_all(&self, path: &Path) -> Result<()>; fn exists(&self, path: &Path) -> bool; fn is_dir(&self, path: &Path) -> bool; fn disk_usage(&self, path: &Path) -> Option<DiskUsage>; fn dir_size(&self, path: &Path) -> (u64, bool); // Provided methods fn item_count(&self, _path: &Path) -> Option<usize> { ... } fn restore_deleted(&self, _path: &Path) -> Result<()> { ... } fn is_local(&self) -> bool { ... }
}
Expand description

Filesystem backend used by explorer widgets.

Implement this trait to browse an in-memory, remote, archive, or otherwise virtual filesystem while keeping the same state machine and renderer.

Required Methods§

Source

fn read_dir(&self, path: &Path) -> Result<Vec<FsEntry>>

List the entries of the directory at path.

Source

fn create_dir_all(&self, path: &Path) -> Result<()>

Create the directory at path and any missing parents.

Source

fn create_file(&self, path: &Path) -> Result<()>

Create an empty file at path.

Source

fn rename(&self, source: &Path, destination: &Path) -> Result<()>

Rename or move source to destination.

Source

fn copy_file(&self, source: &Path, destination: &Path) -> Result<()>

Copy the file source to destination.

Source

fn copy_dir(&self, source: &Path, destination: &Path) -> Result<()>

Copy the directory source and everything under it to destination.

Source

fn remove_file(&self, path: &Path) -> Result<()>

Remove the file at path.

Source

fn remove_dir_all(&self, path: &Path) -> Result<()>

Remove the directory at path and everything under it.

Source

fn exists(&self, path: &Path) -> bool

true when something exists at path.

Source

fn is_dir(&self, path: &Path) -> bool

true when path is a directory.

Source

fn disk_usage(&self, path: &Path) -> Option<DiskUsage>

Space on the volume holding path, or None when unknown.

Source

fn dir_size(&self, path: &Path) -> (u64, bool)

Total size in bytes of the files under path, and whether the walk stopped early (then the size is a lower bound).

Provided Methods§

Source

fn item_count(&self, _path: &Path) -> Option<usize>

Number of immediate children of the directory at path.

Called lazily for the rows that are actually visible, so read_dir can leave FsEntry::item_count unset and stay fast on huge directories. The default reports “unknown”.

Source

fn restore_deleted(&self, _path: &Path) -> Result<()>

Bring a previously trashed path back to where it was deleted from.

Only trash-backed filesystems on platforms with a restorable trash (Linux, Windows) support this; the default reports io::ErrorKind::Unsupported.

Source

fn is_local(&self) -> bool

true when paths are real OS paths (symlink targets, git status and similar OS-level lookups are meaningful). Virtual backends keep the default false.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FileSystem for StdFileSystem

Source§

impl FileSystem for TrashFileSystem

Available on crate feature trash only.