bitwarden_uniffi/tool/
sends.rs1use std::path::Path;
2
3use bitwarden_send::{Send, SendListView, SendView};
4
5use crate::Result;
6
7#[derive(uniffi::Object)]
8pub struct SendClient(pub(crate) bitwarden_send::SendClient);
9
10#[uniffi::export]
11impl SendClient {
12 pub fn encrypt(&self, send: SendView) -> Result<Send> {
14 Ok(self.0.encrypt(send)?)
15 }
16
17 pub fn encrypt_buffer(&self, send: Send, buffer: Vec<u8>) -> Result<Vec<u8>> {
19 Ok(self.0.encrypt_buffer(send, &buffer)?)
20 }
21
22 pub fn encrypt_file(
24 &self,
25 send: Send,
26 decrypted_file_path: String,
27 encrypted_file_path: String,
28 ) -> Result<()> {
29 Ok(self.0.encrypt_file(
30 send,
31 Path::new(&decrypted_file_path),
32 Path::new(&encrypted_file_path),
33 )?)
34 }
35
36 pub fn decrypt(&self, send: Send) -> Result<SendView> {
38 Ok(self.0.decrypt(send)?)
39 }
40
41 pub fn decrypt_list(&self, sends: Vec<Send>) -> Result<Vec<SendListView>> {
43 Ok(self.0.decrypt_list(sends)?)
44 }
45
46 pub fn decrypt_buffer(&self, send: Send, buffer: Vec<u8>) -> Result<Vec<u8>> {
48 Ok(self.0.decrypt_buffer(send, &buffer)?)
49 }
50
51 pub fn decrypt_file(
53 &self,
54 send: Send,
55 encrypted_file_path: String,
56 decrypted_file_path: String,
57 ) -> Result<()> {
58 Ok(self.0.decrypt_file(
59 send,
60 Path::new(&encrypted_file_path),
61 Path::new(&decrypted_file_path),
62 )?)
63 }
64}