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§
Sourcefn read_dir_diff_paths(
&self,
left: &Path,
right: &Path,
) -> Result<BTreeSet<PathBuf>>
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
.
Sourcefn read_file_info(&self, path: &Path) -> Result<FileInfo>
fn read_file_info(&self, path: &Path) -> Result<FileInfo>
Read the FileInfo
for the provided path
.
Sourcefn write_file(&mut self, path: &Path, contents: &str) -> Result<()>
fn write_file(&mut self, path: &Path, contents: &str) -> Result<()>
Write new file contents to path
.
Sourcefn copy_file(&mut self, old_path: &Path, new_path: &Path) -> Result<()>
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.)
Sourcefn remove_file(&mut self, path: &Path) -> Result<()>
fn remove_file(&mut self, path: &Path) -> Result<()>
Delete the file at path
.
Sourcefn create_dir_all(&mut self, path: &Path) -> Result<()>
fn create_dir_all(&mut self, path: &Path) -> Result<()>
Create the directory path
and any parent directories as necessary.