native-dialog
Cross-platform native file choosers and message boxes for Rust
Repository Health
Technical Analysis
native-dialog is a Rust library for displaying platform-native file choosers and message boxes. It presents a single, ergonomic builder API while delegating to each operating system’s real dialog implementation, so applications get authentic OS look and feel with no bespoke per-platform code.
It supports GNU/Linux, BSD, macOS, and Windows, offering open/save file pickers, folder selection, and info/confirmation dialogs in both synchronous and asynchronous forms.
What You Get
- File open/save dialogs and folder pickers with filters and default locations
- Message boxes: info, warning, error, and yes/no confirmation prompts
- A single builder API (DialogBuilder) that works across all supported OSes
- Optional async support so dialogs can be spawned and awaited without blocking
Common Use Cases
- Adding an Open/Save file dialog to a Rust desktop application
- Prompting the user for confirmation before a destructive action
- Selecting an output directory or importing files with extension filters
Under The Hood
Architecture - The crate splits into a public builder layer (src/builder) and platform-specific dialog backends under src/dialog/{win,gnu,mac}. The builder collects options (title, filters, location) and dispatches to the correct backend at compile time via cfg targets. macOS uses objc2 bindings to AppKit panels (src/ffi/mac), Windows uses wfd/winapi common dialogs, and Linux/BSD shell out to Zenity, KDialog, or YAD detected at runtime.
Tech Stack - Rust edition 2024 (rust-version 1.85), with thiserror for errors and raw-window-handle for parenting. Platform deps are gated by target cfg: objc2/objc2-app-kit on macOS, winapi/wfd on Windows, and which/versions/ascii plus optional async-process on Unix. Async support is behind the async feature (futures-lite, futures-channel).
Code Quality - Code is cleanly modularized per platform and per dialog type (file.rs/message.rs), errors are centralized in errors.rs with a typed MissingDep variant for absent Linux backends, and macOS FFI is carefully split into focused modules (open_panel, save_panel, alert, and their async variants). The repo ships multiple runnable examples.
API Design - The DialogBuilder entry point reads fluently: DialogBuilder::file().add_filter(…).open_single_file().show(). The same builder exposes .spawn().await for async use, and message dialogs mirror the same pattern, giving a consistent, discoverable surface across platforms.