Skip to main content

tauri_plugin_biometry/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Default, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct AuthOptions {
6    /// Enables authentication using the device's password. This feature is available on both Android and iOS.
7    pub allow_device_credential: Option<bool>,
8    /// Label for the Cancel button. This feature is available on both Android and iOS.
9    pub cancel_title: Option<String>,
10    /// Specifies the text displayed on the fallback button if biometry authentication fails. This feature is available iOS only.
11    pub fallback_title: Option<String>,
12    /// Title indicating the purpose of biometry verification. This feature is available Android only.
13    pub title: Option<String>,
14    /// SubTitle providing contextual information of biometry verification. This feature is available Android only.
15    pub subtitle: Option<String>,
16    /// Specifies whether additional user confirmation is required, such as pressing a button after successful biometry authentication. This feature is available Android only.
17    pub confirmation_required: Option<bool>,
18}
19
20#[derive(Serialize)]
21pub struct AuthenticatePayload {
22    pub reason: String,
23    #[serde(flatten)]
24    pub options: AuthOptions,
25}
26
27#[derive(Debug, Clone, serde_repr::Deserialize_repr, serde_repr::Serialize_repr)]
28#[repr(u8)]
29pub enum BiometryType {
30    None = 0,
31    Auto = 1,
32    TouchID = 2,
33    FaceID = 3,
34}
35
36#[derive(Debug, Clone, Deserialize, Serialize)]
37#[serde(rename_all = "camelCase")]
38pub struct Status {
39    pub is_available: bool,
40    pub biometry_type: BiometryType,
41    pub error: Option<String>,
42    pub error_code: Option<String>,
43}
44
45#[derive(Debug, Clone, Deserialize, Serialize)]
46#[serde(rename_all = "camelCase")]
47pub struct HasDataResponse {
48    pub has_data: bool,
49}
50
51#[derive(Debug, Clone, Deserialize, Serialize)]
52#[serde(rename_all = "camelCase")]
53pub struct DataOptions {
54    pub domain: String,
55    pub name: String,
56}
57
58#[derive(Debug, Clone, Deserialize, Serialize)]
59#[serde(rename_all = "camelCase")]
60pub struct DataResponse {
61    pub domain: String,
62    pub name: String,
63    pub data: String,
64}
65
66#[derive(Debug, Clone, Deserialize, Serialize)]
67#[serde(rename_all = "camelCase")]
68pub struct GetDataOptions {
69    pub domain: String,
70    pub name: String,
71    pub reason: String,
72    pub cancel_title: Option<String>,
73}
74
75#[derive(Debug, Clone, Deserialize, Serialize)]
76#[serde(rename_all = "camelCase")]
77pub struct SetDataOptions {
78    pub domain: String,
79    pub name: String,
80    pub data: String,
81}
82
83pub type RemoveDataOptions = DataOptions;