Trait virtual_filesystem::FileSystem

source ·
pub trait FileSystem {
    // Required methods
    fn create_dir(&self, path: &str) -> Result<()>;
    fn metadata(&self, path: &str) -> Result<Metadata>;
    fn open_file_options(
        &self,
        path: &str,
        options: &OpenOptions
    ) -> Result<Box<dyn File>>;
    fn read_dir(
        &self,
        path: &str
    ) -> Result<Box<dyn Iterator<Item = Result<DirEntry>>>>;
    fn remove_dir(&self, path: &str) -> Result<()>;
    fn remove_file(&self, path: &str) -> Result<()>;

    // Provided methods
    fn create_dir_all(&self, path: &str) -> Result<()> { ... }
    fn create_file(&self, path: &str) -> Result<Box<dyn File>> { ... }
    fn exists(&self, path: &str) -> Result<bool> { ... }
    fn open_file(&self, path: &str) -> Result<Box<dyn File>> { ... }
}
Expand description

A file system with a directory tree.

Required Methods§

source

fn create_dir(&self, path: &str) -> Result<()>

Creates a directory at path.

source

fn metadata(&self, path: &str) -> Result<Metadata>

Returns the metadata for the file/folder at `path.

source

fn open_file_options( &self, path: &str, options: &OpenOptions ) -> Result<Box<dyn File>>

Opens a file at path with options options.

source

fn read_dir( &self, path: &str ) -> Result<Box<dyn Iterator<Item = Result<DirEntry>>>>

Lists the files and folders contained in the directory denoted by path.

source

fn remove_dir(&self, path: &str) -> Result<()>

Removes the directory at path.

source

fn remove_file(&self, path: &str) -> Result<()>

Removes a file at path.

Provided Methods§

source

fn create_dir_all(&self, path: &str) -> Result<()>

Creates a directory path and all of its parents.

source

fn create_file(&self, path: &str) -> Result<Box<dyn File>>

Creates a file at path in write mode. The file will be opened in truncate mode, so all contents will be overwritten. If this is not desirable, use open_file directly.

source

fn exists(&self, path: &str) -> Result<bool>

Returns Ok(true) or Ok(false) if a file or folder at path does or does not exist, and Err(_) if the presence cannot be verified.

source

fn open_file(&self, path: &str) -> Result<Box<dyn File>>

Opens a file at path for reading.

Implementors§

source§

impl FileSystem for MemoryFS

source§

impl FileSystem for MountableFS

source§

impl FileSystem for RocFS

source§

impl FileSystem for MockFileSystem

A file system with a directory tree.

source§

impl FileSystem for TarFS

source§

impl<R: Read + Seek> FileSystem for ZipFS<R>

source§

impl<R: PathResolver> FileSystem for PhysicalFSImpl<R>