Workspace Structure
Loom LDAP Browser is organized as a Cargo workspace with three crates, each with distinct responsibilities:Crate Responsibilities
loom-ldapbrowser (Binary)
loom-ldapbrowser (Binary)
The main binary crate that ties everything together.Responsibilities:
- Command-line argument parsing with
clap - Application initialization and entry point
- TUI runtime setup
- Credential prompting (
rpassword) - Configuration file discovery
loom-tui- TUI application logicloom-core- LDAP operationsclap- CLI argument parsingtokio- Async runtime
loom-core (Library)
loom-core (Library)
Core LDAP client functionality and business logic.Modules:
connection.rs- LDAP connection management and operationsschema.rs- Schema parsing and caching (object classes, attribute types)search.rs- LDAP search operations with paging supportmodify.rs- Entry modification (add, replace, delete attributes)entry.rs- Entry data structures and serializationdn.rs- Distinguished Name parsing and manipulationfilter.rs- LDAP filter parsing and validationtree.rs- Directory tree navigation structuresexport/- LDIF, JSON, CSV, XLSX export formatsimport/- LDIF, JSON, CSV, XLSX import parsersbulk.rs- Bulk update operationstls.rs- TLS configuration and certificate trustcredentials.rs- Password retrieval (keychain, command, prompt)auth.rs- LDAP bind authenticationserver_detect.rs- Server type detection (OpenLDAP, AD, etc.)offline.rs- In-memory demo directory for testingvault.rs- Encrypted credential storage
ldap3- LDAP protocol implementationserde,serde_json,toml- Serializationcsv,rust_xlsxwriter,calamine- Export/Importkeyring- OS keychain integrationrustls- TLS support
loom-tui (Library)
loom-tui (Library)
Terminal user interface framework and all UI components.Core Modules:
app.rs- Main application state machine (124KB - the heart of the app)action.rs- Action enum and dispatch typesconfig.rs- Configuration file parsing and profileskeymap.rs- Keybinding configuration and handlingtheme.rs- Theme system and color palettesevent.rs- Terminal event loopfocus.rs- Focus management across panelstui.rs- Terminal initialization and rendering
components/):tree_panel.rs- Directory tree browserdetail_panel.rs- Entry attribute viewercommand_panel.rs- Search input and command bartab_bar.rs- Connection tab switcherstatus_bar.rs- Status and hints displayconnections_tree.rs- Profiles tree viewconnection_form.rs- Profile editor formattribute_editor.rs- Attribute value editor with DN searchattribute_picker.rs- Add attribute dialogsearch_dialog.rs- Search results popupschema_viewer.rs- Schema browserexport_dialog.rs- Export configuration formbulk_update_dialog.rs- Bulk update formcreate_entry_dialog.rs- New entry wizardconnect_dialog.rs- Quick connect dialoghelp_popup.rs- Help overlaycontext_menu.rs- Right-click context menuscert_trust_dialog.rs- Certificate trust promptvault_password_dialog.rs- Vault password prompt
ratatui- TUI frameworkcrossterm- Terminal backendtui-tree-widget- Tree componenttui-textarea- Text input widgettui-logger- Log panel integrationnucleo- Fuzzy search
Action Dispatch Pattern
All state changes in Loom LDAP Browser flow through an Action enum dispatched via an async channel. This architecture keeps the UI responsive by running LDAP operations in background Tokio tasks.The Action Enum
TheAction enum (defined in loom-tui/src/action.rs) is the central message type:
Dispatch Flow
User Input
Terminal events (key presses, mouse clicks) are captured by the event loop and converted to actions by UI components.
Action Sent to App
Actions are sent through an async channel (
tokio::sync::mpsc) to the main application state machine.State Update
The
App::update() method in app.rs receives the action and updates state. For I/O operations, it spawns a background task.Benefits of Action Dispatch
Non-blocking UI
LDAP operations run in background tasks, keeping the UI responsive even during slow network operations.
Testability
Actions can be tested in isolation without a running LDAP server by inspecting action sequences.
Debugging
All state transitions are explicit actions that can be logged for debugging.
Extensibility
New features add new action variants without disrupting existing logic.
Data Flow Example: Loading Entry Details
Here’s how data flows when a user selects an entry in the tree:The async action pattern is inspired by Redux and Elm architecture, providing predictable state management with immutable state transitions.
Component Communication
Components communicate only through actions. They don’t hold direct references to each other.Building the Workspace
Use Cargo workspace commands to build all crates:The
--workspace flag ensures all three crates (loom-ldapbrowser, loom-core, loom-tui) are built together with consistent dependencies.Dependency Graph
- loom-ldapbrowser depends on both libraries
- loom-tui depends on loom-core for LDAP types
- loom-core has no internal dependencies (only external crates)