Trait Filesystem

Source
pub trait Filesystem {
    // Required methods
    fn read_dir_diff_paths(
        &self,
        left: &Path,
        right: &Path,
    ) -> Result<BTreeSet<PathBuf>>;
    fn read_file_info(&self, path: &Path) -> Result<FileInfo>;
    fn write_file(&mut self, path: &Path, contents: &str) -> Result<()>;
    fn copy_file(&mut self, old_path: &Path, new_path: &Path) -> Result<()>;
    fn remove_file(&mut self, path: &Path) -> Result<()>;
    fn create_dir_all(&mut self, path: &Path) -> Result<()>;
}
Expand description

Abstraction over the filesystem.

Required Methods§

Source

fn read_dir_diff_paths( &self, left: &Path, right: &Path, ) -> Result<BTreeSet<PathBuf>>

Find the set of files that appear in either left or right.

Source

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

Read the FileInfo for the provided path.

Source

fn write_file(&mut self, path: &Path, contents: &str) -> Result<()>

Write new file contents to path.

Source

fn copy_file(&mut self, old_path: &Path, new_path: &Path) -> Result<()>

Copy the file at old_path to new_path. (This can be more efficient than reading and writing the entire contents, particularly for large binary files.)

Source

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

Delete the file at path.

Source

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

Create the directory path and any parent directories as necessary.

Implementors§