pub struct MemFs { /* private fields */ }Expand description
In-memory filesystem for tests.
Backed by a BTreeMap (files) and BTreeSet (directories) for
deterministic, sorted output. Interior mutability via RefCell lets
callers hold &MemFs (shared reference) while still mutating state.
Fidelity contract: write returns an error when the parent directory
has not been registered via create_dir_all, faithfully modelling real OS
behaviour so tests cannot accidentally skip the parent-creation step.
This type is available in non-test builds so integration tests in later units can import it without feature flags.
Implementations§
Trait Implementations§
Source§impl Fs for MemFs
impl Fs for MemFs
Source§fn create_dir_all(&self, path: &Path) -> Result<(), SessionError>
fn create_dir_all(&self, path: &Path) -> Result<(), SessionError>
Create
path and all missing ancestors, like mkdir -p.Source§fn read(&self, path: &Path) -> Result<Vec<u8>, SessionError>
fn read(&self, path: &Path) -> Result<Vec<u8>, SessionError>
Read the entire contents of the file at
path.Source§fn append(&self, path: &Path, data: &[u8]) -> Result<(), SessionError>
fn append(&self, path: &Path, data: &[u8]) -> Result<(), SessionError>
Append
data to the file at path, creating it if absent. Like write,
it errors if the parent directory does not exist.Source§fn read_dir(&self, path: &Path) -> Result<Vec<PathBuf>, SessionError>
fn read_dir(&self, path: &Path) -> Result<Vec<PathBuf>, SessionError>
List immediate children (files and directories) of
path, sorted for
deterministic iteration.Auto Trait Implementations§
impl !Freeze for MemFs
impl !RefUnwindSafe for MemFs
impl !Sync for MemFs
impl Send for MemFs
impl Unpin for MemFs
impl UnsafeUnpin for MemFs
impl UnwindSafe for MemFs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more