bitwarden_vault/
vault_client.rs1use bitwarden_collections::collection_client::CollectionsClient;
2use bitwarden_core::{Client, FromClient};
3
4use crate::{
5 AttachmentsClient, CipherRiskClient, CiphersClient, FoldersClient, PasswordHistoryClient,
6 TotpClient,
7};
8
9#[allow(missing_docs)]
10#[derive(Clone)]
11#[bitwarden_ffi::wasm_object]
12pub struct VaultClient {
13 pub(crate) client: Client,
14}
15
16impl VaultClient {
17 fn new(client: Client) -> Self {
18 Self { client }
19 }
20
21 pub fn password_history(&self) -> PasswordHistoryClient {
23 PasswordHistoryClient {
24 client: self.client.clone(),
25 }
26 }
27}
28
29#[bitwarden_ffi::wasm_export]
30impl VaultClient {
31 pub fn attachments(&self) -> AttachmentsClient {
33 AttachmentsClient::from_client(&self.client)
34 }
35
36 pub fn ciphers(&self) -> CiphersClient {
38 CiphersClient::from_client(&self.client)
39 }
40
41 pub fn folders(&self) -> FoldersClient {
43 FoldersClient::from_client(&self.client)
44 }
45
46 pub fn totp(&self) -> TotpClient {
48 TotpClient
49 }
50
51 pub fn collections(&self) -> CollectionsClient {
56 CollectionsClient::from_client(&self.client)
57 }
58
59 pub fn cipher_risk(&self) -> CipherRiskClient {
61 CipherRiskClient {
62 client: self.client.clone(),
63 }
64 }
65}
66
67#[allow(missing_docs)]
68pub trait VaultClientExt {
69 fn vault(&self) -> VaultClient;
70}
71
72impl VaultClientExt for Client {
73 fn vault(&self) -> VaultClient {
74 VaultClient::new(self.clone())
75 }
76}