pub struct OverlayFs { /* private fields */ }Expand description
A copy-on-write filesystem: reads from a real directory, writes to memory.
The lower layer (a real directory on disk) is treated as read-only.
All mutations go to the upper InMemoryFs layer. Deletions are tracked
via a whiteout set so deleted lower-layer entries appear as removed.
§Example
ⓘ
use rust_bash::{RustBashBuilder, OverlayFs};
use std::sync::Arc;
let overlay = OverlayFs::new("./my_project").unwrap();
let mut shell = RustBashBuilder::new()
.fs(Arc::new(overlay))
.cwd("/")
.build()
.unwrap();
let result = shell.exec("cat /src/main.rs").unwrap(); // reads from disk
shell.exec("echo new > /src/main.rs").unwrap(); // writes to memory onlyImplementations§
Trait Implementations§
Source§impl VirtualFs for OverlayFs
impl VirtualFs for OverlayFs
fn read_file(&self, path: &Path) -> Result<Vec<u8>, VfsError>
fn write_file(&self, path: &Path, content: &[u8]) -> Result<(), VfsError>
fn append_file(&self, path: &Path, content: &[u8]) -> Result<(), VfsError>
fn remove_file(&self, path: &Path) -> Result<(), VfsError>
fn mkdir(&self, path: &Path) -> Result<(), VfsError>
fn mkdir_p(&self, path: &Path) -> Result<(), VfsError>
fn readdir(&self, path: &Path) -> Result<Vec<DirEntry>, VfsError>
fn remove_dir(&self, path: &Path) -> Result<(), VfsError>
fn remove_dir_all(&self, path: &Path) -> Result<(), VfsError>
fn exists(&self, path: &Path) -> bool
fn stat(&self, path: &Path) -> Result<Metadata, VfsError>
fn lstat(&self, path: &Path) -> Result<Metadata, VfsError>
fn chmod(&self, path: &Path, mode: u32) -> Result<(), VfsError>
fn utimes(&self, path: &Path, mtime: SystemTime) -> Result<(), VfsError>
fn symlink(&self, target: &Path, link: &Path) -> Result<(), VfsError>
fn hardlink(&self, src: &Path, dst: &Path) -> Result<(), VfsError>
fn readlink(&self, path: &Path) -> Result<PathBuf, VfsError>
fn canonicalize(&self, path: &Path) -> Result<PathBuf, VfsError>
fn copy(&self, src: &Path, dst: &Path) -> Result<(), VfsError>
fn rename(&self, src: &Path, dst: &Path) -> Result<(), VfsError>
fn glob(&self, pattern: &str, cwd: &Path) -> Result<Vec<PathBuf>, VfsError>
Auto Trait Implementations§
impl Freeze for OverlayFs
impl !RefUnwindSafe for OverlayFs
impl Send for OverlayFs
impl Sync for OverlayFs
impl Unpin for OverlayFs
impl UnsafeUnpin for OverlayFs
impl !UnwindSafe for OverlayFs
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