Trait grebedb::vfs::Vfs[][src]

pub trait Vfs {
Show methods fn lock(&mut self, path: &str) -> Result<(), Error>;
fn unlock(&mut self, path: &str) -> Result<(), Error>;
fn read(&self, path: &str) -> Result<Vec<u8>, Error>;
fn write(
        &mut self,
        path: &str,
        data: &[u8],
        sync_option: VfsSyncOption
    ) -> Result<(), Error>;
fn sync_file(
        &mut self,
        path: &str,
        sync_option: VfsSyncOption
    ) -> Result<(), Error>;
fn remove_file(&mut self, path: &str) -> Result<(), Error>;
fn read_dir(&self, path: &str) -> Result<Vec<String>, Error>;
fn create_dir(&mut self, path: &str) -> Result<(), Error>;
fn remove_dir(&mut self, path: &str) -> Result<(), Error>;
fn rename_file(
        &mut self,
        old_path: &str,
        new_path: &str
    ) -> Result<(), Error>;
fn is_dir(&self, path: &str) -> Result<bool, Error>;
fn exists(&self, path: &str) -> Result<bool, Error>; fn create_dir_all(&mut self, path: &str) -> Result<(), Error> { ... }
fn remove_empty_dir_all(&mut self, path: &str) -> Result<(), Error> { ... }
}

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]

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 sync_file(
    &mut self,
    path: &str,
    sync_option: VfsSyncOption
) -> Result<(), Error>
[src]

Flush buffered data of a file to persistent storage.

If supported by the file system, the method calls the appropriate sync operation on an existing, writable file without modifying the file contents. Flush operations complete 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.

Loading content...

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.

Loading content...

Implementors

impl Vfs for MemoryVfs[src]

impl Vfs for OsVfs[src]

impl Vfs for ReadOnlyVfs[src]

Loading content...