tauri_plugin_keyring_store/plugin.rs
1//! Managed application state for the plugin (`KeyringStore` + open snapshot sessions).
2//!
3//! Obtain it from any [`tauri::Manager`] via [`crate::KeyringExt::keyring`].
4
5use std::sync::Arc;
6
7use crate::store::{KeyringStore, SessionRegistry};
8
9/// Root plugin state registered with Tauri ([`tauri::Manager::manage`]).
10pub struct KeyringPlugin {
11 /// Shared OS keyring accessor for the configured service name.
12 pub store: Arc<KeyringStore>,
13 /// Snapshot paths that have been initialized for this process (Stronghold-compatible session ids).
14 pub sessions: SessionRegistry,
15}
16
17impl KeyringPlugin {
18 /// Builds plugin state; normally done inside [`crate::Builder::build`].
19 pub fn new(service: impl Into<String>) -> Self {
20 Self {
21 store: Arc::new(KeyringStore::new(service)),
22 sessions: SessionRegistry::default(),
23 }
24 }
25}