Skip to main content

VirtualFileSystem

Trait VirtualFileSystem 

Source
pub trait VirtualFileSystem: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn open_file(&self, path: &str) -> Result<Arc<Mutex<dyn File>>, FileError>;
    fn stat_path(&self, path: &str) -> Result<FileMetadata, FileError>;
    fn readdir_path(&self, path: &str) -> Result<Vec<String>, FileError>;

    // Provided methods
    fn create_file(
        &self,
        _path: &str,
    ) -> Result<Arc<Mutex<dyn File>>, FileError> { ... }
    fn create_dir(&self, _path: &str) -> Result<(), FileError> { ... }
    fn remove_file(&self, _path: &str) -> Result<(), FileError> { ... }
}
Expand description

Filesystem interface used by the VFS mount table for pseudo filesystems.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable filesystem name such as procfs, sysfs, or devtmpfs.

Source

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

Open a file path relative to this virtual filesystem’s mount root.

Source

fn stat_path(&self, path: &str) -> Result<FileMetadata, FileError>

Return file metadata for a path relative to this mount.

Source

fn readdir_path(&self, path: &str) -> Result<Vec<String>, FileError>

List a virtual directory.

Provided Methods§

Source

fn create_file(&self, _path: &str) -> Result<Arc<Mutex<dyn File>>, FileError>

Virtual filesystems are read-mostly by default.

Source

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

Virtual filesystems are read-mostly by default.

Source

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

Virtual filesystems are read-mostly by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§