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 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_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 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 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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KeyringStore
impl RefUnwindSafe for KeyringStore
impl Send for KeyringStore
impl Sync for KeyringStore
impl Unpin for KeyringStore
impl UnsafeUnpin for KeyringStore
impl UnwindSafe for KeyringStore
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