Trait grebedb::vfs::Vfs [−][src]
Represents a virtual file system.
File paths are characters within pattern [a-z0-9._]
in Unix style
where directory separators as slashes (/
). Paths are specified in
relative notation such as example/my_file.ext
.
Implementations are not expected to support directory traversal notations or handling redundant slashes. Implementations can return an error in those cases.
Required methods
fn lock(&mut self, path: &str) -> Result<(), Error>
[src]
Lock the file preventing other processes from accessing it.
If the file is already locked, an error is returned.
fn unlock(&mut self, path: &str) -> Result<(), Error>
[src]
Unlock the file.
If the file is not locked, an error is returned.
fn read(&self, path: &str) -> Result<Vec<u8>, Error>
[src]
Read the contents of a file to a vector.
fn write(
&mut self,
path: &str,
data: &[u8],
sync_option: VfsSyncOption
) -> Result<(), Error>
[src]
&mut self,
path: &str,
data: &[u8],
sync_option: VfsSyncOption
) -> Result<(), Error>
Write the contents to a file.
The file will be created if it does not exist and existing data is overwritten.
If sync_option
is a flushing operation, it will flush data from
buffers to persistent storage before returning.
fn remove_file(&mut self, path: &str) -> Result<(), Error>
[src]
Delete a file.
If the file does not exist, an error is returned.
fn read_dir(&self, path: &str) -> Result<Vec<String>, Error>
[src]
Return a vector of filenames in a directory.
fn create_dir(&mut self, path: &str) -> Result<(), Error>
[src]
Create a directory at the given path.
The parent directory must exist.
fn remove_dir(&mut self, path: &str) -> Result<(), Error>
[src]
Remove an empty directory.
If the path is not an empty directory, an error is returned.
fn rename_file(&mut self, old_path: &str, new_path: &str) -> Result<(), Error>
[src]
Rename a file.
If the destination file path already exists, the file is overwritten.
fn is_dir(&self, path: &str) -> Result<bool, Error>
[src]
Return whether the path is a directory.
Returns an error if the path does not exist.
fn exists(&self, path: &str) -> Result<bool, Error>
[src]
Return whether the path exists.
Provided methods
fn create_dir_all(&mut self, path: &str) -> Result<(), Error>
[src]
Create directories for all components of the path if they do not exist.
fn remove_empty_dir_all(&mut self, path: &str) -> Result<(), Error>
[src]
Remove empty directories in the path if they exist.
Implementors
impl Vfs for MemoryVfs
[src]
fn lock(&mut self, _path: &str) -> Result<(), Error>
[src]
fn unlock(&mut self, _path: &str) -> Result<(), Error>
[src]
fn read(&self, path: &str) -> Result<Vec<u8>, Error>
[src]
fn write(
&mut self,
path: &str,
data: &[u8],
_sync_option: VfsSyncOption
) -> Result<(), Error>
[src]
&mut self,
path: &str,
data: &[u8],
_sync_option: VfsSyncOption
) -> Result<(), Error>
fn remove_file(&mut self, path: &str) -> Result<(), Error>
[src]
fn read_dir(&self, path: &str) -> Result<Vec<String>, Error>
[src]
fn create_dir(&mut self, path: &str) -> Result<(), Error>
[src]
fn remove_dir(&mut self, path: &str) -> Result<(), Error>
[src]
fn rename_file(&mut self, old_path: &str, new_path: &str) -> Result<(), Error>
[src]
fn is_dir(&self, path: &str) -> Result<bool, Error>
[src]
fn exists(&self, path: &str) -> Result<bool, Error>
[src]
impl Vfs for OsVfs
[src]
fn lock(&mut self, path: &str) -> Result<(), Error>
[src]
fn unlock(&mut self, path: &str) -> Result<(), Error>
[src]
fn read(&self, path: &str) -> Result<Vec<u8>, Error>
[src]
fn write(
&mut self,
path: &str,
data: &[u8],
sync_option: VfsSyncOption
) -> Result<(), Error>
[src]
&mut self,
path: &str,
data: &[u8],
sync_option: VfsSyncOption
) -> Result<(), Error>
fn remove_file(&mut self, path: &str) -> Result<(), Error>
[src]
fn read_dir(&self, path: &str) -> Result<Vec<String>, Error>
[src]
fn create_dir(&mut self, path: &str) -> Result<(), Error>
[src]
fn remove_dir(&mut self, path: &str) -> Result<(), Error>
[src]
fn rename_file(&mut self, old_path: &str, new_path: &str) -> Result<(), Error>
[src]
fn is_dir(&self, path: &str) -> Result<bool, Error>
[src]
fn exists(&self, path: &str) -> Result<bool, Error>
[src]
impl Vfs for ReadOnlyVfs
[src]
fn lock(&mut self, path: &str) -> Result<(), Error>
[src]
fn unlock(&mut self, path: &str) -> Result<(), Error>
[src]
fn read(&self, path: &str) -> Result<Vec<u8>, Error>
[src]
fn write(
&mut self,
_path: &str,
_data: &[u8],
_sync_option: VfsSyncOption
) -> Result<(), Error>
[src]
&mut self,
_path: &str,
_data: &[u8],
_sync_option: VfsSyncOption
) -> Result<(), Error>