1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! An ultra-lightweight, dependency-free system dialog library.
//! Adds no GUI dependencies, requires no linking,
//! and introduces zero extra code complexity.
//!
//! Designed to show system-native dialogs as a last-resort
//! user-facing error/exception handler without adding project bloat.
//!
//! ## Usage
//!
//! Show a modal dialog with title `Hello`, content `World`, warning icon, and an `OK` button (closes when clicked):
//!
//! ```no_run
//! zero_dialog::show("Hello", "World", &Default::default());
//! ```
//!
//! Show error icon with `OK` / `Cancel` buttons and capture user choice:
//!
//! ```no_run
//! use zero_dialog::*;
//!
//! let title = "Fatal Error";
//! let msg = "Required assets not found, click Ok to exit";
//! let config = DialogConfig {
//! icon: IconKind::Error,
//! btn: ButtonKind::OkCancel,
//! };
//! let result = zero_dialog::show(title, msg, &config);
//! match result {
//! Ok(Response::Ok) => std::process::exit(1),
//! Ok(Response::Cancel) => println!("Cancel"),
//! _ => println!("None"),
//! }
//! ```
//!
//! Suitable for use after `panic!()` to display critical errors.
//!
//! ```no_run
//! use std::panic;
//! use zero_dialog::show;
//!
//! fn main() {
//! panic::set_hook(Box::new(|_| {
//! let title = "Error";
//! let msg = "Something went wrong";
//! let _ = show(title, msg, &Default::default());
//! }));
//!
//! panic!("Normal panic");
//! }
//! ```
/// User response when clicking buttons
/// Possible errors when attempting to show the dialog
/// Dialog button layout
/// Displays a modal dialog that blocks the calling thread and waits for user input.
///
/// Allows configuration of the dialog icon and button layout (default: Warning icon with OK button).
/// Use `Default::default()` if no custom configuration is needed.