pub trait FileSystemProvider: Send + Sync {
// Required methods
fn read(&self, path: &Path) -> Result<Vec<u8>>;
fn write(&self, path: &Path, data: &[u8]) -> Result<()>;
fn append(&self, path: &Path, data: &[u8]) -> Result<()>;
fn exists(&self, path: &Path) -> bool;
fn remove(&self, path: &Path) -> Result<()>;
fn list_dir(&self, path: &Path) -> Result<Vec<PathEntry>>;
fn metadata(&self, path: &Path) -> Result<FileMetadata>;
fn create_dir_all(&self, path: &Path) -> Result<()>;
}Expand description
Trait for all filesystem operations used by the Shape stdlib.
Implementations include:
RealFileSystem— delegates tostd::fsPolicyEnforcedFs— wraps another provider with permission checksVirtualFilesystem(invirtual_fs.rs) — in-memory sandbox
Required Methods§
Sourcefn write(&self, path: &Path, data: &[u8]) -> Result<()>
fn write(&self, path: &Path, data: &[u8]) -> Result<()>
Write data to a file, creating or truncating as needed.
Sourcefn metadata(&self, path: &Path) -> Result<FileMetadata>
fn metadata(&self, path: &Path) -> Result<FileMetadata>
Query metadata for a path.
Sourcefn create_dir_all(&self, path: &Path) -> Result<()>
fn create_dir_all(&self, path: &Path) -> Result<()>
Recursively create directories.