pub struct VirtualFilesystem { /* private fields */ }Expand description
In-memory virtual filesystem implementing FileSystemProvider.
Thread-safe via internal RwLock. Designed for sandbox mode where no real
disk access is permitted.
Implementations§
Source§impl VirtualFilesystem
impl VirtualFilesystem
Sourcepub fn new(max_size: usize) -> Self
pub fn new(max_size: usize) -> Self
Create a new empty VFS with the given maximum total size in bytes.
max_size of 0 means unlimited.
Sourcepub fn seed_file(&self, path: impl Into<PathBuf>, content: Vec<u8>)
pub fn seed_file(&self, path: impl Into<PathBuf>, content: Vec<u8>)
Pre-seed a read-only file. Typically called by the host before
executing a sandboxed program (e.g., from [sandbox.seed_files]).
Sourcepub fn seed_dir(&self, path: impl Into<PathBuf>)
pub fn seed_dir(&self, path: impl Into<PathBuf>)
Seed a directory (empty). Automatically seeds all parent directories.
Sourcepub fn extract_written_files(&self) -> HashMap<PathBuf, Vec<u8>>
pub fn extract_written_files(&self) -> HashMap<PathBuf, Vec<u8>>
Extract all files written by the sandboxed program (excludes seed files).
Returns a map from path to file content.
Sourcepub fn total_bytes_written(&self) -> usize
pub fn total_bytes_written(&self) -> usize
Total bytes written by the sandboxed program (excludes seed files).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VirtualFilesystem
impl RefUnwindSafe for VirtualFilesystem
impl Send for VirtualFilesystem
impl Sync for VirtualFilesystem
impl Unpin for VirtualFilesystem
impl UnsafeUnpin for VirtualFilesystem
impl UnwindSafe for VirtualFilesystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more