pub struct KeyringStore { /* private fields */ }Expand description
OS-backed credential storage scoped to one service identifier (bundle id / custom).
Implementations§
Source§impl KeyringStore
impl KeyringStore
Sourcepub fn new(service: impl Into<String>) -> Self
pub fn new(service: impl Into<String>) -> Self
Creates a store handle; no I/O until the first read/write (backend registers lazily).
Sourcepub fn availability(&self) -> KeyringAvailability
pub fn availability(&self) -> KeyringAvailability
Probes whether the OS keyring is readable without surfacing an error to callers.
On iOS, performs a read of a dedicated probe account: missing entry means available;
keyring_core::Error::NoStorageAccess means locked. Other platforms always return
KeyringAvailability::Available.
Sourcepub fn set_password(&self, account: &str, password: &str) -> Result<()>
pub fn set_password(&self, account: &str, password: &str) -> Result<()>
Persists a UTF-8 secret (use Self::set_bytes for arbitrary bytes).
Sourcepub fn set_bytes(&self, account: &str, value: &[u8]) -> Result<()>
pub fn set_bytes(&self, account: &str, value: &[u8]) -> Result<()>
Encodes value as Base64 and stores it via Self::set_password.
Sourcepub fn get_password(&self, account: &str) -> Result<Option<String>>
pub fn get_password(&self, account: &str) -> Result<Option<String>>
Returns stored UTF-8, or None if the entry is missing.
Sourcepub fn get_password_for_background(
&self,
account: &str,
) -> Result<Option<String>>
pub fn get_password_for_background( &self, account: &str, ) -> Result<Option<String>>
Like Self::get_password, but returns [Ok(None)] when Self::availability is KeyringAvailability::Locked
(intended for background sync without treating lock as a hard error).
Sourcepub fn get_bytes(&self, account: &str) -> Result<Option<Vec<u8>>>
pub fn get_bytes(&self, account: &str) -> Result<Option<Vec<u8>>>
Decodes Base64 from Self::get_password; returns None if missing.
Sourcepub fn get_bytes_for_background(&self, account: &str) -> Result<Option<Vec<u8>>>
pub fn get_bytes_for_background(&self, account: &str) -> Result<Option<Vec<u8>>>
Like Self::get_bytes, but returns [Ok(None)] when the keychain is locked (Self::get_password_for_background).
Sourcepub fn delete(&self, account: &str) -> Result<()>
pub fn delete(&self, account: &str) -> Result<()>
Deletes the credential if present; missing entries are treated as success.
Sourcepub fn exists_nonempty(&self, account: &str) -> Result<bool>
pub fn exists_nonempty(&self, account: &str) -> Result<bool>
true if a non-empty password exists for account.
Sourcepub fn exists_nonempty_for_background(&self, account: &str) -> Result<bool>
pub fn exists_nonempty_for_background(&self, account: &str) -> Result<bool>
Like Self::exists_nonempty, but returns false when the keychain is locked.
Sourcepub fn account_raw(
&self,
snapshot_path: &str,
client: &BytesDto,
suffix: &str,
) -> String
pub fn account_raw( &self, snapshot_path: &str, client: &BytesDto, suffix: &str, ) -> String
Stable account id for an unstructured secret key under a snapshot + client namespace.
§Example
use tauri_plugin_keyring_store::{BytesDto, KeyringStore};
let store = KeyringStore::new("com.example.app");
let client = BytesDto::Text("cli".into());
let account = store.account_raw("/data/main", &client, "token");
assert!(account.starts_with("kp:v1:"));Trait Implementations§
Source§impl Clone for KeyringStore
impl Clone for KeyringStore
Source§fn clone(&self) -> KeyringStore
fn clone(&self) -> KeyringStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more