bitwarden_vault/
vault_client.rs1use bitwarden_core::Client;
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{
6 collection_client::CollectionsClient,
7 sync::{sync, SyncError},
8 AttachmentsClient, CiphersClient, FoldersClient, PasswordHistoryClient, SyncRequest,
9 SyncResponse, TotpClient,
10};
11
12#[allow(missing_docs)]
13#[derive(Clone)]
14#[cfg_attr(feature = "wasm", wasm_bindgen)]
15pub struct VaultClient {
16 pub(crate) client: Client,
17}
18
19impl VaultClient {
20 fn new(client: Client) -> Self {
21 Self { client }
22 }
23
24 #[allow(missing_docs)]
25 pub async fn sync(&self, input: &SyncRequest) -> Result<SyncResponse, SyncError> {
26 sync(&self.client, input).await
27 }
28
29 pub fn password_history(&self) -> PasswordHistoryClient {
31 PasswordHistoryClient {
32 client: self.client.clone(),
33 }
34 }
35}
36
37#[cfg_attr(feature = "wasm", wasm_bindgen)]
38impl VaultClient {
39 pub fn attachments(&self) -> AttachmentsClient {
41 AttachmentsClient {
42 client: self.client.clone(),
43 }
44 }
45
46 pub fn ciphers(&self) -> CiphersClient {
48 CiphersClient {
49 client: self.client.clone(),
50 }
51 }
52
53 pub fn folders(&self) -> FoldersClient {
55 FoldersClient {
56 client: self.client.clone(),
57 }
58 }
59
60 pub fn totp(&self) -> TotpClient {
62 TotpClient {
63 client: self.client.clone(),
64 }
65 }
66
67 pub fn collections(&self) -> CollectionsClient {
69 CollectionsClient {
70 client: self.client.clone(),
71 }
72 }
73}
74
75#[allow(missing_docs)]
76pub trait VaultClientExt {
77 fn vault(&self) -> VaultClient;
78}
79
80impl VaultClientExt for Client {
81 fn vault(&self) -> VaultClient {
82 VaultClient::new(self.clone())
83 }
84}