pub struct TreeBuilder { /* private fields */ }Expand description
An in-memory, programmatic source: add entries, then hand it to the model.
Order of addition does not affect the result — the model sorts by path so the inode numbering is deterministic — but a directory’s contents are only valid if the directory itself is also added.
Implementations§
Source§impl TreeBuilder
impl TreeBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
A builder with no entries. The root directory always exists implicitly and is not added here.
Sourcepub fn directory(self, path: impl Into<Vec<u8>>, meta: Metadata) -> Self
pub fn directory(self, path: impl Into<Vec<u8>>, meta: Metadata) -> Self
Add a directory at path.
Sourcepub fn root(self, meta: Metadata) -> Self
pub fn root(self, meta: Metadata) -> Self
Set the root directory’s own metadata, overriding the 0755 root-owned default.
The root already exists, so this describes it rather than adding an entry; any
xattr that follows attaches to the root. Naming it once is
enough — a second root entry is a duplicate the model rejects.
Sourcepub fn file(
self,
path: impl Into<Vec<u8>>,
contents: impl Into<FileContent>,
meta: Metadata,
) -> Self
pub fn file( self, path: impl Into<Vec<u8>>, contents: impl Into<FileContent>, meta: Metadata, ) -> Self
Add a regular file at path with contents.
contents is anything that converts into a FileContent: an owned Vec<u8> or
String, a borrowed &[u8], &[u8; N], or &str — each copied into the entry —
or a FileRange, which names bytes on the host and reads them when the file is
placed rather than now.
Sourcepub fn symlink(
self,
path: impl Into<Vec<u8>>,
target: impl Into<Vec<u8>>,
meta: Metadata,
) -> Self
pub fn symlink( self, path: impl Into<Vec<u8>>, target: impl Into<Vec<u8>>, meta: Metadata, ) -> Self
Add a symbolic link at path pointing at target.
Sourcepub fn hardlink(
self,
path: impl Into<Vec<u8>>,
target: impl Into<Vec<u8>>,
meta: Metadata,
) -> Self
pub fn hardlink( self, path: impl Into<Vec<u8>>, target: impl Into<Vec<u8>>, meta: Metadata, ) -> Self
Add a hard link at path to the entry already declared at target, which may
be of any kind but a directory, and may itself be a hard link.
The link shares the target’s inode, so the two names are one file: the
metadata, extended attributes, and contents are the inode’s, and the meta
given here is not applied.
Sourcepub fn char_device(
self,
path: impl Into<Vec<u8>>,
major: u32,
minor: u32,
meta: Metadata,
) -> Self
pub fn char_device( self, path: impl Into<Vec<u8>>, major: u32, minor: u32, meta: Metadata, ) -> Self
Add a character-special device node at path.
Sourcepub fn block_device(
self,
path: impl Into<Vec<u8>>,
major: u32,
minor: u32,
meta: Metadata,
) -> Self
pub fn block_device( self, path: impl Into<Vec<u8>>, major: u32, minor: u32, meta: Metadata, ) -> Self
Add a block-special device node at path.
Sourcepub fn fifo(self, path: impl Into<Vec<u8>>, meta: Metadata) -> Self
pub fn fifo(self, path: impl Into<Vec<u8>>, meta: Metadata) -> Self
Add a named pipe (FIFO) at path.
Trait Implementations§
Source§impl Clone for TreeBuilder
impl Clone for TreeBuilder
Source§fn clone(&self) -> TreeBuilder
fn clone(&self) -> TreeBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more