bitwarden_uniffi/vault/
mod.rs1use bitwarden_vault::{CipherListView, TotpResponse};
2use chrono::{DateTime, Utc};
3
4use crate::error::{Error, Result};
5
6pub mod attachments;
7pub mod ciphers;
8pub mod collections;
9pub mod folders;
10pub mod password_history;
11
12#[derive(uniffi::Object)]
13pub struct VaultClient(pub(crate) bitwarden_vault::VaultClient);
14
15#[uniffi::export]
16impl VaultClient {
17 pub fn folders(&self) -> folders::FoldersClient {
19 folders::FoldersClient(self.0.folders())
20 }
21
22 pub fn collections(&self) -> collections::CollectionsClient {
24 collections::CollectionsClient(self.0.collections())
25 }
26
27 pub fn ciphers(&self) -> ciphers::CiphersClient {
29 ciphers::CiphersClient(self.0.ciphers())
30 }
31
32 pub fn password_history(&self) -> password_history::PasswordHistoryClient {
34 password_history::PasswordHistoryClient(self.0.password_history())
35 }
36
37 pub fn attachments(&self) -> attachments::AttachmentsClient {
39 attachments::AttachmentsClient(self.0.attachments())
40 }
41
42 pub fn generate_totp(&self, key: String, time: Option<DateTime<Utc>>) -> Result<TotpResponse> {
49 Ok(self
50 .0
51 .totp()
52 .generate_totp(key, time)
53 .map_err(Error::Totp)?)
54 }
55
56 pub fn generate_totp_cipher_view(
58 &self,
59 view: CipherListView,
60 time: Option<DateTime<Utc>>,
61 ) -> Result<TotpResponse> {
62 Ok(self
63 .0
64 .totp()
65 .generate_totp_cipher_view(view, time)
66 .map_err(Error::Totp)?)
67 }
68}