Skip to main content

Fs

Trait Fs 

Source
pub trait Fs: Send + Sync {
    // Required methods
    fn write_new(&self, path: &Path, data: &[u8]) -> Result<()>;
    fn sync_file(&self, path: &Path) -> Result<()>;
    fn rename(&self, from: &Path, to: &Path) -> Result<()>;
    fn rename_new(&self, from: &Path, to: &Path) -> Result<()>;
    fn sync_dir(&self, dir: &Path) -> Result<()>;
    fn read(&self, path: &Path) -> Result<Vec<u8>>;
    fn remove(&self, path: &Path) -> Result<()>;
    fn list(&self, dir: &Path) -> Result<Vec<OsString>>;
    fn create_dir_all(&self, dir: &Path) -> Result<()>;
    fn remove_dir_all(&self, dir: &Path) -> Result<()>;
}
Expand description

The filesystem calls Store makes.

Required Methods§

Source

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

Creates a file that must not exist yet and writes data to it, without syncing.

§Errors

AlreadyExists if the path is taken, NotFound if its directory does not exist, or any other I/O error.

Source

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

Makes a file’s data durable.

§Errors

NotFound if there is no such file, or any other I/O error.

Source

fn rename(&self, from: &Path, to: &Path) -> Result<()>

Renames a file, replacing any file at to.

§Errors

The I/O error that stopped the rename.

Source

fn rename_new(&self, from: &Path, to: &Path) -> Result<()>

Renames a file only if nothing has the name to, in one step: of two callers renaming onto one name, one is refused.

§Errors

AlreadyExists if to is taken, or the I/O error that stopped the rename.

Source

fn sync_dir(&self, dir: &Path) -> Result<()>

Makes a directory’s entries durable: files created, renamed or removed in it.

§Errors

NotFound if there is no such directory, or any other I/O error.

Source

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

Reads a whole file.

§Errors

NotFound if there is no such file, or any other I/O error.

Source

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

Removes a file.

§Errors

NotFound if there is no such file, an error if the path is a directory, or any other I/O error.

Source

fn list(&self, dir: &Path) -> Result<Vec<OsString>>

The names in a directory, sorted.

§Errors

NotFound if there is no such directory, or any other I/O error.

Source

fn create_dir_all(&self, dir: &Path) -> Result<()>

Creates a directory and its parents, without syncing. A new directory survives a crash once the directory holding it is synced.

§Errors

An error if a file stands in the path, or any other I/O error.

Source

fn remove_dir_all(&self, dir: &Path) -> Result<()>

Removes a directory and everything in it, without syncing. The removal survives a crash once the directory that held it is synced.

§Errors

NotFound if there is no such directory, an error if the path is a file, or any other I/O error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Fs for OsFs