Skip to main content

bitwarden_uniffi/
managed_settings.rs

1use bitwarden_managed_settings::ManagedSettingsClient;
2use bitwarden_managed_settings_types::ManagementProfile;
3
4/// UniFFI wrapper for [`ManagedSettingsClient`].
5///
6/// The host application constructs one of these at boot, acquires a management profile from the
7/// operating system's Unified Endpoint Management channel, and pushes it in with
8/// [`update_profile`](ManagedSettingsBindingClient::update_profile).
9#[derive(uniffi::Object)]
10pub struct ManagedSettingsBindingClient(pub(crate) ManagedSettingsClient);
11
12impl Default for ManagedSettingsBindingClient {
13    fn default() -> Self {
14        Self::new()
15    }
16}
17
18#[uniffi::export]
19impl ManagedSettingsBindingClient {
20    /// Fresh handle with no active profile.
21    #[uniffi::constructor]
22    pub fn new() -> Self {
23        Self(ManagedSettingsClient::new())
24    }
25
26    /// Replace the active profile. Clear the profile with `None`.
27    pub fn update_profile(&self, profile: Option<ManagementProfile>) {
28        self.0.update_profile(profile);
29    }
30
31    /// Returns `true` if `key` is present in the active profile.
32    pub fn is_managed(&self, key: String) -> bool {
33        self.0.is_managed(key)
34    }
35
36    /// Raw JSON-encoded value for `key`, if a value is present.
37    pub fn get(&self, key: String) -> Option<String> {
38        self.0.get(key)
39    }
40}