bitwarden_uniffi/vault/
mod.rsuse std::sync::Arc;
use bitwarden_vault::{CipherListView, TotpResponse, VaultClientExt};
use chrono::{DateTime, Utc};
use crate::{
error::{Error, Result},
Client,
};
pub mod attachments;
pub mod ciphers;
pub mod collections;
pub mod folders;
pub mod password_history;
#[derive(uniffi::Object)]
pub struct VaultClient(pub(crate) Arc<Client>);
#[uniffi::export]
impl VaultClient {
pub fn folders(self: Arc<Self>) -> Arc<folders::ClientFolders> {
Arc::new(folders::ClientFolders(self.0.clone()))
}
pub fn collections(self: Arc<Self>) -> Arc<collections::ClientCollections> {
Arc::new(collections::ClientCollections(self.0.clone()))
}
pub fn ciphers(self: Arc<Self>) -> Arc<ciphers::ClientCiphers> {
Arc::new(ciphers::ClientCiphers(self.0.clone()))
}
pub fn password_history(self: Arc<Self>) -> Arc<password_history::ClientPasswordHistory> {
Arc::new(password_history::ClientPasswordHistory(self.0.clone()))
}
pub fn attachments(self: Arc<Self>) -> Arc<attachments::ClientAttachments> {
Arc::new(attachments::ClientAttachments(self.0.clone()))
}
pub fn generate_totp(&self, key: String, time: Option<DateTime<Utc>>) -> Result<TotpResponse> {
Ok(self
.0
.0
.vault()
.generate_totp(key, time)
.map_err(Error::Totp)?)
}
pub fn generate_totp_cipher_view(
&self,
view: CipherListView,
time: Option<DateTime<Utc>>,
) -> Result<TotpResponse> {
Ok(self
.0
.0
.vault()
.generate_totp_cipher_view(view, time)
.map_err(Error::Totp)?)
}
}