bitwarden_vault/
vault_client.rs1use bitwarden_collections::collection_client::CollectionsClient;
2use bitwarden_core::{Client, FromClient};
3#[cfg(feature = "wasm")]
4use wasm_bindgen::prelude::*;
5
6use crate::{
7 AttachmentsClient, CipherRiskClient, CiphersClient, FoldersClient, PasswordHistoryClient,
8 TotpClient,
9};
10
11#[allow(missing_docs)]
12#[derive(Clone)]
13#[cfg_attr(feature = "wasm", wasm_bindgen)]
14pub struct VaultClient {
15 pub(crate) client: Client,
16}
17
18impl VaultClient {
19 fn new(client: Client) -> Self {
20 Self { client }
21 }
22
23 pub fn password_history(&self) -> PasswordHistoryClient {
25 PasswordHistoryClient {
26 client: self.client.clone(),
27 }
28 }
29}
30
31#[cfg_attr(feature = "wasm", wasm_bindgen)]
32impl VaultClient {
33 pub fn attachments(&self) -> AttachmentsClient {
35 AttachmentsClient::from_client(&self.client)
36 }
37
38 pub fn ciphers(&self) -> CiphersClient {
40 CiphersClient::from_client(&self.client)
41 }
42
43 pub fn folders(&self) -> FoldersClient {
45 FoldersClient::from_client(&self.client)
46 }
47
48 pub fn totp(&self) -> TotpClient {
50 TotpClient
51 }
52
53 pub fn collections(&self) -> CollectionsClient {
58 CollectionsClient::from_client(&self.client)
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}