core_crypto_ffi/
ephemeral.rs1#[cfg(target_family = "wasm")]
2use wasm_bindgen::prelude::*;
3
4use crate::{CoreCrypto, CoreCryptoError, CoreCryptoResult};
5use core_crypto::prelude::{CoreCrypto as CoreCryptoFfi, HistorySecret as HistorySecretFfi};
6
7pub type HistorySecret = Vec<u8>;
10
11async fn history_client_inner(history_secret: HistorySecret) -> CoreCryptoResult<CoreCrypto> {
12 let secret = rmp_serde::from_slice::<HistorySecretFfi>(&history_secret).map_err(CoreCryptoError::generic())?;
13 CoreCryptoFfi::history_client(secret)
14 .await
15 .map(|inner| CoreCrypto { inner })
16 .map_err(Into::into)
17}
18
19#[cfg(target_family = "wasm")]
20#[wasm_bindgen]
21impl CoreCrypto {
22 pub async fn history_client(history_secret: HistorySecret) -> CoreCryptoResult<Self> {
27 history_client_inner(history_secret).await
28 }
29}
30
31#[cfg(not(target_family = "wasm"))]
36#[uniffi::export]
37pub async fn core_crypto_history_client(history_secret: HistorySecret) -> CoreCryptoResult<CoreCrypto> {
38 history_client_inner(history_secret).await
39}