bitwarden_vault/
vault_client.rs1use bitwarden_core::{Client, FromClient};
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{
6 AttachmentsClient, CipherRiskClient, CiphersClient, FoldersClient, PasswordHistoryClient,
7 TotpClient, collection_client::CollectionsClient,
8};
9
10#[allow(missing_docs)]
11#[derive(Clone)]
12#[cfg_attr(feature = "wasm", wasm_bindgen)]
13pub struct VaultClient {
14 pub(crate) client: Client,
15}
16
17impl VaultClient {
18 fn new(client: Client) -> Self {
19 Self { client }
20 }
21
22 pub fn password_history(&self) -> PasswordHistoryClient {
24 PasswordHistoryClient {
25 client: self.client.clone(),
26 }
27 }
28}
29
30#[cfg_attr(feature = "wasm", wasm_bindgen)]
31impl VaultClient {
32 pub fn attachments(&self) -> AttachmentsClient {
34 AttachmentsClient::from_client(&self.client)
35 }
36
37 pub fn ciphers(&self) -> CiphersClient {
39 CiphersClient::from_client(&self.client)
40 }
41
42 pub fn folders(&self) -> FoldersClient {
44 FoldersClient::from_client(&self.client)
45 }
46
47 pub fn totp(&self) -> TotpClient {
49 TotpClient {
50 client: self.client.clone(),
51 }
52 }
53
54 pub fn collections(&self) -> CollectionsClient {
56 CollectionsClient {
57 client: self.client.clone(),
58 }
59 }
60
61 pub fn cipher_risk(&self) -> CipherRiskClient {
63 CipherRiskClient {
64 client: self.client.clone(),
65 }
66 }
67}
68
69#[allow(missing_docs)]
70pub trait VaultClientExt {
71 fn vault(&self) -> VaultClient;
72}
73
74impl VaultClientExt for Client {
75 fn vault(&self) -> VaultClient {
76 VaultClient::new(self.clone())
77 }
78}