tauri_plugin_app_control/
models.rs

1use serde::{Deserialize, Serialize};
2
3/// Options for configuring app exit behavior
4#[derive(Debug, Clone, Default, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct ExitOptions {
7    /// Whether to remove the app from the recent apps list
8    #[serde(default = "default_true")]
9    pub remove_from_recents: bool,
10    
11    /// Whether to forcefully kill the process (use with caution)
12    #[serde(default)]
13    pub kill_process: bool,
14}
15
16fn default_true() -> bool {
17    true
18}
19
20/// Result of minimizing the app
21#[derive(Debug, Clone, Serialize, Deserialize)]
22#[serde(rename_all = "camelCase")]
23pub struct MinimizeResult {
24    /// Whether the minimize operation was successful
25    pub success: bool,
26    
27    /// Human-readable message describing the result
28    pub message: String,
29}
30
31/// Result of closing the app
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct CloseResult {
35    /// Whether the close operation was successful
36    pub success: bool,
37    
38    /// Human-readable message describing the result
39    pub message: String,
40}
41
42/// Result of exiting the app
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct ExitResult {
46    /// Whether the exit operation was successful
47    pub success: bool,
48    
49    /// Human-readable message describing the result
50    pub message: String,
51}
52
53/// Current state of the application
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(rename_all = "camelCase")]
56pub struct AppState {
57    /// Whether the app is currently in the foreground
58    pub in_foreground: bool,
59    
60    /// Whether the app is in the process of finishing
61    pub is_finishing: bool,
62    
63    /// Whether the app has been destroyed (Android API 17+)
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub is_destroyed: Option<bool>,
66    
67    /// The app's package name
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub package_name: Option<String>,
70}