pub trait DiskInterface: FileReader {
// Required methods
fn make_dir(&self, path: &Path) -> Result<(), Error>;
fn make_dirs(&self, path: &Path) -> Result<(), Error>;
fn stat(&self, path: &Path) -> Result<TimeStamp, String>;
fn write_file(&self, path: &Path, contents: &[u8]) -> Result<(), ()>;
fn remove_file(&self, path: &Path) -> Result<bool, Error>;
}
Expand description
Interface for accessing the disk.
Abstract so it can be mocked out for tests. The real implementation is RealDiskInterface.
Required Methods§
Sourcefn make_dir(&self, path: &Path) -> Result<(), Error>
fn make_dir(&self, path: &Path) -> Result<(), Error>
Create a directory, returning false on failure.
Sourcefn make_dirs(&self, path: &Path) -> Result<(), Error>
fn make_dirs(&self, path: &Path) -> Result<(), Error>
Create all the parent directories for path; like mkdir -p
basename path
.
Sourcefn stat(&self, path: &Path) -> Result<TimeStamp, String>
fn stat(&self, path: &Path) -> Result<TimeStamp, String>
stat() a file, returning the mtime, or 0 if missing and -1 on other errors.