neco-filetree
Pure file tree snapshot helpers for lookup, subtree replacement, visible-row flattening, and reveal planning.
Tree snapshots
neco-filetree defines a neutral tree node shape and keeps all operations pure. Callers own loading, watcher integration, and UI state, while this crate handles exact node lookup, subtree replacement, flattening under a collapsed set, and ancestor expansion planning for reveal behavior.
Directory nodes carry both materialization and optional child_count, so a runtime can distinguish a fully loaded subtree from a partial listing without introducing host-specific types into the tree itself.
Usage
use BTreeSet;
use ;
use PathPolicy;
let tree = FileTreeNode ;
let rows = flatten_file_tree;
let plan = reveal_plan_for_path;
assert_eq!;
assert_eq!;
API
| Item | Description |
|---|---|
FileTreeNode |
Neutral file tree node with children, materialization, and optional child_count |
FileTreeNodeKind |
Distinguish File and Directory nodes |
DirectoryMaterialization |
Distinguish fully loaded and partial directory snapshots |
FlatFileTreeRow |
Flattened row shape for visible tree rendering |
RevealPlan |
Ordered ancestor expansion plan with found status |
find_node_by_path(root, path, policy) |
Find one node by exact path |
merge_subtree(root, subtree, policy) |
Monotonic merge: recursively merge the matching subtree, preserving existing deeper children and sibling order |
flatten_file_tree(root, collapsed_paths, include_root, policy) |
Convert a tree snapshot into visible rows |
reveal_plan_for_path(root, target_path, policy) |
Compute which ancestor directories should be expanded |
License
MIT