pub struct FileTree { /* private fields */ }Expand description
Builder for a tree of files and directories under a chosen root.
§Example
use dev_fixtures::tree::FileTree;
let dir = tempfile::tempdir().unwrap();
FileTree::new(dir.path())
.file("README.md", "hello")
.dir("src")
.file("src/lib.rs", "pub fn x() {}")
.build()
.unwrap();
assert!(dir.path().join("src/lib.rs").exists());Implementations§
Source§impl FileTree
impl FileTree
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
Build a tree rooted at root. The directory MUST exist on
build; the builder does not create it.
Sourcepub fn file(
self,
relative_path: impl Into<PathBuf>,
contents: impl Into<String>,
) -> Self
pub fn file( self, relative_path: impl Into<PathBuf>, contents: impl Into<String>, ) -> Self
Stage a UTF-8 text file at relative_path.
Sourcepub fn bytes(
self,
relative_path: impl Into<PathBuf>,
contents: impl Into<Vec<u8>>,
) -> Self
pub fn bytes( self, relative_path: impl Into<PathBuf>, contents: impl Into<Vec<u8>>, ) -> Self
Stage a binary file at relative_path.
Sourcepub fn dir(self, relative_path: impl Into<PathBuf>) -> Self
pub fn dir(self, relative_path: impl Into<PathBuf>) -> Self
Stage an empty directory at relative_path.
Auto Trait Implementations§
impl Freeze for FileTree
impl RefUnwindSafe for FileTree
impl Send for FileTree
impl Sync for FileTree
impl Unpin for FileTree
impl UnsafeUnpin for FileTree
impl UnwindSafe for FileTree
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