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§
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 Methods§
Sourcefn read_with_metadata(&self, path: &Path) -> Result<(String, VfsMetadata)>
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).