Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem {
    // Required methods
    fn read_dir(&self, dir: &Path) -> Result<Vec<FsEntry>>;
    fn canonicalize(&self, path: &Path) -> Result<PathBuf>;
    fn metadata(&self, path: &Path) -> Result<FsMetadata>;
    fn create_dir(&self, path: &Path) -> Result<()>;
    fn rename(&self, from: &Path, to: &Path) -> Result<()>;
    fn remove_file(&self, path: &Path) -> Result<()>;
    fn remove_dir(&self, path: &Path) -> Result<()>;
    fn remove_dir_all(&self, path: &Path) -> Result<()>;
    fn copy_file(&self, from: &Path, to: &Path) -> Result<u64>;
}
Expand description

File system abstraction (IGFD IFileSystem-like).

This is a first incremental step; the API will expand as Places/devices, directory creation, symlink support, and async enumeration are added.

Required Methods§

Source

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

List entries of a directory.

Source

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

Canonicalize a path (best-effort absolute normalization).

Source

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

Fetch minimal metadata for a path.

Source

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

Create a directory.

Source

fn rename(&self, from: &Path, to: &Path) -> Result<()>

Rename/move a path.

Source

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

Remove a file.

Source

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

Remove an empty directory.

Source

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

Remove a directory and all of its contents (recursive).

Source

fn copy_file(&self, from: &Path, to: &Path) -> Result<u64>

Copy a file.

Returns the number of bytes copied (mirrors std::fs::copy).

Implementors§