Crate rsfs [] [src]

A generic filesystem with implementations for normal (disk), in memory, and test work sets.

The std::fs module provides functions to manipulate the filesytem and these functions are fine. However, if you have code that uses std::fs, it is difficult to ensure that your code handles errors properly because generally, you are not testing on an already broken machine. You could attempt to set up FUSE, which, although doable, is quite involved.

This crate provides a generic filesystem with various implementations, one of which is an in-memory filesystem that can have defined error injection. The intent of this crate is for you to use the generic rsfs::FS everywhere where you use std::fs in your code. Your main can use rsfs::rs to get default std::fs behavior while your tests can use rsfs::testfs to get an in-memory filesystem where you are able to define how errors propagate.

Not all filesystem operations are implemented yet. If something is missing, please feel free to implement it and open a PR to add it. Additionally, the current filesystem implementations are all based around Unix systems. Window's users can help by opening PRs to add in Windows specific behavior. If that ever occurs, the API will need to change to separate Unix specific functionality.

The documentation of the traits in this module should closely resemble or be verbatim copies of the std::fs documentation for the respective structs.

Modules

errors

Common filesystem errors.

mem

An in memory filesystem.

path_parts

Convenience functions and types for working with std::path::Path.

rs

A zero cost wrapper around std::fs that satisfies rsfs::FS.

testfs

An in memory filesystem that allows error injection.

Traits

DirBuilder

A builder used to create directories.

DirEntry

Entries returned by the iterator returned from read_dir.

FS

The filesystem underpinning all operations. All filesystem operations in code should use the same, single filesystem that is created at initialization.

File

A reference to an open file on the filesystem.

Metadata

Metadata information about a file.

OpenOptions

Options and flags which can be used to configure how a file is opened.