pub enum FileTreeNode {
File {
contents: Vec<u8>,
},
Directory {
files: HashMap<String, FileTreeNode>,
},
}Expand description
A node in the file tree structure
Variants§
File
A file with its contents
Directory
A directory containing other files and directories
Fields
files: HashMap<String, FileTreeNode>The files and subdirectories in this directory
Implementations§
Source§impl FileTreeNode
impl FileTreeNode
Sourcepub fn get_node<P: AsRef<Path>>(&self, path: P) -> Option<&FileTreeNode>
pub fn get_node<P: AsRef<Path>>(&self, path: P) -> Option<&FileTreeNode>
Get a file or directory node by path
Sourcepub fn file_exists<P: AsRef<Path>>(&self, path: P) -> bool
pub fn file_exists<P: AsRef<Path>>(&self, path: P) -> bool
Check if a file exists at the given path
Sourcepub fn dir_exists<P: AsRef<Path>>(&self, path: P) -> bool
pub fn dir_exists<P: AsRef<Path>>(&self, path: P) -> bool
Check if a directory exists at the given path
Sourcepub fn list_files<P: AsRef<Path>>(&self, dir_path: P) -> Vec<String>
pub fn list_files<P: AsRef<Path>>(&self, dir_path: P) -> Vec<String>
List all files in a directory (non-recursive)
Sourcepub fn list_subdirectories<P: AsRef<Path>>(&self, dir_path: P) -> Vec<String>
pub fn list_subdirectories<P: AsRef<Path>>(&self, dir_path: P) -> Vec<String>
List all subdirectories in a directory (non-recursive)
Sourcepub fn insert<P: AsRef<Path>>(
&mut self,
path: P,
node: FileTreeNode,
) -> Result<(), Box<dyn StdError + Send + Sync>>
pub fn insert<P: AsRef<Path>>( &mut self, path: P, node: FileTreeNode, ) -> Result<(), Box<dyn StdError + Send + Sync>>
Insert a file or directory at the given path
Sourcepub fn flatten(&self) -> Vec<(String, Vec<u8>)>
pub fn flatten(&self) -> Vec<(String, Vec<u8>)>
Flatten the tree into (path, contents) pairs — the inverse of building
a tree by insert-ing each path. Paths are "/"-joined and relative
(no leading slash), exactly the key shape the WASM Quill.fromTree
boundary consumes, so from_tree(flatten(t)) round-trips every file.
Output is sorted by path for deterministic ordering (the construction
side stores children in a HashMap, which has no inherent order).
Only files are emitted: an EMPTY directory yields no entry and so is not
reconstructed by a flatten → insert round trip. This is intentional —
quill bundles are file-addressed and nothing in load/render depends on
empty directories — but it means the round trip preserves file contents,
not exact directory structure.
pub fn print_tree(&self) -> String
Trait Implementations§
Source§impl Clone for FileTreeNode
impl Clone for FileTreeNode
Source§fn clone(&self) -> FileTreeNode
fn clone(&self) -> FileTreeNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more