pub struct VirtualFs { /* private fields */ }Expand description
Copy-on-write filesystem over one immutable snapshot.
Implementations§
Source§impl VirtualFs
impl VirtualFs
Sourcepub fn new(base: BaseSnapshot) -> VirtualFs
pub fn new(base: BaseSnapshot) -> VirtualFs
Begin a new isolated virtual transaction.
Sourcepub fn base_node_count(&self) -> usize
pub fn base_node_count(&self) -> usize
Return the number of base manifest nodes, including the virtual root.
Sourcepub fn with_effect_origin<T>(
&mut self,
origin: EffectOrigin,
operation: impl FnOnce(&mut VirtualFs) -> T,
) -> T
pub fn with_effect_origin<T>( &mut self, origin: EffectOrigin, operation: impl FnOnce(&mut VirtualFs) -> T, ) -> T
Run an operation while attributing every emitted effect to origin.
Adapters use this narrow scope to preserve the typed source of observations without duplicating filesystem semantics. Nested scopes restore the previous origin when the operation returns.
Sourcepub fn base_snapshot_id(&self) -> SnapshotId
pub fn base_snapshot_id(&self) -> SnapshotId
Return the immutable base snapshot identity.
Sourcepub fn exists(&mut self, path: &VPath) -> bool
pub fn exists(&mut self, path: &VPath) -> bool
Test path existence and record the metadata dependency.
Sourcepub fn metadata(&mut self, path: &VPath) -> Result<NodeState, VfsError>
pub fn metadata(&mut self, path: &VPath) -> Result<NodeState, VfsError>
Read virtual metadata without following symbolic links.
§Errors
Returns VfsError::NotFound when path is absent.
Sourcepub fn read(&mut self, path: &VPath) -> Result<Vec<u8>, VfsError>
pub fn read(&mut self, path: &VPath) -> Result<Vec<u8>, VfsError>
Read regular-file bytes from virtual state.
§Errors
Returns an error for absent paths, non-files, stale lazy content, or blob-store verification failures.
Sourcepub fn read_link(&mut self, path: &VPath) -> Result<Vec<u8>, VfsError>
pub fn read_link(&mut self, path: &VPath) -> Result<Vec<u8>, VfsError>
Read an opaque symbolic-link target without following it.
§Errors
Returns an error for absent paths, non-links, stale lazy content, or blob errors.
Sourcepub fn read_dir(&mut self, path: &VPath) -> Result<Vec<VPath>, VfsError>
pub fn read_dir(&mut self, path: &VPath) -> Result<Vec<VPath>, VfsError>
List immediate child paths in canonical order.
§Errors
Returns an error when path is absent or not a directory.
Sourcepub fn write(&mut self, path: &VPath, bytes: &[u8]) -> Result<(), VfsError>
pub fn write(&mut self, path: &VPath, bytes: &[u8]) -> Result<(), VfsError>
Create or replace a regular file in the overlay.
§Errors
Returns an error when the parent is absent/non-directory, the target is a directory/link, or immutable blob storage fails.
Sourcepub fn append(&mut self, path: &VPath, suffix: &[u8]) -> Result<(), VfsError>
pub fn append(&mut self, path: &VPath, suffix: &[u8]) -> Result<(), VfsError>
Append bytes to a regular file using the same read/write semantics.
§Errors
Returns the same errors as Self::read or Self::write.
Sourcepub fn mkdir(&mut self, path: &VPath, mode: u32) -> Result<(), VfsError>
pub fn mkdir(&mut self, path: &VPath, mode: u32) -> Result<(), VfsError>
Create one empty directory.
§Errors
Returns an error when the path exists or its parent is unavailable.
Sourcepub fn unlink(&mut self, path: &VPath) -> Result<(), VfsError>
pub fn unlink(&mut self, path: &VPath) -> Result<(), VfsError>
Delete one regular file or opaque symbolic link.
§Errors
Returns an error when the path is absent or is a directory/root.
Sourcepub fn rmdir(&mut self, path: &VPath) -> Result<(), VfsError>
pub fn rmdir(&mut self, path: &VPath) -> Result<(), VfsError>
Delete one empty directory.
§Errors
Returns an error when the path is absent, non-directory, non-empty, or root.
Sourcepub fn remove_tree(&mut self, path: &VPath) -> Result<(), VfsError>
pub fn remove_tree(&mut self, path: &VPath) -> Result<(), VfsError>
Recursively delete a virtual subtree while expanding every affected write.
§Errors
Returns an error when the root path is absent or targets the virtual root.
Sourcepub fn rename(&mut self, from: &VPath, to: &VPath) -> Result<(), VfsError>
pub fn rename(&mut self, from: &VPath, to: &VPath) -> Result<(), VfsError>
Move a file, link, or directory subtree without touching the host.
Existing non-directory destinations are replaced. A directory may replace only an empty directory. Symlinks are moved as opaque nodes and never followed.
§Errors
Returns an error for root/overlapping moves, absent sources, invalid parents, or incompatible/non-empty destinations.
Sourcepub fn canonical_diff(&self) -> Result<CanonicalDiff, VfsError>
pub fn canonical_diff(&self) -> Result<CanonicalDiff, VfsError>
Produce the exact path-ordered diff between base and final virtual state.
Descendant closure is expanded for subtree tombstones, so a recursive delete is never represented as a misleading one-path change.
§Errors
Returns an error if changed lazy content cannot be captured and verified.
Sourcepub fn effects(&self) -> &[EffectEvent]
pub fn effects(&self) -> &[EffectEvent]
Return the observed effect ledger.
This excludes host-only evidence capture.
Sourcepub fn capture_before_content<'a>(
&self,
paths: impl IntoIterator<Item = &'a VPath>,
maximum: usize,
) -> Result<(), VfsError>
pub fn capture_before_content<'a>( &self, paths: impl IntoIterator<Item = &'a VPath>, maximum: usize, ) -> Result<(), VfsError>
Capture bounded base content before finalizing a reviewable transaction.
The trusted caller must authorize content reads for every supplied path.
Existing read/write observations and guest effects are not modified. Call
canonical_diff afterwards to bind any newly materialized before identities.
Paths exceeding the remaining byte budget retain their lazy stamp.
§Errors
Returns an error if base content changed during capture or cannot be read.
Sourcepub fn read_set(&self) -> &BTreeMap<VPath, ReadObservation>
pub fn read_set(&self) -> &BTreeMap<VPath, ReadObservation>
Return base dependencies observed by virtual execution.
Sourcepub fn write_set(&self) -> &BTreeMap<VPath, WritePrecondition>
pub fn write_set(&self) -> &BTreeMap<VPath, WritePrecondition>
Return base preconditions for every virtual write.
Sourcepub fn metrics(&self) -> VfsMetrics
pub fn metrics(&self) -> VfsMetrics
Return bounded transaction-local size metrics.
Sourcepub fn materialized_final_state(
&self,
) -> Result<BTreeMap<VPath, NodeState>, VfsError>
pub fn materialized_final_state( &self, ) -> Result<BTreeMap<VPath, NodeState>, VfsError>
Materialize final virtual state for verification/test harnesses.
This intentionally scans the full snapshot and is not used by transaction hot
paths; production decisions use Self::canonical_diff.
§Errors
Returns an error when visible lazy content cannot be verified.
Auto Trait Implementations§
impl !RefUnwindSafe for VirtualFs
impl !UnwindSafe for VirtualFs
impl Freeze for VirtualFs
impl Send for VirtualFs
impl Sync for VirtualFs
impl Unpin for VirtualFs
impl UnsafeUnpin for VirtualFs
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.