bitwarden_uniffi/tool/
mod.rs1use bitwarden_collections::collection::Collection;
2use bitwarden_exporters::{Account, ExportFormat};
3use bitwarden_generators::{
4 PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest,
5};
6use bitwarden_vault::{Cipher, Folder};
7
8use crate::error::{Error, Result};
9
10mod sends;
11pub use sends::SendClient;
12
13mod ssh;
14pub use ssh::SshClient;
15
16#[derive(uniffi::Object)]
17pub struct GeneratorClients(pub(crate) bitwarden_generators::GeneratorClient);
18
19#[uniffi::export(async_runtime = "tokio")]
20impl GeneratorClients {
21 pub fn password(&self, settings: PasswordGeneratorRequest) -> Result<String> {
23 Ok(self.0.password(settings).map_err(Error::Password)?)
24 }
25
26 pub fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result<String> {
28 Ok(self.0.passphrase(settings).map_err(Error::Passphrase)?)
29 }
30
31 pub async fn username(&self, settings: UsernameGeneratorRequest) -> Result<String> {
33 Ok(self.0.username(settings).await.map_err(Error::Username)?)
34 }
35}
36
37#[derive(uniffi::Object)]
38pub struct ExporterClient(pub(crate) bitwarden_exporters::ExporterClient);
39
40#[uniffi::export]
41impl ExporterClient {
42 pub fn export_vault(
44 &self,
45 folders: Vec<Folder>,
46 ciphers: Vec<Cipher>,
47 format: ExportFormat,
48 ) -> Result<String> {
49 Ok(self
50 .0
51 .export_vault(folders, ciphers, format)
52 .map_err(Error::Export)?)
53 }
54
55 pub fn export_organization_vault(
57 &self,
58 collections: Vec<Collection>,
59 ciphers: Vec<Cipher>,
60 format: ExportFormat,
61 ) -> Result<String> {
62 Ok(self
63 .0
64 .export_organization_vault(collections, ciphers, format)
65 .map_err(Error::Export)?)
66 }
67
68 pub fn export_cxf(&self, account: Account, ciphers: Vec<Cipher>) -> Result<String> {
75 Ok(self.0.export_cxf(account, ciphers).map_err(Error::Export)?)
76 }
77
78 pub fn import_cxf(&self, payload: String) -> Result<Vec<Cipher>> {
85 Ok(self.0.import_cxf(payload).map_err(Error::Export)?)
86 }
87}