apple-localauthentication 0.2.0

Safe Rust bindings for Apple's LocalAuthentication framework — contexts, rights, persisted secrets, keys, and credentials on macOS
Documentation
use localauthentication::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let context = LAContext::new()?;
    let password = LACredential::application_password(b"p@ssword".to_vec());
    let pin = LACredential::smart_card_pin(b"123456".to_vec());

    assert!(context.set_credential(&password)?);
    assert!(context.is_credential_set(LACredentialType::ApplicationPassword)?);
    assert!(context.clear_credential(LACredentialType::ApplicationPassword)?);

    assert!(context.set_credential(&pin)?);
    assert!(context.is_credential_set(LACredentialType::SmartCardPin)?);
    assert!(context.clear_credential(LACredentialType::SmartCardPin)?);

    println!("password bytes: {}", password.bytes().len());
    println!("pin bytes: {}", pin.bytes().len());
    println!("✅ credential round-trip OK");
    Ok(())
}