bitwarden_core/platform/
state_client.rs

1use std::sync::Arc;
2
3use bitwarden_state::repository::{Repository, RepositoryItem};
4
5use crate::Client;
6
7/// Wrapper for state specific functionality.
8pub struct StateClient {
9    pub(crate) client: Client,
10}
11
12impl StateClient {
13    /// Register a client managed state repository for a specific type.
14    pub fn register_client_managed<T: 'static + Repository<V>, V: RepositoryItem>(
15        &self,
16        store: Arc<T>,
17    ) {
18        self.client
19            .internal
20            .repository_map
21            .register_client_managed(store)
22    }
23
24    /// Get a client managed state repository for a specific type, if it exists.
25    pub fn get_client_managed<T: RepositoryItem>(&self) -> Option<Arc<dyn Repository<T>>> {
26        self.client.internal.repository_map.get_client_managed()
27    }
28}