pub struct Keychain;Implementations§
Source§impl Keychain
impl Keychain
pub fn entry( account: impl Into<String>, service: impl Into<String>, ) -> KeychainEntry
Sourcepub fn set(account: &str, service: &str, password: &str) -> Result<()>
pub fn set(account: &str, service: &str, password: &str) -> Result<()>
Examples found in repository?
examples/01_keychain_password.rs (line 13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let account = "example-account";
8 let service = support::unique_service("keychain");
9 let access_control = AccessControl::create(
10 AccessControlProtection::WhenUnlocked,
11 AccessControlFlags::PRIVATE_KEY_USAGE,
12 )?;
13 Keychain::set(account, &service, "secret-password")?;
14 let password = Keychain::get(account, &service)?;
15 let accounts = Keychain::list_accounts(&service)?;
16 Keychain::delete(account, &service)?;
17 println!(
18 "password={password} accounts={accounts:?} access_control_created={}",
19 access_control.is_valid()
20 );
21 Ok(())
22}Sourcepub fn get(account: &str, service: &str) -> Result<String>
pub fn get(account: &str, service: &str) -> Result<String>
Examples found in repository?
examples/01_keychain_password.rs (line 14)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let account = "example-account";
8 let service = support::unique_service("keychain");
9 let access_control = AccessControl::create(
10 AccessControlProtection::WhenUnlocked,
11 AccessControlFlags::PRIVATE_KEY_USAGE,
12 )?;
13 Keychain::set(account, &service, "secret-password")?;
14 let password = Keychain::get(account, &service)?;
15 let accounts = Keychain::list_accounts(&service)?;
16 Keychain::delete(account, &service)?;
17 println!(
18 "password={password} accounts={accounts:?} access_control_created={}",
19 access_control.is_valid()
20 );
21 Ok(())
22}Sourcepub fn delete(account: &str, service: &str) -> Result<()>
pub fn delete(account: &str, service: &str) -> Result<()>
Examples found in repository?
examples/01_keychain_password.rs (line 16)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let account = "example-account";
8 let service = support::unique_service("keychain");
9 let access_control = AccessControl::create(
10 AccessControlProtection::WhenUnlocked,
11 AccessControlFlags::PRIVATE_KEY_USAGE,
12 )?;
13 Keychain::set(account, &service, "secret-password")?;
14 let password = Keychain::get(account, &service)?;
15 let accounts = Keychain::list_accounts(&service)?;
16 Keychain::delete(account, &service)?;
17 println!(
18 "password={password} accounts={accounts:?} access_control_created={}",
19 access_control.is_valid()
20 );
21 Ok(())
22}Sourcepub fn list_accounts(service: &str) -> Result<Vec<String>>
pub fn list_accounts(service: &str) -> Result<Vec<String>>
Examples found in repository?
examples/01_keychain_password.rs (line 15)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let account = "example-account";
8 let service = support::unique_service("keychain");
9 let access_control = AccessControl::create(
10 AccessControlProtection::WhenUnlocked,
11 AccessControlFlags::PRIVATE_KEY_USAGE,
12 )?;
13 Keychain::set(account, &service, "secret-password")?;
14 let password = Keychain::get(account, &service)?;
15 let accounts = Keychain::list_accounts(&service)?;
16 Keychain::delete(account, &service)?;
17 println!(
18 "password={password} accounts={accounts:?} access_control_created={}",
19 access_control.is_valid()
20 );
21 Ok(())
22}Auto Trait Implementations§
impl Freeze for Keychain
impl RefUnwindSafe for Keychain
impl Send for Keychain
impl Sync for Keychain
impl Unpin for Keychain
impl UnsafeUnpin for Keychain
impl UnwindSafe for Keychain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more