pub trait VirtualFileSystem {
Show 47 methods
// Required methods
fn read_file(&mut self, path: &str) -> Result<Vec<u8>, VfsError>;
fn read_dir(&mut self, path: &str) -> Result<Vec<String>, VfsError>;
fn read_dir_with_types(
&mut self,
path: &str,
) -> Result<Vec<VirtualDirEntry>, VfsError>;
fn write_file(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
) -> Result<(), VfsError>;
fn create_dir(&mut self, path: &str) -> Result<(), VfsError>;
fn mkdir(&mut self, path: &str, recursive: bool) -> Result<(), VfsError>;
fn exists(&self, path: &str) -> bool;
fn stat(&mut self, path: &str) -> Result<VirtualStat, VfsError>;
fn remove_file(&mut self, path: &str) -> Result<(), VfsError>;
fn remove_dir(&mut self, path: &str) -> Result<(), VfsError>;
fn rename(&mut self, old_path: &str, new_path: &str) -> Result<(), VfsError>;
fn realpath(&self, path: &str) -> Result<String, VfsError>;
fn symlink(&mut self, target: &str, link_path: &str) -> Result<(), VfsError>;
fn read_link(&self, path: &str) -> Result<String, VfsError>;
fn lstat(&self, path: &str) -> Result<VirtualStat, VfsError>;
fn link(&mut self, old_path: &str, new_path: &str) -> Result<(), VfsError>;
fn chmod(&mut self, path: &str, mode: u32) -> Result<(), VfsError>;
fn chown(&mut self, path: &str, uid: u32, gid: u32) -> Result<(), VfsError>;
fn utimes(
&mut self,
path: &str,
atime_ms: u64,
mtime_ms: u64,
) -> Result<(), VfsError>;
fn truncate(&mut self, path: &str, length: u64) -> Result<(), VfsError>;
fn pread(
&mut self,
path: &str,
offset: u64,
length: usize,
) -> Result<Vec<u8>, VfsError>;
// Provided methods
fn read_text_file(&mut self, path: &str) -> Result<String, VfsError> { ... }
fn read_dir_limited(
&mut self,
path: &str,
max_entries: usize,
) -> Result<Vec<String>, VfsError> { ... }
fn write_file_with_mode(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
mode: Option<u32>,
) -> Result<(), VfsError> { ... }
fn create_file_exclusive(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
) -> Result<(), VfsError> { ... }
fn create_file_exclusive_with_mode(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
mode: Option<u32>,
) -> Result<(), VfsError> { ... }
fn append_file(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
) -> Result<u64, VfsError> { ... }
fn create_dir_with_mode(
&mut self,
path: &str,
mode: Option<u32>,
) -> Result<(), VfsError> { ... }
fn mknod(
&mut self,
path: &str,
mode: u32,
rdev: u64,
) -> Result<(), VfsError> { ... }
fn mkdir_with_mode(
&mut self,
path: &str,
recursive: bool,
mode: Option<u32>,
) -> Result<(), VfsError> { ... }
fn rename_at2(
&mut self,
old_path: &str,
new_path: &str,
flags: u32,
) -> Result<(), VfsError> { ... }
fn chown_spec(
&mut self,
path: &str,
uid: u32,
gid: u32,
follow_symlinks: bool,
) -> Result<(), VfsError> { ... }
fn lchown(&mut self, path: &str, uid: u32, gid: u32) -> Result<(), VfsError> { ... }
fn get_xattr(
&mut self,
path: &str,
name: &str,
follow_symlinks: bool,
) -> Result<Vec<u8>, VfsError> { ... }
fn list_xattrs(
&mut self,
path: &str,
follow_symlinks: bool,
) -> Result<Vec<String>, VfsError> { ... }
fn set_xattr(
&mut self,
path: &str,
name: &str,
value: Vec<u8>,
flags: u32,
follow_symlinks: bool,
) -> Result<(), VfsError> { ... }
fn remove_xattr(
&mut self,
path: &str,
name: &str,
follow_symlinks: bool,
) -> Result<(), VfsError> { ... }
fn utimes_spec(
&mut self,
path: &str,
atime: VirtualUtimeSpec,
mtime: VirtualUtimeSpec,
follow_symlinks: bool,
) -> Result<(), VfsError> { ... }
fn sync(&mut self, _path: &str) -> Result<(), VfsError> { ... }
fn allocate(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError> { ... }
fn insert_range(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError> { ... }
fn collapse_range(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError> { ... }
fn zero_range(
&mut self,
path: &str,
offset: u64,
length: u64,
keep_size: bool,
) -> Result<(), VfsError> { ... }
fn punch_hole(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError> { ... }
fn allocated_ranges(
&mut self,
path: &str,
) -> Result<Vec<(u64, u64)>, VfsError> { ... }
fn unwritten_ranges(
&mut self,
_path: &str,
) -> Result<Vec<(u64, u64)>, VfsError> { ... }
fn pwrite(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
offset: u64,
) -> Result<(), VfsError> { ... }
}Required Methods§
fn read_file(&mut self, path: &str) -> Result<Vec<u8>, VfsError>
fn read_dir(&mut self, path: &str) -> Result<Vec<String>, VfsError>
fn read_dir_with_types( &mut self, path: &str, ) -> Result<Vec<VirtualDirEntry>, VfsError>
Sourcefn write_file(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
) -> Result<(), VfsError>
fn write_file( &mut self, path: &str, content: impl Into<Vec<u8>>, ) -> Result<(), VfsError>
Writes caller-owned bytes into the filesystem.
This raw VFS primitive does not enforce VM resource policy. Kernel entry points must preflight file sizes and inode growth before calling it.
fn create_dir(&mut self, path: &str) -> Result<(), VfsError>
fn mkdir(&mut self, path: &str, recursive: bool) -> Result<(), VfsError>
fn exists(&self, path: &str) -> bool
fn stat(&mut self, path: &str) -> Result<VirtualStat, VfsError>
fn remove_file(&mut self, path: &str) -> Result<(), VfsError>
fn remove_dir(&mut self, path: &str) -> Result<(), VfsError>
fn rename(&mut self, old_path: &str, new_path: &str) -> Result<(), VfsError>
fn realpath(&self, path: &str) -> Result<String, VfsError>
fn symlink(&mut self, target: &str, link_path: &str) -> Result<(), VfsError>
fn read_link(&self, path: &str) -> Result<String, VfsError>
fn lstat(&self, path: &str) -> Result<VirtualStat, VfsError>
fn link(&mut self, old_path: &str, new_path: &str) -> Result<(), VfsError>
fn chmod(&mut self, path: &str, mode: u32) -> Result<(), VfsError>
fn chown(&mut self, path: &str, uid: u32, gid: u32) -> Result<(), VfsError>
fn utimes( &mut self, path: &str, atime_ms: u64, mtime_ms: u64, ) -> Result<(), VfsError>
Sourcefn truncate(&mut self, path: &str, length: u64) -> Result<(), VfsError>
fn truncate(&mut self, path: &str, length: u64) -> Result<(), VfsError>
Resizes a file. VM resource policy must be enforced by the caller.
fn pread( &mut self, path: &str, offset: u64, length: usize, ) -> Result<Vec<u8>, VfsError>
Provided Methods§
fn read_text_file(&mut self, path: &str) -> Result<String, VfsError>
fn read_dir_limited( &mut self, path: &str, max_entries: usize, ) -> Result<Vec<String>, VfsError>
fn write_file_with_mode( &mut self, path: &str, content: impl Into<Vec<u8>>, mode: Option<u32>, ) -> Result<(), VfsError>
fn create_file_exclusive( &mut self, path: &str, content: impl Into<Vec<u8>>, ) -> Result<(), VfsError>
fn create_file_exclusive_with_mode( &mut self, path: &str, content: impl Into<Vec<u8>>, mode: Option<u32>, ) -> Result<(), VfsError>
Sourcefn append_file(
&mut self,
path: &str,
content: impl Into<Vec<u8>>,
) -> Result<u64, VfsError>
fn append_file( &mut self, path: &str, content: impl Into<Vec<u8>>, ) -> Result<u64, VfsError>
Appends caller-owned bytes into the filesystem after checking that the in-memory file can grow without overflowing addressable memory.
fn create_dir_with_mode( &mut self, path: &str, mode: Option<u32>, ) -> Result<(), VfsError>
fn mknod(&mut self, path: &str, mode: u32, rdev: u64) -> Result<(), VfsError>
fn mkdir_with_mode( &mut self, path: &str, recursive: bool, mode: Option<u32>, ) -> Result<(), VfsError>
fn rename_at2( &mut self, old_path: &str, new_path: &str, flags: u32, ) -> Result<(), VfsError>
fn chown_spec( &mut self, path: &str, uid: u32, gid: u32, follow_symlinks: bool, ) -> Result<(), VfsError>
fn lchown(&mut self, path: &str, uid: u32, gid: u32) -> Result<(), VfsError>
fn get_xattr( &mut self, path: &str, name: &str, follow_symlinks: bool, ) -> Result<Vec<u8>, VfsError>
fn list_xattrs( &mut self, path: &str, follow_symlinks: bool, ) -> Result<Vec<String>, VfsError>
fn set_xattr( &mut self, path: &str, name: &str, value: Vec<u8>, flags: u32, follow_symlinks: bool, ) -> Result<(), VfsError>
fn remove_xattr( &mut self, path: &str, name: &str, follow_symlinks: bool, ) -> Result<(), VfsError>
fn utimes_spec( &mut self, path: &str, atime: VirtualUtimeSpec, mtime: VirtualUtimeSpec, follow_symlinks: bool, ) -> Result<(), VfsError>
fn sync(&mut self, _path: &str) -> Result<(), VfsError>
Sourcefn allocate(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError>
fn allocate( &mut self, path: &str, offset: u64, length: u64, ) -> Result<(), VfsError>
Allocates storage for a range without changing existing bytes. VM resource policy must be enforced by the caller.
fn insert_range( &mut self, path: &str, offset: u64, length: u64, ) -> Result<(), VfsError>
fn collapse_range( &mut self, path: &str, offset: u64, length: u64, ) -> Result<(), VfsError>
Sourcefn zero_range(
&mut self,
path: &str,
offset: u64,
length: u64,
keep_size: bool,
) -> Result<(), VfsError>
fn zero_range( &mut self, path: &str, offset: u64, length: u64, keep_size: bool, ) -> Result<(), VfsError>
Zeroes and allocates a byte range, optionally preserving the file size.
Sourcefn punch_hole(
&mut self,
path: &str,
offset: u64,
length: u64,
) -> Result<(), VfsError>
fn punch_hole( &mut self, path: &str, offset: u64, length: u64, ) -> Result<(), VfsError>
Deallocates a byte range while preserving the file size. Bytes in the intersecting range read back as zeroes.
Sourcefn allocated_ranges(&mut self, path: &str) -> Result<Vec<(u64, u64)>, VfsError>
fn allocated_ranges(&mut self, path: &str) -> Result<Vec<(u64, u64)>, VfsError>
Returns allocated byte ranges as half-open (start, end) intervals.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".