bitwarden_importers/
importer_client.rs1use bitwarden_core::Client;
2#[cfg(feature = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{ImportError, ImportOptions, ImportSummary, import::import_kdbx};
6
7#[allow(missing_docs)]
8#[cfg_attr(feature = "wasm", wasm_bindgen)]
9pub struct ImporterClient {
10 client: Client,
11}
12
13#[cfg_attr(feature = "wasm", wasm_bindgen)]
14impl ImporterClient {
15 fn new(client: Client) -> Self {
16 Self { client }
17 }
18
19 pub async fn import_kdbx(
26 &self,
27 file: Vec<u8>,
28 password: Option<String>,
29 key_file: Option<Vec<u8>>,
30 options: ImportOptions,
31 ) -> Result<ImportSummary, ImportError> {
32 import_kdbx(&self.client, file, password, key_file, options).await
33 }
34}
35
36#[allow(missing_docs)]
37pub trait ImporterClientExt {
38 fn importers(&self) -> ImporterClient;
39}
40
41impl ImporterClientExt for Client {
42 fn importers(&self) -> ImporterClient {
43 ImporterClient::new(self.clone())
44 }
45}