1#[macro_export]
18macro_rules! proteus_impl {
19 ($errcode_dest:expr => $body:block or throw $err_type:ty) => {{
20 cfg_if::cfg_if! {
21 if #[cfg(feature = "proteus")] {
22 #[allow(clippy::redundant_closure_call)]
23 let result = (async move { $body }).await;
24
25 cfg_if::cfg_if! {
26 if #[cfg(target_family = "wasm")] {
27 if let Err(CoreCryptoError($crate::InternalError::ProteusError(err))) = &result {
28 let err_code = err.error_code();
29 let mut ec = $errcode_dest.write().await;
30 *ec = err_code;
31 }
32
33 result
34 } else {
35 if let Err(CoreCryptoError::Proteus(err)) = &result {
36 let err_code = err.error_code();
37 $errcode_dest.store(err_code, std::sync::atomic::Ordering::SeqCst);
38 }
39
40 result
41 }
42 }
43 } else {
44 return <$err_type>::Err(core_crypto::CryptoError::ProteusSupportNotEnabled("proteus".into()).into());
45 }
46 }
47 }};
48 ($body:block or throw $err_type:ty) => {{
49 cfg_if::cfg_if! {
50 if #[cfg(feature = "proteus")] {
51 $body
52 } else {
53 return <$err_type>::Err(core_crypto::CryptoError::ProteusSupportNotEnabled("proteus".into()).into());
54 }
55 }
56 }};
57
58 ($body:block) => {
59 proteus_impl!($body or throw ::std::result::Result<_, _>)
60 };
61
62 ($errcode_dest:expr => $body:block) => {
63 proteus_impl!($errcode_dest => $body or throw ::std::result::Result<_, _>)
64 };
65}
66
67cfg_if::cfg_if! {
68 if #[cfg(target_family = "wasm")] {
69 mod wasm;
70 pub use self::wasm::*;
71 } else {
72 uniffi::setup_scaffolding!("core_crypto_ffi");
73
74 mod generic;
75 pub use self::generic::*;
76 }
77}
78
79#[cfg(doc)]
80pub mod bindings;