pub struct MemoryFs { /* private fields */ }Expand description
MemoryFs is a simple in-memory filesystem that can be used for testing purposes.
It implements the RemoteFs trait.
The MemoryFs is instantiated providing a orange_trees::Tree which contains the filesystem data.
When reading or writing files, the MemoryFs will use the orange_trees::Tree to store the data.
You can easily create the MemoryFs using the MemoryFs::new method, providing the tree.
Use the node! macro to create the tree or use the orange_trees crate to create it programmatically.
The tree contains nodes identified by a PathBuf and a value of type Inode.
Every path passed to the client must be absolute; the tree root is /.
Implementations§
Source§impl MemoryFs
impl MemoryFs
Sourcepub fn new(tree: FsTree) -> Self
pub fn new(tree: FsTree) -> Self
Create a client backed by tree.
uid/gid default to 0 for every file until
MemoryFs::with_get_uid or MemoryFs::with_get_gid is used to
override them.
§Examples
Sourcepub fn with_get_uid<F>(self, get_uid: F) -> Self
pub fn with_get_uid<F>(self, get_uid: F) -> Self
Override the closure used to fill the uid of newly created files.
§Examples
Sourcepub fn with_get_gid<F>(self, get_gid: F) -> Self
pub fn with_get_gid<F>(self, get_gid: F) -> Self
Override the closure used to fill the gid of newly created files.
§Examples
Trait Implementations§
Source§impl RemoteFs for MemoryFs
impl RemoteFs for MemoryFs
Source§fn connect(&mut self) -> RemoteResult<()>
fn connect(&mut self) -> RemoteResult<()>
Source§fn disconnect(&mut self) -> RemoteResult<()>
fn disconnect(&mut self) -> RemoteResult<()>
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Source§fn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
Source§fn list_dir(&self, path: &Path) -> RemoteResult<Vec<File>>
fn list_dir(&self, path: &Path) -> RemoteResult<Vec<File>>
Source§fn stat(&self, path: &Path) -> RemoteResult<File>
fn stat(&self, path: &Path) -> RemoteResult<File>
Source§fn exists(&self, path: &Path) -> RemoteResult<bool>
fn exists(&self, path: &Path) -> RemoteResult<bool>
Source§fn set_metadata(&self, path: &Path, metadata: &SetMetadata) -> RemoteResult<()>
fn set_metadata(&self, path: &Path, metadata: &SetMetadata) -> RemoteResult<()>
Source§fn create_dir(&self, path: &Path, mode: Option<UnixPex>) -> RemoteResult<()>
fn create_dir(&self, path: &Path, mode: Option<UnixPex>) -> RemoteResult<()>
Source§fn remove_file(&self, path: &Path) -> RemoteResult<()>
fn remove_file(&self, path: &Path) -> RemoteResult<()>
Source§fn remove_dir(&self, path: &Path) -> RemoteResult<()>
fn remove_dir(&self, path: &Path) -> RemoteResult<()>
Source§fn remove_dir_all(&self, path: &Path) -> RemoteResult<()>
fn remove_dir_all(&self, path: &Path) -> RemoteResult<()>
Source§fn rename(&self, src: &Path, dest: &Path) -> RemoteResult<()>
fn rename(&self, src: &Path, dest: &Path) -> RemoteResult<()>
Source§fn copy(&self, src: &Path, dest: &Path) -> RemoteResult<()>
fn copy(&self, src: &Path, dest: &Path) -> RemoteResult<()>
Source§fn symlink(&self, path: &Path, target: &Path) -> RemoteResult<()>
fn symlink(&self, path: &Path, target: &Path) -> RemoteResult<()>
path pointing to an absolute target.