localauthentication/
la_policy.rs1use crate::ffi;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7#[non_exhaustive]
8pub enum LAPolicy {
9 DeviceOwnerAuthenticationWithBiometrics,
11 DeviceOwnerAuthentication,
13 DeviceOwnerAuthenticationWithCompanion,
15 DeviceOwnerAuthenticationWithBiometricsOrCompanion,
17 #[deprecated(note = "Use `DeviceOwnerAuthenticationWithCompanion` instead.")]
19 DeviceOwnerAuthenticationWithWatch,
20 #[deprecated(note = "Use `DeviceOwnerAuthenticationWithBiometricsOrCompanion` instead.")]
22 DeviceOwnerAuthenticationWithBiometricsOrWatch,
23}
24
25pub type Policy = LAPolicy;
27
28impl LAPolicy {
29 #[allow(deprecated)]
30 #[must_use]
31 pub const fn raw_value(self) -> i32 {
32 match self {
33 Self::DeviceOwnerAuthenticationWithBiometrics => {
34 ffi::la_policy::DEVICE_OWNER_AUTHENTICATION_WITH_BIOMETRICS
35 }
36 Self::DeviceOwnerAuthentication => ffi::la_policy::DEVICE_OWNER_AUTHENTICATION,
37 Self::DeviceOwnerAuthenticationWithCompanion => {
38 ffi::la_policy::DEVICE_OWNER_AUTHENTICATION_WITH_COMPANION
39 }
40 Self::DeviceOwnerAuthenticationWithBiometricsOrCompanion => {
41 ffi::la_policy::DEVICE_OWNER_AUTHENTICATION_WITH_BIOMETRICS_OR_COMPANION
42 }
43 Self::DeviceOwnerAuthenticationWithWatch => {
44 ffi::la_policy::DEVICE_OWNER_AUTHENTICATION_WITH_WATCH
45 }
46 Self::DeviceOwnerAuthenticationWithBiometricsOrWatch => {
47 ffi::la_policy::DEVICE_OWNER_AUTHENTICATION_WITH_BIOMETRICS_OR_WATCH
48 }
49 }
50 }
51
52 pub(crate) const fn as_ffi(self) -> i32 {
53 self.raw_value()
54 }
55
56 #[allow(deprecated)]
58 #[must_use]
59 pub const fn description(self) -> &'static str {
60 match self {
61 Self::DeviceOwnerAuthenticationWithBiometrics => {
62 "device owner authentication with biometrics"
63 }
64 Self::DeviceOwnerAuthentication => "device owner authentication",
65 Self::DeviceOwnerAuthenticationWithCompanion => {
66 "device owner authentication with companion"
67 }
68 Self::DeviceOwnerAuthenticationWithBiometricsOrCompanion => {
69 "device owner authentication with biometrics or companion"
70 }
71 Self::DeviceOwnerAuthenticationWithWatch => "device owner authentication with watch",
72 Self::DeviceOwnerAuthenticationWithBiometricsOrWatch => {
73 "device owner authentication with biometrics or watch"
74 }
75 }
76 }
77}