bitwarden_vault/
vault_client.rs1use bitwarden_core::Client;
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{
6 AttachmentsClient, CiphersClient, FoldersClient, PasswordHistoryClient, TotpClient,
7 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 {
35 client: self.client.clone(),
36 }
37 }
38
39 pub fn ciphers(&self) -> CiphersClient {
41 CiphersClient {
42 client: self.client.clone(),
43 }
44 }
45
46 pub fn folders(&self) -> FoldersClient {
48 FoldersClient {
49 client: self.client.clone(),
50 }
51 }
52
53 pub fn totp(&self) -> TotpClient {
55 TotpClient {
56 client: self.client.clone(),
57 }
58 }
59
60 pub fn collections(&self) -> CollectionsClient {
62 CollectionsClient {
63 client: self.client.clone(),
64 }
65 }
66}
67
68#[allow(missing_docs)]
69pub trait VaultClientExt {
70 fn vault(&self) -> VaultClient;
71}
72
73impl VaultClientExt for Client {
74 fn vault(&self) -> VaultClient {
75 VaultClient::new(self.clone())
76 }
77}