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//! This crate supports Windows only.
16//!
17//! # Example
18//!
19//! ```
20//! fn main() -> Result<(), win_desktop_utils::Error> {
21//! let local = win_desktop_utils::local_app_data("demo-app")?;
22//! assert!(local.ends_with("demo-app"));
23//!
24//! match win_desktop_utils::single_instance("demo-app")? {
25//! Some(_guard) => {}
26//! None => {}
27//! }
28//!
29//! Ok(())
30//! }
31//! ```
32
33#[cfg(not(windows))]
34compile_error!("win-desktop-utils supports Windows only.");
35
36#[cfg(windows)]
37pub mod elevation;
38#[cfg(windows)]
39pub mod error;
40#[cfg(windows)]
41pub mod instance;
42#[cfg(windows)]
43pub mod paths;
44#[cfg(windows)]
45pub mod shell;
46
47#[cfg(windows)]
48pub use error::{Error, Result};
49
50#[cfg(windows)]
51pub use elevation::{is_elevated, restart_as_admin};
52#[cfg(windows)]
53pub use instance::{single_instance, InstanceGuard};
54#[cfg(windows)]
55pub use paths::{ensure_local_app_data, ensure_roaming_app_data, local_app_data, roaming_app_data};
56#[cfg(windows)]
57pub use shell::{move_to_recycle_bin, open_url, open_with_default, reveal_in_explorer};