pub struct FileTree { /* private fields */ }Expand description
In-memory file tree tracking directory structure during formatting.
Implementations§
Source§impl FileTree
impl FileTree
Sourcepub fn new(root_inode: InodeNumber, name: &str) -> Self
pub fn new(root_inode: InodeNumber, name: &str) -> Self
Create a new file tree with a single root node.
Sourcepub fn node(&self, idx: usize) -> &FileTreeNode
pub fn node(&self, idx: usize) -> &FileTreeNode
Borrow a node by index.
Sourcepub fn node_mut(&mut self, idx: usize) -> &mut FileTreeNode
pub fn node_mut(&mut self, idx: usize) -> &mut FileTreeNode
Mutably borrow a node by index.
Sourcepub fn lookup(&self, path: &Path) -> Option<usize>
pub fn lookup(&self, path: &Path) -> Option<usize>
Look up a node by path, walking the tree from the root.
The path is split into components. A leading “/” or empty first component
is skipped so that both “/foo/bar” and “foo/bar” resolve identically.
Returns None if any component is not found.
Sourcepub fn add_child(&mut self, parent: usize, node: FileTreeNode) -> usize
pub fn add_child(&mut self, parent: usize, node: FileTreeNode) -> usize
Add a child node under parent, returning the new node’s index.
Sourcepub fn remove_child(&mut self, parent: usize, name: &str)
pub fn remove_child(&mut self, parent: usize, name: &str)
Remove the first child with the given name from parent’s children list.
The node itself remains in the vector (indices are stable), but the parent no longer references it.
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