Skip to main content

01_keychain_password/
01_keychain_password.rs

1#[path = "support/mod.rs"]
2mod support;
3
4use security::Keychain;
5
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let account = "example-account";
8    let service = support::unique_service("keychain");
9    Keychain::set(account, &service, "secret-password")?;
10    let password = Keychain::get(account, &service)?;
11    let accounts = Keychain::list_accounts(&service)?;
12    Keychain::delete(account, &service)?;
13    println!("password={password} accounts={accounts:?}");
14    Ok(())
15}