2 releases
0.1.1 | Aug 1, 2022 |
---|---|
0.1.0 | Aug 1, 2022 |
#676 in Authentication
16KB
224 lines
tid-rs
TouchId integration for Rust
Usage
async fn touch_id() {
let mut ctx = LAContext::new();
if ctx.can_evaluate_policy(LAPolicy::DeviceOwnerAuthenticationWithBiometrics) {
ctx.set_localized_cancel_title("Use Another Method");
ctx.evaluate_policy(
LAPolicy::DeviceOwnerAuthenticationWithBiometrics,
"Use TouchId to Unlock Rust",
).await;
}
}
lib.rs
:
TouchId integration for Rust
This crate provides touch-id integration.
Get Started
Add following code to your Cargo.toml
:
tid-rs = "0.1"
Example
use tid::{LAContext, LAPolicy};
#[tokio::main(flavor = "current_thread")]
async fn main() {
let mut ctx = LAContext::new();
ctx.set_localized_cancel_title("Use Another Method");
if ctx.can_evaluate_policy(LAPolicy::DeviceOwnerAuthenticationWithBiometrics) {
println!("device supports biometrics authentication");
let auth_result = ctx.evaluate_policy(
LAPolicy::DeviceOwnerAuthenticationWithBiometrics,
"Use TouchId to Unlock Rust",
).await;
println!("Authentication result: {:?}", auth_result);
}
}
Dependencies
~2–7.5MB
~57K SLoC