Expand description
§dioxus-swdir-tree
A lazy-loading directory-tree explorer widget for
Dioxus GUI apps, built on
swdir.
§Architecture
┌─────────────────────────────┐
Signal │ DirectoryTreeView │ renders
─────────────►│ (this crate) │──────────► HTML rows
│ │
on_event ◄────│ EventHandler │ user gestures
└──────────────┬──────────────┘
│ Toggled / Selected / Drag
▼
┌─────────────────────────────┐
Signal.write │ DirectoryTree │ pure state machine
─────────────►│ (dioxus-swdir-tree-core) │
└──────────────┬──────────────┘
│ ScanRequest (data)
▼
┌─────────────────────────────┐
│ use_scan_driver │ coroutine
│ ScanExecutor / Thread │ executes scan
└─────────────────────────────┘§Quick start
use dioxus_swdir_tree::{DirectoryTreeView, DirectoryTreeEvent, use_scan_driver};
use dioxus_swdir_tree_core::{DirectoryTree, SelectionMode, ThreadExecutor};
use dioxus_swdir_tree_core::drag::DragOutcome;
use std::sync::Arc;
fn app() -> Element {
let mut tree = use_signal(|| DirectoryTree::new("/home"));
let scans = use_scan_driver(tree, Arc::new(ThreadExecutor));
let on_event = move |ev: DirectoryTreeEvent| match ev {
DirectoryTreeEvent::Toggled(path) => {
if let Some(req) = tree.write().on_toggled(&path) {
scans.send(req);
}
}
DirectoryTreeEvent::Selected { path, is_dir, mode } => {
tree.write().on_selected(&path, is_dir, mode);
}
DirectoryTreeEvent::Drag(msg) => {
let outcome = tree.write().on_drag_msg(msg);
if let DragOutcome::Clicked { path, is_dir } = outcome {
tree.write().on_selected(&path, is_dir, SelectionMode::Replace);
}
// DragOutcome::Completed { sources, destination } → app handles it
}
};
rsx! { DirectoryTreeView { tree, on_event } }
}The default-style feature (on by default) injects a minimal
dx-swdir-* stylesheet; disable it to theme from scratch.
Re-exports§
pub use driver::use_scan_driver;pub use view::DirectoryTreeView;pub use view::DirectoryTreeView;
Modules§
- cache
- Cache of raw, unfiltered scan results, keyed by path.
- config
- Widget configuration: display filter modes and the per-tree settings.
- drag
- Drag-and-drop state and messages for
crate::DirectoryTree. - driver
- The async scan driver: a
use_coroutine-backed hook that runsScanRequests off the UI thread and merges results back through theSignal<DirectoryTree>. - entry
- Owned, framework-neutral directory entry produced by a scan.
- error
- Cloneable, comparable error attached to a
crate::TreeNodewhose scan failed. - event
- Re-export
DirectoryTreeEventfromdioxus-swdir-tree-core. - executor
- The async executor seam: who runs a
crate::scan::ScanRequestand how the result re-enters the reactive cycle. - icon
- Icon theme types for
crate::DirectoryTreerendering. - item_
event - Event type for
crate::ItemTree. - item_
tree - Generic in-memory item tree — framework-free sibling of
crate::DirectoryTree. - keyboard
- Framework-neutral keyboard navigation for
crate::DirectoryTree. - node
- The recursive node value making up the in-memory tree.
- scan
- The async-boundary types: side effects as data, and the one blocking function that executes them.
- search
- Incremental search over the already-loaded node graph.
- selection
- Selection state and mode types for
crate::DirectoryTree. - style
- CSS class names (the public theming surface) and the optional default
stylesheet bundled behind the
default-stylefeature. - tree
- The widget root: all state, all accessors, and the entry points the
embedding layer calls. State transitions live in the private
tree::transitionssubmodule.
Structs§
- ArcTheme
- Thin
Arc<dyn IconTheme>wrapper that implementsPartialEqvia pointer equality so it can be used as a Dioxus prop. - Cached
Scan - One completed scan: the generation it was accepted under and the complete (unfiltered) entry list.
- Directory
Tree - The directory-tree widget state.
- Drag
State - Active drag session.
- Icon
Spec - The rendering specification for one icon position (S10.3).
- Item
Node - Caller-facing input to
crate::ItemTree::set_tree: a recursive tree of items. - Item
Search State - Active search session held on
crate::ItemTree. - Item
Tree - Generic in-memory item tree (S11).
- Load
Payload - A completed scan, ready to merge.
- Loaded
Entry - One scanned directory entry, reduced to what the tree model needs.
- Loaded
Outcome - What
crate::DirectoryTree::on_loadeddid with a payload. - Modifiers
- Active modifier keys at the time of the key press.
- NodeId
- Opaque node identity. The caller assigns IDs; the tree treats them as
black-box
u64values (S11.4 key-based diffing). - Scan
Issue - Owned record of a failed directory scan.
- Scan
Request - A scan the embedding layer must execute off the UI thread.
- Search
State - Active search session held on
crate::DirectoryTree. - Thread
Executor - Default executor: spawns one
std::thread::spawnper scan (S5.3). - Tree
Cache - Flat map from scanned path to its latest accepted result.
- Tree
Config - Settings fixed at construction or mutated by the application at runtime.
- Tree
Node - One directory entry in the tree.
- Unicode
Theme - Default theme: Unicode/emoji glyphs in the ambient system font.
No font registration required (S10.5, without
iconsfeature). - Visible
Item - Pre-computed row data returned by
crate::ItemTree::visible_rows.
Enums§
- Directory
Tree Event - An event emitted by the keyboard handler, the view component, or the drag state machine.
- Display
Filter - Which scanned entries become visible tree nodes.
- DragMsg
- A drag gesture event sent by the view to
crate::DirectoryTree::on_drag_msg. - Drag
Outcome - The side effect produced by
crate::DirectoryTree::on_drag_msg. - Drop
Position - Where a dragged node lands relative to the drop target (S11.15).
- Icon
Role - The six logical icon positions in a tree row (S10.1).
- Item
Drag Msg - Opaque drag-gesture message produced by the view, routed back to
crate::ItemTree::on_drag_msgunchanged. - Item
Drag Outcome - The side effect produced by
crate::ItemTree::on_drag_msg. - Item
Tree Event - An event emitted by
crate::ItemTree::handle_keyor by the view component’s mouse handlers. - Selection
Mode - How a click or keyboard gesture modifies the selection set.
- TreeKey
- A bound key — the framework-neutral representation of a key press.
Constants§
- DEFAULT_
PREFETCH_ SKIP - Basenames skipped by the prefetch heuristic (S8.5) — directories whose names match any entry here (ASCII case-insensitive) are never speculatively scanned.
Traits§
- Icon
Theme - Plug-in icon rendering (S10.7).
- Scan
Executor - The executor seam — pluggable off-thread scan execution (S5.1).
Functions§
- Directory
Tree View - A lazy-loading, filterable, keyboard-navigable, drag-and-drop, search-aware directory-tree explorer widget for Dioxus.
- Item
Tree View - default_
theme - Return the default theme for the active feature set.
- handle_
key - Translate a key press into a
DirectoryTreeEvent, orNonewhen the key is unbound (hosts may handle it themselves).
Type Aliases§
- Scan
Future - The future returned by
ScanExecutor::spawn_blocking. - ScanJob
- A heap-allocated blocking job: no arguments, returns a
LoadPayload.