use std::collections::HashMap;
use keyring_core::Entry;
use linux_keyutils_keyring_store::Store;
fn main() {
keyring_core::set_default_store(Store::new().unwrap());
let service = "service";
let username = "user";
let password = "<PASSWORD>";
let entry = Entry::new(service, username).unwrap();
entry.set_password(password).unwrap();
let retrieved = entry.get_password().unwrap();
if retrieved != password {
panic!("Passwords do not match");
}
println!("Entry with no target: {:?}", entry);
entry.delete_credential().unwrap();
let modifiers = HashMap::from([("description", "custom description")]);
let entry = Entry::new_with_modifiers("ignored", "ignored", &modifiers).unwrap();
entry.set_password(password).unwrap();
let retrieved = entry.get_password().unwrap();
if retrieved != password {
panic!("Passwords do not match");
}
println!("Entry with custom description: {:?}", entry);
entry.delete_credential().unwrap();
keyring_core::unset_default_store();
}