Skip to main content

DiskTree

Struct DiskTree 

Source
pub struct DiskTree { /* private fields */ }
Expand description

Arena-allocated directory tree

Implementations§

Source§

impl DiskTree

Source

pub fn new(root_path: PathBuf) -> Self

Source

pub fn add_node( &mut self, name: String, kind: NodeKind, path: PathBuf, parent: NodeId, ) -> NodeId

Add a new node and return its ID

Source

pub fn get(&self, id: NodeId) -> Option<&TreeNode>

Get a reference to a node

Source

pub fn get_mut(&mut self, id: NodeId) -> Option<&mut TreeNode>

Get a mutable reference to a node

Source

pub fn root(&self) -> &TreeNode

Get the root node

Source

pub fn root_path(&self) -> &Path

Get the root path

Source

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

Source

pub fn len(&self) -> usize

Get total number of nodes (including tombstones)

Source

pub fn live_count(&self) -> usize

Get count of live (non-tombstone) nodes

Source

pub fn is_empty(&self) -> bool

Check if tree is empty (only has root)

Source

pub fn set_size(&mut self, id: NodeId, size: u64)

Set size for a node

Source

pub fn aggregate_sizes(&mut self)

Propagate sizes from children to parents (bottom-up)

Source

pub fn sort_by_size(&mut self)

Sort all children by size descending

Source

pub fn toggle_expanded(&mut self, id: NodeId)

Toggle expanded state for a node

Source

pub fn set_expanded(&mut self, id: NodeId, expanded: bool)

Set expanded state for a node

Source

pub fn visible_nodes(&self, root: NodeId) -> Vec<NodeId>

Get visible nodes in tree order (respecting expansion state)

Source

pub fn path_to_node(&self, id: NodeId) -> Vec<NodeId>

Get the path from root to a node

Source

pub fn breadcrumbs(&self, id: NodeId) -> String

Get breadcrumb string for a node

Source

pub fn expand_to(&mut self, id: NodeId)

Expand all ancestors of a node

Source

pub fn total_size(&self) -> u64

Get total size of the tree

Source

pub fn total_files(&self) -> u64

Get total file count

Source

pub fn iter(&self) -> impl Iterator<Item = &TreeNode>

Iterator over all live nodes (skips tombstones)

Source

pub fn find_by_path(&self, path: &Path) -> Option<NodeId>

Find a node by its path

Source

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 Clone for DiskTree

Source§

fn clone(&self) -> DiskTree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiskTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DiskTree

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DiskTree

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,