pub struct DiskTree { /* private fields */ }Expand description
Arena-allocated directory tree
Implementations§
Source§impl DiskTree
impl DiskTree
pub fn new(root_path: PathBuf) -> Self
Sourcepub fn add_node(
&mut self,
name: String,
kind: NodeKind,
path: PathBuf,
parent: NodeId,
) -> NodeId
pub fn add_node( &mut self, name: String, kind: NodeKind, path: PathBuf, parent: NodeId, ) -> NodeId
Add a new node and return its ID
Sourcepub fn get_mut(&mut self, id: NodeId) -> Option<&mut TreeNode>
pub fn get_mut(&mut self, id: NodeId) -> Option<&mut TreeNode>
Get a mutable reference to a node
Sourcepub fn rebuild_paths(&mut self)
pub fn rebuild_paths(&mut self)
Reconstruct paths and UI state for all nodes after deserialization Must be called after loading from cache since paths and is_expanded are not serialized
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Get count of live (non-tombstone) nodes
Sourcepub fn aggregate_sizes(&mut self)
pub fn aggregate_sizes(&mut self)
Propagate sizes from children to parents (bottom-up)
Sourcepub fn sort_by_size(&mut self)
pub fn sort_by_size(&mut self)
Sort all children by size descending
Sourcepub fn toggle_expanded(&mut self, id: NodeId)
pub fn toggle_expanded(&mut self, id: NodeId)
Toggle expanded state for a node
Sourcepub fn set_expanded(&mut self, id: NodeId, expanded: bool)
pub fn set_expanded(&mut self, id: NodeId, expanded: bool)
Set expanded state for a node
Sourcepub fn visible_nodes(&self, root: NodeId) -> Vec<NodeId>
pub fn visible_nodes(&self, root: NodeId) -> Vec<NodeId>
Get visible nodes in tree order (respecting expansion state)
Sourcepub fn path_to_node(&self, id: NodeId) -> Vec<NodeId>
pub fn path_to_node(&self, id: NodeId) -> Vec<NodeId>
Get the path from root to a node
Get breadcrumb string for a node
Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
Get total size of the tree
Sourcepub fn total_files(&self) -> u64
pub fn total_files(&self) -> u64
Get total file count
Sourcepub fn iter(&self) -> impl Iterator<Item = &TreeNode>
pub fn iter(&self) -> impl Iterator<Item = &TreeNode>
Iterator over all live nodes (skips tombstones)
Sourcepub fn find_by_path(&self, path: &Path) -> Option<NodeId>
pub fn find_by_path(&self, path: &Path) -> Option<NodeId>
Find a node by its path
Sourcepub fn remove_node(&mut self, id: NodeId) -> u64
pub fn remove_node(&mut self, id: NodeId) -> u64
Remove node and descendants, return bytes freed Does NOT perform filesystem operations - only updates tree structure
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DiskTree
impl<'de> Deserialize<'de> for DiskTree
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for DiskTree
impl RefUnwindSafe for DiskTree
impl Send for DiskTree
impl Sync for DiskTree
impl Unpin for DiskTree
impl UnwindSafe for DiskTree
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more