Skip to main content

FileOps

Trait FileOps 

Source
pub trait FileOps: Send + Sync {
    // Required methods
    fn read(&self, path: &Path) -> Result<Vec<u8>>;
    fn write(&self, path: &Path, data: &[u8]) -> Result<()>;
    fn remove(&self, path: &Path) -> Result<()>;
    fn list(&self, dir: &Path) -> Vec<(String, SystemTime)>;
    fn is_file(&self, path: &Path) -> bool;
}
Expand description

The file operations autosave and recovery need, by path.

Required Methods§

Source

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

Source

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

Write data to path atomically, creating its folder.

Source

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

Remove a file; removing a missing file is not an error.

Source

fn list(&self, dir: &Path) -> Vec<(String, SystemTime)>

Files directly in dir: (file name, modified time), sorted by name.

Source

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

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§