-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlib.rs
More file actions
67 lines (59 loc) · 1.82 KB
/
lib.rs
File metadata and controls
67 lines (59 loc) · 1.82 KB
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
use tauri::{
plugin::{Builder, TauriPlugin},
Manager, Runtime,
};
pub use models::*;
#[cfg(all(desktop, not(target_os = "windows"), not(target_os = "macos")))]
mod desktop;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(mobile)]
mod mobile;
#[cfg(target_os = "windows")]
mod windows;
mod commands;
mod error;
mod models;
pub use error::{Error, Result};
#[cfg(all(desktop, not(target_os = "windows"), not(target_os = "macos")))]
use desktop::Biometry;
#[cfg(target_os = "macos")]
use macos::Biometry;
#[cfg(mobile)]
use mobile::Biometry;
#[cfg(target_os = "windows")]
use windows::Biometry;
/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the biometry APIs.
pub trait BiometryExt<R: Runtime> {
fn biometry(&self) -> &Biometry<R>;
}
impl<R: Runtime, T: Manager<R>> crate::BiometryExt<R> for T {
fn biometry(&self) -> &Biometry<R> {
self.state::<Biometry<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("biometry")
.invoke_handler(tauri::generate_handler![
commands::status,
commands::authenticate,
commands::has_data,
commands::get_data,
commands::set_data,
commands::remove_data,
])
.setup(|app, api| {
#[cfg(mobile)]
let biometry = mobile::init(app, api)?;
#[cfg(all(desktop, not(target_os = "windows"), not(target_os = "macos")))]
let biometry = desktop::init(app, api)?;
#[cfg(target_os = "windows")]
let biometry = windows::init(app, api)?;
#[cfg(target_os = "macos")]
let biometry = macos::init(app, api)?;
app.manage(biometry);
Ok(())
})
.build()
}