Skip to main content

VortexFs

Trait VortexFs 

Source
pub trait VortexFs {
    // Required methods
    fn read_file(&self, path: &str) -> VortexFsResult<Vec<u8>>;
    fn write_file(&mut self, path: &str, data: &[u8]) -> VortexFsResult<()>;
    fn append_file(&mut self, path: &str, data: &[u8]) -> VortexFsResult<()>;
    fn remove_file(&mut self, path: &str) -> VortexFsResult<()>;
    fn rename(&mut self, from: &str, to: &str) -> VortexFsResult<()>;
    fn create_dir_all(&mut self, path: &str) -> VortexFsResult<()>;
    fn remove_dir(&mut self, path: &str) -> VortexFsResult<()>;
    fn read_dir(&self, path: &str) -> VortexFsResult<Vec<String>>;
    fn metadata(&self, path: &str) -> VortexFsResult<FileMetadata>;
    fn exists(&self, path: &str) -> bool;
    fn fsync(&mut self, path: &str) -> VortexFsResult<()>;
}
Expand description

The filesystem abstraction boundary.

In production: implement with RealFs (pass-through to std::fs). In simulation: implement with SimFs (in-memory + fault injection).

Required Methods§

Source

fn read_file(&self, path: &str) -> VortexFsResult<Vec<u8>>

Read the entire contents of a file.

Source

fn write_file(&mut self, path: &str, data: &[u8]) -> VortexFsResult<()>

Write data to a file (creates or overwrites).

Source

fn append_file(&mut self, path: &str, data: &[u8]) -> VortexFsResult<()>

Append data to a file (creates if not exists).

Source

fn remove_file(&mut self, path: &str) -> VortexFsResult<()>

Remove a file.

Source

fn rename(&mut self, from: &str, to: &str) -> VortexFsResult<()>

Rename a file or directory.

Source

fn create_dir_all(&mut self, path: &str) -> VortexFsResult<()>

Create a directory (and all parent directories).

Source

fn remove_dir(&mut self, path: &str) -> VortexFsResult<()>

Remove an empty directory.

Source

fn read_dir(&self, path: &str) -> VortexFsResult<Vec<String>>

List the entries in a directory.

Source

fn metadata(&self, path: &str) -> VortexFsResult<FileMetadata>

Get metadata about a file or directory.

Source

fn exists(&self, path: &str) -> bool

Check if a path exists.

Source

fn fsync(&mut self, path: &str) -> VortexFsResult<()>

Flush / fsync a file (no-op for in-memory, real sync for production).

Implementors§