pub struct InMemoryFs { /* private fields */ }Expand description
In-memory Vfs backing. Useful for tests, dry-run previews, and
sandboxed environments where the apply layer must not touch the host
filesystem.
Cheap to clone — all clones share the same underlying storage, so a
caller can hand a clone to ApplyConfig::with_vfs
and then inspect the in-memory state after the apply returns via the
retained clone.
§Storage shape
- Files:
BTreeMap<PathBuf, Vec<u8>>, keyed by the absolute path the apply layer resolved them to. - Directories:
BTreeSet<PathBuf>of created directories. - Both maps live behind a single
Arc<Mutex<_>>. Contention is not a concern — the apply layer is single-threaded and holds the lock only for the duration of one syscall-shaped operation.
Implementations§
Source§impl InMemoryFs
impl InMemoryFs
Sourcepub fn snapshot_files(&self) -> BTreeMap<PathBuf, Vec<u8>>
pub fn snapshot_files(&self) -> BTreeMap<PathBuf, Vec<u8>>
Take a snapshot of every file’s contents.
The returned map is keyed by the absolute path the apply layer wrote to. Use this after a successful apply to inspect the resulting layout in tests.
§Panics
Panics if the internal mutex is poisoned.
Sourcepub fn snapshot_dirs(&self) -> BTreeSet<PathBuf>
pub fn snapshot_dirs(&self) -> BTreeSet<PathBuf>
Trait Implementations§
Source§impl Clone for InMemoryFs
impl Clone for InMemoryFs
Source§fn clone(&self) -> InMemoryFs
fn clone(&self) -> InMemoryFs
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemoryFs
impl Debug for InMemoryFs
Source§impl Default for InMemoryFs
impl Default for InMemoryFs
Source§fn default() -> InMemoryFs
fn default() -> InMemoryFs
Returns the “default value” for a type. Read more
Source§impl Vfs for InMemoryFs
impl Vfs for InMemoryFs
Source§fn open_write(&self, path: &Path) -> Result<Box<dyn VfsWrite>>
fn open_write(&self, path: &Path) -> Result<Box<dyn VfsWrite>>
Open
path for writing, creating it if it does not exist. Read moreSource§fn create_dir_all(&self, path: &Path) -> Result<()>
fn create_dir_all(&self, path: &Path) -> Result<()>
Create
path and every missing ancestor directory.Auto Trait Implementations§
impl Freeze for InMemoryFs
impl RefUnwindSafe for InMemoryFs
impl Send for InMemoryFs
impl Sync for InMemoryFs
impl Unpin for InMemoryFs
impl UnsafeUnpin for InMemoryFs
impl UnwindSafe for InMemoryFs
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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