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 client: self.client.clone(),
52 }
53 }
54
55 pub fn collections(&self) -> CollectionsClient {
60 CollectionsClient::from_client(&self.client)
61 }
62
63 pub fn cipher_risk(&self) -> CipherRiskClient {
65 CipherRiskClient {
66 client: self.client.clone(),
67 }
68 }
69}
70
71#[allow(missing_docs)]
72pub trait VaultClientExt {
73 fn vault(&self) -> VaultClient;
74}
75
76impl VaultClientExt for Client {
77 fn vault(&self) -> VaultClient {
78 VaultClient::new(self.clone())
79 }
80}