Skip to main content

Vfs

Trait Vfs 

Source
pub trait Vfs: Send + Sync {
    // Required methods
    fn read_to_string(&self, path: &Path) -> Result<String>;
    fn read(&self, path: &Path) -> Result<Vec<u8>>;
    fn metadata(&self, path: &Path) -> Result<VfsMetadata>;
    fn exists(&self, path: &Path) -> bool;
    fn is_dir(&self, path: &Path) -> bool;
    fn is_file(&self, path: &Path) -> bool;
    fn read_dir(&self, path: &Path) -> Result<Vec<PathBuf>>;
    fn canonicalize(&self, path: &Path) -> Result<PathBuf>;

    // Provided method
    fn read_with_metadata(&self, path: &Path) -> Result<(String, VfsMetadata)> { ... }
}
Expand description

Filesystem abstraction for the graph-building pipeline.

All methods mirror their std::fs counterparts. Implementations must be safe to call from multiple threads concurrently.

Required Methods§

Source

fn read_to_string(&self, path: &Path) -> Result<String>

Source

fn read(&self, path: &Path) -> Result<Vec<u8>>

Source

fn metadata(&self, path: &Path) -> Result<VfsMetadata>

Source

fn exists(&self, path: &Path) -> bool

Source

fn is_dir(&self, path: &Path) -> bool

Source

fn is_file(&self, path: &Path) -> bool

Source

fn read_dir(&self, path: &Path) -> Result<Vec<PathBuf>>

Source

fn canonicalize(&self, path: &Path) -> Result<PathBuf>

Provided Methods§

Source

fn read_with_metadata(&self, path: &Path) -> Result<(String, VfsMetadata)>

Read file content and metadata in one operation. The default calls read_to_string + metadata separately; OsVfs overrides this to reuse the file descriptor (open + fstat + read = 3 syscalls, not 4).

Implementors§