bitwarden_exporters/
exporter_client.rs1use bitwarden_core::Client;
2use bitwarden_vault::{Cipher, Collection, Folder};
3#[cfg(feature = "wasm")]
4use wasm_bindgen::prelude::*;
5
6use crate::{
7 export::{export_cxf, export_organization_vault, export_vault, import_cxf},
8 Account, ExportError, ExportFormat,
9};
10
11#[allow(missing_docs)]
12#[cfg_attr(feature = "wasm", wasm_bindgen)]
13pub struct ExporterClient {
14 client: Client,
15}
16
17#[cfg_attr(feature = "wasm", wasm_bindgen)]
18impl ExporterClient {
19 fn new(client: Client) -> Self {
20 Self { client }
21 }
22
23 #[allow(missing_docs)]
24 pub fn export_vault(
25 &self,
26 folders: Vec<Folder>,
27 ciphers: Vec<Cipher>,
28 format: ExportFormat,
29 ) -> Result<String, ExportError> {
30 export_vault(&self.client, folders, ciphers, format)
31 }
32
33 #[allow(missing_docs)]
34 pub fn export_organization_vault(
35 &self,
36 collections: Vec<Collection>,
37 ciphers: Vec<Cipher>,
38 format: ExportFormat,
39 ) -> Result<String, ExportError> {
40 export_organization_vault(collections, ciphers, format)
41 }
42
43 pub fn export_cxf(
50 &self,
51 account: Account,
52 ciphers: Vec<Cipher>,
53 ) -> Result<String, ExportError> {
54 export_cxf(&self.client, account, ciphers)
55 }
56
57 pub fn import_cxf(&self, payload: String) -> Result<Vec<Cipher>, ExportError> {
64 import_cxf(&self.client, payload)
65 }
66}
67
68#[allow(missing_docs)]
69pub trait ExporterClientExt {
70 fn exporters(&self) -> ExporterClient;
71}
72
73impl ExporterClientExt for Client {
74 fn exporters(&self) -> ExporterClient {
75 ExporterClient::new(self.clone())
76 }
77}