Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem {
    // Required methods
    fn read_file(&self, path: &Path) -> Result<Vec<u8>>;
    fn file_exists(&self, path: &Path) -> bool;

    // Provided method
    fn read_file_string(&self, path: &Path) -> Result<String> { ... }
}
Expand description

Environment trait for file system operations.

Abstraction over file system to enable testing without real files.

Required Methods§

Source

fn read_file(&self, path: &Path) -> Result<Vec<u8>>

Read file contents as bytes.

Source

fn file_exists(&self, path: &Path) -> bool

Check if file exists.

Provided Methods§

Source

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

Read file contents as UTF-8 string.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§