bitwarden_uniffi/vault/
collections.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::sync::Arc;

use bitwarden_vault::{Collection, CollectionView, VaultClientExt};

use crate::{error::Error, Client, Result};

#[derive(uniffi::Object)]
pub struct ClientCollections(pub Arc<Client>);

#[uniffi::export]
impl ClientCollections {
    /// Decrypt collection
    pub fn decrypt(&self, collection: Collection) -> Result<CollectionView> {
        Ok(self
            .0
             .0
            .vault()
            .collections()
            .decrypt(collection)
            .map_err(Error::Decrypt)?)
    }

    /// Decrypt collection list
    pub fn decrypt_list(&self, collections: Vec<Collection>) -> Result<Vec<CollectionView>> {
        Ok(self
            .0
             .0
            .vault()
            .collections()
            .decrypt_list(collections)
            .map_err(Error::Decrypt)?)
    }
}