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
pub fn print_tree(&self) -> String
pub fn __print_tree(&self, name: &str, prefix: &str, is_last: bool) -> String
Trait Implementations§
Source§impl Clone for FileTreeNode
impl Clone for FileTreeNode
Source§fn clone(&self) -> FileTreeNode
fn clone(&self) -> FileTreeNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FileTreeNode
impl RefUnwindSafe for FileTreeNode
impl Send for FileTreeNode
impl Sync for FileTreeNode
impl Unpin for FileTreeNode
impl UnwindSafe for FileTreeNode
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