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§
Sourcefn read_dir(&self, path: &Path) -> Result<Vec<FsEntry>>
fn read_dir(&self, path: &Path) -> Result<Vec<FsEntry>>
List the entries of the directory at path.
Sourcefn create_dir_all(&self, path: &Path) -> Result<()>
fn create_dir_all(&self, path: &Path) -> Result<()>
Create the directory at path and any missing parents.
Sourcefn create_file(&self, path: &Path) -> Result<()>
fn create_file(&self, path: &Path) -> Result<()>
Create an empty file at path.
Sourcefn rename(&self, source: &Path, destination: &Path) -> Result<()>
fn rename(&self, source: &Path, destination: &Path) -> Result<()>
Rename or move source to destination.
Sourcefn copy_file(&self, source: &Path, destination: &Path) -> Result<()>
fn copy_file(&self, source: &Path, destination: &Path) -> Result<()>
Copy the file source to destination.
Sourcefn copy_dir(&self, source: &Path, destination: &Path) -> Result<()>
fn copy_dir(&self, source: &Path, destination: &Path) -> Result<()>
Copy the directory source and everything under it to destination.
Sourcefn remove_file(&self, path: &Path) -> Result<()>
fn remove_file(&self, path: &Path) -> Result<()>
Remove the file at path.
Sourcefn remove_dir_all(&self, path: &Path) -> Result<()>
fn remove_dir_all(&self, path: &Path) -> Result<()>
Remove the directory at path and everything under it.
Sourcefn disk_usage(&self, path: &Path) -> Option<DiskUsage>
fn disk_usage(&self, path: &Path) -> Option<DiskUsage>
Space on the volume holding path, or None when unknown.
Provided Methods§
Sourcefn item_count(&self, _path: &Path) -> Option<usize>
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”.
Sourcefn restore_deleted(&self, _path: &Path) -> Result<()>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl FileSystem for StdFileSystem
impl FileSystem for TrashFileSystem
trash only.