pub trait FileSystem: Send + Sync {
// Required methods
fn read_to_string(&self, path: &Path) -> Result<String>;
fn write(&self, path: &Path, contents: &str) -> Result<()>;
fn glob(&self, base: &Path, pattern: &str) -> Result<Vec<PathBuf>>;
fn exists(&self, path: &Path) -> bool;
fn create_dir_all(&self, path: &Path) -> Result<()>;
}Expand description
Abstraction over filesystem operations for testability.
Required Methods§
Sourcefn read_to_string(&self, path: &Path) -> Result<String>
fn read_to_string(&self, path: &Path) -> Result<String>
Reads the contents of a file as a UTF-8 string.
Sourcefn write(&self, path: &Path, contents: &str) -> Result<()>
fn write(&self, path: &Path, contents: &str) -> Result<()>
Writes string contents to a file, creating parent directories as needed.
Sourcefn glob(&self, base: &Path, pattern: &str) -> Result<Vec<PathBuf>>
fn glob(&self, base: &Path, pattern: &str) -> Result<Vec<PathBuf>>
Lists all files matching a glob pattern in a directory.
Sourcefn create_dir_all(&self, path: &Path) -> Result<()>
fn create_dir_all(&self, path: &Path) -> Result<()>
Creates a directory and all parent directories.