Trait DiskInterface

Source
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§

Source

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

Create a directory, returning false on failure.

Source

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

Create all the parent directories for path; like mkdir -p basename path.

Source

fn stat(&self, path: &Path) -> Result<TimeStamp, String>

stat() a file, returning the mtime, or 0 if missing and -1 on other errors.

Source

fn write_file(&self, path: &Path, contents: &[u8]) -> Result<(), ()>

Create a file, with the specified name and contents Returns true on success, false on failure

Source

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

Remove the file named @a path. It behaves like ‘rm -f path’ so no errors are reported if it does not exists. @returns 0 if the file has been removed, 1 if the file does not exist, and -1 if an error occurs.

Implementors§