# dioxus-swdir-tree-core
Framework-free state machines powering [`dioxus-swdir-tree`](https://crates.io/crates/dioxus-swdir-tree): a lazy-loading directory-tree explorer and a generic in-memory item-tree, both over [`swdir`](https://crates.io/crates/swdir).
**This crate depends only on `swdir`** — no Dioxus, no async runtime — so it is testable anywhere and reusable from other frontends.
## What's inside
### `DirectoryTree`
- Lazy one-level loading — `on_toggled` returns `ScanRequest` as data; `on_loaded` merges the result.
- Stale-result protection via wrapping generation counter.
- `DisplayFilter` / `TreeCache` — zero-I/O filter switching.
- `SelectionMode` (Replace / Toggle / ExtendRange) — insertion-ordered multi-selection.
- `handle_key` — read-only keyboard navigation over `visible_rows()`.
- `on_drag_msg` / `DragMsg` / `DragOutcome` — press → hover → release drag protocol; emits `Completed { sources, destination }`.
- Speculative prefetch — `with_prefetch_limit`, `DEFAULT_PREFETCH_SKIP`.
- `set_search_query` / `SearchState` — incremental basename search, zero I/O.
- `IconTheme` / `IconRole` / `UnicodeTheme` — pluggable icon rendering; `LucideTheme` behind the `icons` feature.
### `ItemTree<T>`
- Fully preloaded in-memory tree over caller-supplied `NodeId`-keyed data. No I/O, no generation counter.
- `set_tree(root: ItemNode<T>)` — key-based diffing preserves expansion and selection for surviving `NodeId`s (S11.4/S11.5).
- `with_display(fn)` — display function for search and `VisibleItem::label`.
- `on_drag_msg` / `ItemDragMsg` / `ItemDragOutcome` — three-position drag: `DropPosition { Before, Into, After }`.
- `handle_key`, `set_search_query`, selection — same contract as `DirectoryTree`.
- `with_drag_and_drop(true)` — opt-in; off by default.
License: Apache-2.0.