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::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)?)
24 }
25
26 pub fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result<String> {
28 Ok(self.0.passphrase(settings)?)
29 }
30
31 pub async fn username(&self, settings: UsernameGeneratorRequest) -> Result<String> {
33 Ok(self.0.username(settings).await?)
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.0.export_vault(folders, ciphers, format)?)
50 }
51
52 pub fn export_organization_vault(
54 &self,
55 collections: Vec<Collection>,
56 ciphers: Vec<Cipher>,
57 format: ExportFormat,
58 ) -> Result<String> {
59 Ok(self
60 .0
61 .export_organization_vault(collections, ciphers, format)?)
62 }
63
64 pub fn export_cxf(&self, account: Account, ciphers: Vec<Cipher>) -> Result<String> {
71 Ok(self.0.export_cxf(account, ciphers)?)
72 }
73
74 pub fn import_cxf(&self, payload: String) -> Result<Vec<Cipher>> {
81 Ok(self.0.import_cxf(payload)?)
82 }
83}