Skip to main content

win_desktop_utils/
lib.rs

1//! Windows-first desktop utility helpers for Rust apps.
2//!
3//! This crate provides small helpers for common Windows desktop-app tasks:
4//!
5//! - opening files and directories with the default shell handler
6//! - opening URLs
7//! - revealing items in Explorer
8//! - sending files or directories to the Recycle Bin
9//! - enforcing single-instance behavior
10//! - resolving per-user app-data directories
11//! - checking elevation and relaunching as admin
12//!
13//! This crate is intended for Windows desktop applications and utilities.
14//! Some functions launch external shell behavior or may trigger a UAC prompt.
15//!
16//! # Example
17//!
18//! ```
19//! fn main() -> Result<(), win_desktop_utils::Error> {
20//!     let local = win_desktop_utils::local_app_data("demo-app")?;
21//!     assert!(local.ends_with("demo-app"));
22//!
23//!     match win_desktop_utils::single_instance("demo-app")? {
24//!         Some(_guard) => {}
25//!         None => {}
26//!     }
27//!
28//!     Ok(())
29//! }
30//! ```
31
32pub mod elevation;
33pub mod error;
34pub mod instance;
35pub mod paths;
36pub mod shell;
37
38pub use error::{Error, Result};
39
40pub use elevation::{is_elevated, restart_as_admin};
41pub use instance::{single_instance, InstanceGuard};
42pub use paths::{ensure_local_app_data, ensure_roaming_app_data, local_app_data, roaming_app_data};
43pub use shell::{move_to_recycle_bin, open_url, open_with_default, reveal_in_explorer};