tauri_plugin_android_fs/
lib.rs1#![allow(unused_variables)]
4
5mod models;
6mod error;
7mod api;
8
9#[cfg(target_os = "android")]
10mod utils;
11
12pub use models::*;
13pub use error::*;
14pub use api::*;
15
16#[cfg(target_os = "android")]
17pub(crate) use utils::*;
18
19pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
21 tauri::plugin::Builder::new("android-fs")
22 .setup(|app, api| {
23 use tauri::Manager as _;
24
25 let afs = AndroidFs::new(app.clone(), api)?;
26
27 #[cfg(target_os = "android")] {
28 let _ = afs
30 .private_storage()
31 .remove_all_tmp_files();
32 }
33
34 app.manage(afs);
35 Ok(())
36 })
37 .build()
38}
39
40pub trait AndroidFsExt<R: tauri::Runtime> {
41
42 fn android_fs(&self) -> &AndroidFs<R>;
43}
44
45impl<R: tauri::Runtime, T: tauri::Manager<R>> AndroidFsExt<R> for T {
46
47 fn android_fs(&self) -> &AndroidFs<R> {
48 self.try_state::<AndroidFs<R>>()
49 .map(|i| i.inner())
50 .expect("You should call tauri_plugin_android_fs::init() and registier it to your project. See https://crates.io/crates/tauri-plugin-android-fs")
51 }
52}