tauri_plugin_android_fs/models.rs
1use serde::{Deserialize, Serialize};
2
3
4/// Filters for VisualMediaPicker.
5#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
6pub enum VisualMediaTarget {
7
8 /// Allow only images to be selected.
9 ImageOnly,
10
11 /// Allow only videos to be selected.
12 VideoOnly,
13
14 /// Allow only images and videos to be selected.
15 ImageAndVideo
16}
17
18/// The application specific directory.
19#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
20pub enum PrivateDir {
21
22 /// The application specific persistent-data directory.
23 ///
24 /// The system prevents other apps from accessing these locations, and on Android 10 (API level 29) and higher, these locations are encrypted.
25 ///
26 /// These files will be deleted when the app is uninstalled and may also be deleted at the user’s request.
27 ///
28 /// ex: `/data/user/0/{app-package-name}/files`
29 Data,
30
31 /// The application specific cache directory.
32 ///
33 /// The system prevents other apps from accessing these locations, and on Android 10 (API level 29) and higher, these locations are encrypted.
34 ///
35 /// These files will be deleted when the app is uninstalled and may also be deleted at the user’s request.
36 /// In addition, the system will automatically delete files in this directory as disk space is needed elsewhere on the device.
37 ///
38 /// ex: `/data/user/0/{app-package-name}/cache`
39 Cache,
40}
41
42/// Directory in which to place images that are available to other applications and users.
43#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
44pub enum PublicImageDir {
45
46 /// Standard directory in which to place pictures that are available to the user.
47 ///
48 /// ex: `~/Pictures`
49 Pictures,
50
51 /// The traditional location for pictures and videos when mounting the device as a camera.
52 ///
53 /// ex: `~/DCIM`
54 DCIM,
55}
56
57/// Directory in which to place videos that are available to other applications and users.
58#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
59pub enum PublicVideoDir {
60
61 /// Standard directory in which to place movies that are available to the user.
62 ///
63 /// ex: `~/Movies`
64 Movies,
65
66 /// The traditional location for pictures and videos when mounting the device as a camera.
67 ///
68 /// ex: `~/DCIM`
69 DCIM,
70}
71
72/// Directory in which to place audios that are available to other applications and users.
73#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
74pub enum PublicAudioDir {
75
76 /// Standard directory in which to place movies that are available to the user.
77 ///
78 /// ex: `~/Music`
79 Music,
80
81 /// Standard directory in which to place any audio files that should be in the list of alarms that the user can select (not as regular music).
82 ///
83 /// ex: `~/Alarms`
84 Alarms,
85
86 /// Standard directory in which to place any audio files that should be in the list of audiobooks that the user can select (not as regular music).
87 ///
88 /// This is not available on Android 9 (API level 28) and lower.
89 /// Availability on a given device can be verified by calling [`PublicStorage::is_audiobooks_dir_available`](crate::PublicStorage::is_audiobooks_dir_available).
90 ///
91 /// ex: `~/Audiobooks`
92 Audiobooks,
93
94 /// Standard directory in which to place any audio files that should be in the list of notifications that the user can select (not as regular music).
95 ///
96 /// ex: `~/Notifications`
97 Notifications,
98
99 /// Standard directory in which to place any audio files that should be in the list of podcasts that the user can select (not as regular music).
100 ///
101 /// ex: `~/Podcasts`
102 Podcasts,
103
104 /// Standard directory in which to place any audio files that should be in the list of ringtones that the user can select (not as regular music).
105 ///
106 /// ex: `~/Ringtones`
107 Ringtones,
108
109 /// Standard directory in which to place any audio files that should be in the list of voice recordings recorded by voice recorder apps that the user can select (not as regular music).
110 ///
111 /// This is not available on Android 11 (API level 30) and lower.
112 /// Availability on a given device can be verified by calling [`PublicStorage::is_recordings_dir_available`](crate::PublicStorage::is_recordings_dir_available).
113 ///
114 /// ex: `~/Recordings`
115 Recordings,
116}
117
118/// Directory in which to place files that are available to other applications and users.
119#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
120pub enum PublicGeneralPurposeDir {
121
122 /// Standard directory in which to place documents that have been created by the user.
123 ///
124 /// ex: `~/Documents`
125 Documents,
126
127 /// Standard directory in which to place files that have been downloaded by the user.
128 ///
129 /// ex: `~/Download`
130 Download,
131}
132
133
134#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Deserialize, Serialize)]
135pub(crate) enum PublicDir {
136 #[serde(untagged)]
137 Image(PublicImageDir),
138
139 #[serde(untagged)]
140 Video(PublicVideoDir),
141
142 #[serde(untagged)]
143 Audio(PublicAudioDir),
144
145 #[serde(untagged)]
146 GeneralPurpose(PublicGeneralPurposeDir),
147}