localauthentication/
la_authentication_requirement.rs1use crate::ffi;
4use crate::la_error::Result;
5use crate::private::{bridge_ptr, OwnedHandle};
6
7#[derive(Debug)]
9pub struct LAAuthenticationRequirement {
10 handle: OwnedHandle,
11}
12
13impl LAAuthenticationRequirement {
14 pub(crate) const fn as_ptr(&self) -> *mut core::ffi::c_void {
15 self.handle.as_ptr()
16 }
17
18 pub fn default_requirement() -> Result<Self> {
24 let raw = bridge_ptr(|out, error_out| unsafe {
25 ffi::la_authentication_requirement::la_authentication_requirement_default(
26 out, error_out,
27 )
28 })?;
29 Ok(Self {
30 handle: OwnedHandle::new(
31 raw,
32 ffi::la_authentication_requirement::la_authentication_requirement_release,
33 ),
34 })
35 }
36
37 pub fn biometry_requirement() -> Result<Self> {
43 let raw = bridge_ptr(|out, error_out| unsafe {
44 ffi::la_authentication_requirement::la_authentication_requirement_biometry(
45 out, error_out,
46 )
47 })?;
48 Ok(Self {
49 handle: OwnedHandle::new(
50 raw,
51 ffi::la_authentication_requirement::la_authentication_requirement_release,
52 ),
53 })
54 }
55
56 pub fn biometry_current_set_requirement() -> Result<Self> {
62 let raw = bridge_ptr(|out, error_out| unsafe {
63 ffi::la_authentication_requirement::la_authentication_requirement_biometry_current_set(
64 out, error_out,
65 )
66 })?;
67 Ok(Self {
68 handle: OwnedHandle::new(
69 raw,
70 ffi::la_authentication_requirement::la_authentication_requirement_release,
71 ),
72 })
73 }
74
75 pub fn biometry_requirement_with_fallback(
81 fallback: &LABiometryFallbackRequirement,
82 ) -> Result<Self> {
83 let raw = bridge_ptr(|out, error_out| unsafe {
84 ffi::la_authentication_requirement::la_authentication_requirement_biometry_with_fallback(
85 fallback.as_ptr(),
86 out,
87 error_out,
88 )
89 })?;
90 Ok(Self {
91 handle: OwnedHandle::new(
92 raw,
93 ffi::la_authentication_requirement::la_authentication_requirement_release,
94 ),
95 })
96 }
97}
98
99#[derive(Debug)]
101pub struct LABiometryFallbackRequirement {
102 handle: OwnedHandle,
103}
104
105impl LABiometryFallbackRequirement {
106 pub(crate) const fn as_ptr(&self) -> *mut core::ffi::c_void {
107 self.handle.as_ptr()
108 }
109
110 pub fn default_requirement() -> Result<Self> {
116 let raw = bridge_ptr(|out, error_out| unsafe {
117 ffi::la_authentication_requirement::la_biometry_fallback_requirement_default(
118 out, error_out,
119 )
120 })?;
121 Ok(Self {
122 handle: OwnedHandle::new(
123 raw,
124 ffi::la_authentication_requirement::la_biometry_fallback_requirement_release,
125 ),
126 })
127 }
128
129 pub fn device_passcode_requirement() -> Result<Self> {
135 let raw = bridge_ptr(|out, error_out| unsafe {
136 ffi::la_authentication_requirement::la_biometry_fallback_requirement_device_passcode(
137 out, error_out,
138 )
139 })?;
140 Ok(Self {
141 handle: OwnedHandle::new(
142 raw,
143 ffi::la_authentication_requirement::la_biometry_fallback_requirement_release,
144 ),
145 })
146 }
147}