Skip to main content

Crate dioxus_swdir_tree

Crate dioxus_swdir_tree 

Source
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 runs ScanRequests off the UI thread and merges results back through the Signal<DirectoryTree>.
entry
Owned, framework-neutral directory entry produced by a scan.
error
Cloneable, comparable error attached to a crate::TreeNode whose scan failed.
event
Re-export DirectoryTreeEvent from dioxus-swdir-tree-core.
executor
The async executor seam: who runs a crate::scan::ScanRequest and how the result re-enters the reactive cycle.
icon
Icon theme types for crate::DirectoryTree rendering.
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-style feature.
tree
The widget root: all state, all accessors, and the entry points the embedding layer calls. State transitions live in the private tree::transitions submodule.

Structs§

ArcTheme
Thin Arc<dyn IconTheme> wrapper that implements PartialEq via pointer equality so it can be used as a Dioxus prop.
CachedScan
One completed scan: the generation it was accepted under and the complete (unfiltered) entry list.
DirectoryTree
The directory-tree widget state.
DragState
Active drag session.
IconSpec
The rendering specification for one icon position (S10.3).
ItemNode
Caller-facing input to crate::ItemTree::set_tree: a recursive tree of items.
ItemSearchState
Active search session held on crate::ItemTree.
ItemTree
Generic in-memory item tree (S11).
LoadPayload
A completed scan, ready to merge.
LoadedEntry
One scanned directory entry, reduced to what the tree model needs.
LoadedOutcome
What crate::DirectoryTree::on_loaded did 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 u64 values (S11.4 key-based diffing).
ScanIssue
Owned record of a failed directory scan.
ScanRequest
A scan the embedding layer must execute off the UI thread.
SearchState
Active search session held on crate::DirectoryTree.
ThreadExecutor
Default executor: spawns one std::thread::spawn per scan (S5.3).
TreeCache
Flat map from scanned path to its latest accepted result.
TreeConfig
Settings fixed at construction or mutated by the application at runtime.
TreeNode
One directory entry in the tree.
UnicodeTheme
Default theme: Unicode/emoji glyphs in the ambient system font. No font registration required (S10.5, without icons feature).
VisibleItem
Pre-computed row data returned by crate::ItemTree::visible_rows.

Enums§

DirectoryTreeEvent
An event emitted by the keyboard handler, the view component, or the drag state machine.
DisplayFilter
Which scanned entries become visible tree nodes.
DragMsg
A drag gesture event sent by the view to crate::DirectoryTree::on_drag_msg.
DragOutcome
The side effect produced by crate::DirectoryTree::on_drag_msg.
DropPosition
Where a dragged node lands relative to the drop target (S11.15).
IconRole
The six logical icon positions in a tree row (S10.1).
ItemDragMsg
Opaque drag-gesture message produced by the view, routed back to crate::ItemTree::on_drag_msg unchanged.
ItemDragOutcome
The side effect produced by crate::ItemTree::on_drag_msg.
ItemTreeEvent
An event emitted by crate::ItemTree::handle_key or by the view component’s mouse handlers.
SelectionMode
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§

IconTheme
Plug-in icon rendering (S10.7).
ScanExecutor
The executor seam — pluggable off-thread scan execution (S5.1).

Functions§

DirectoryTreeView
A lazy-loading, filterable, keyboard-navigable, drag-and-drop, search-aware directory-tree explorer widget for Dioxus.
ItemTreeView
default_theme
Return the default theme for the active feature set.
handle_key
Translate a key press into a DirectoryTreeEvent, or None when the key is unbound (hosts may handle it themselves).

Type Aliases§

ScanFuture
The future returned by ScanExecutor::spawn_blocking.
ScanJob
A heap-allocated blocking job: no arguments, returns a LoadPayload.