pub trait FileSystem:
Debug
+ Sync
+ Send
+ 'static {
Show 15 methods
// Required methods
fn read_dir(
&self,
path: &str,
) -> VfsResult<Box<dyn Iterator<Item = String> + Send>>;
fn create_dir(&self, path: &str) -> VfsResult<()>;
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead + Send>>;
fn create_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>;
fn append_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>;
fn metadata(&self, path: &str) -> VfsResult<VfsMetadata>;
fn exists(&self, path: &str) -> VfsResult<bool>;
fn remove_file(&self, path: &str) -> VfsResult<()>;
fn remove_dir(&self, path: &str) -> VfsResult<()>;
// Provided methods
fn set_creation_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()> { ... }
fn set_modification_time(
&self,
_path: &str,
_time: SystemTime,
) -> VfsResult<()> { ... }
fn set_access_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()> { ... }
fn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()> { ... }
fn move_file(&self, _src: &str, _dest: &str) -> VfsResult<()> { ... }
fn move_dir(&self, _src: &str, _dest: &str) -> VfsResult<()> { ... }
}
Expand description
File system implementations must implement this trait All path parameters are absolute, starting with ‘/’, except for the root directory which is simply the empty string (i.e. “”) The character ‘/’ is used to delimit directories on all platforms. Path components may be any UTF-8 string, except “/”, “.” and “..”
Please use the test_macros [test_macros::test_vfs!] and [test_macros::test_vfs_readonly!]
Required Methods§
Sourcefn read_dir(
&self,
path: &str,
) -> VfsResult<Box<dyn Iterator<Item = String> + Send>>
fn read_dir( &self, path: &str, ) -> VfsResult<Box<dyn Iterator<Item = String> + Send>>
Iterates over all direct children of this directory path NOTE: the returned String items denote the local bare filenames, i.e. they should not contain “/” anywhere
Sourcefn create_dir(&self, path: &str) -> VfsResult<()>
fn create_dir(&self, path: &str) -> VfsResult<()>
Creates the directory at this path
Note that the parent directory must already exist.
Sourcefn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead + Send>>
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead + Send>>
Opens the file at this path for reading
Sourcefn create_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>
fn create_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>
Creates a file at this path for writing
Sourcefn append_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>
fn append_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndWrite + Send>>
Opens the file at this path for appending
Sourcefn metadata(&self, path: &str) -> VfsResult<VfsMetadata>
fn metadata(&self, path: &str) -> VfsResult<VfsMetadata>
Returns the file metadata for the file at this path
Sourcefn exists(&self, path: &str) -> VfsResult<bool>
fn exists(&self, path: &str) -> VfsResult<bool>
Returns true if a file or directory at path exists, false otherwise
Sourcefn remove_file(&self, path: &str) -> VfsResult<()>
fn remove_file(&self, path: &str) -> VfsResult<()>
Removes the file at this path
Sourcefn remove_dir(&self, path: &str) -> VfsResult<()>
fn remove_dir(&self, path: &str) -> VfsResult<()>
Removes the directory at this path
Provided Methods§
Sourcefn set_creation_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
fn set_creation_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
Sets the files creation timestamp, if the implementation supports it
Sourcefn set_modification_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
fn set_modification_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
Sets the files modification timestamp, if the implementation supports it
Sourcefn set_access_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
fn set_access_time(&self, _path: &str, _time: SystemTime) -> VfsResult<()>
Sets the files access timestamp, if the implementation supports it
Sourcefn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()>
fn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()>
Copies the src path to the destination path within the same filesystem (optional)