core_crypto_ffi/
metadata.rs1#[cfg(target_family = "wasm")]
2use wasm_bindgen::prelude::*;
3
4const VERSION: &str = env!("CARGO_PKG_VERSION");
5
6#[cfg_attr(not(target_family = "wasm"), uniffi::export)]
7#[cfg_attr(target_family = "wasm", wasm_bindgen)]
8#[inline]
9pub fn version() -> String {
10 VERSION.to_string()
11}
12
13#[cfg(not(target_family = "wasm"))]
19#[derive(uniffi::Record)]
20pub struct BuildMetadata {
22 pub timestamp: String,
24 pub cargo_debug: String,
26 pub cargo_features: String,
28 pub opt_level: String,
30 pub target_triple: String,
32 pub git_branch: String,
34 pub git_describe: String,
36 pub git_sha: String,
38 pub git_dirty: String,
40}
41
42#[cfg(target_family = "wasm")]
44#[wasm_bindgen(inspectable)]
45pub struct BuildMetadata {
46 #[wasm_bindgen(readonly)]
48 pub timestamp: &'static str,
49 #[wasm_bindgen(readonly, js_name = "cargoDebug")]
51 pub cargo_debug: &'static str,
52 #[wasm_bindgen(readonly, js_name = "cargoFeatures")]
54 pub cargo_features: &'static str,
55 #[wasm_bindgen(readonly, js_name = "optLevel")]
57 pub opt_level: &'static str,
58 #[wasm_bindgen(readonly, js_name = "targetTriple")]
60 pub target_triple: &'static str,
61 #[wasm_bindgen(readonly, js_name = "gitBranch")]
63 pub git_branch: &'static str,
64 #[wasm_bindgen(readonly, js_name = "gitDescribe")]
66 pub git_describe: &'static str,
67 #[wasm_bindgen(readonly, js_name = "gitSha")]
69 pub git_sha: &'static str,
70 #[wasm_bindgen(readonly, js_name = "gitDirty")]
72 pub git_dirty: &'static str,
73}
74
75#[cfg_attr(not(target_family = "wasm"), uniffi::export)]
77#[cfg_attr(target_family = "wasm", wasm_bindgen)]
78#[inline]
79pub fn build_metadata() -> BuildMetadata {
80 BuildMetadata {
81 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
82 timestamp: core_crypto::BUILD_METADATA.timestamp.into(),
83 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
84 cargo_debug: core_crypto::BUILD_METADATA.cargo_debug.into(),
85 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
86 cargo_features: core_crypto::BUILD_METADATA.cargo_features.into(),
87 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
88 opt_level: core_crypto::BUILD_METADATA.opt_level.into(),
89 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
90 target_triple: core_crypto::BUILD_METADATA.target_triple.into(),
91 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
92 git_branch: core_crypto::BUILD_METADATA.git_branch.into(),
93 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
94 git_describe: core_crypto::BUILD_METADATA.git_describe.into(),
95 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
96 git_sha: core_crypto::BUILD_METADATA.git_sha.into(),
97 #[cfg_attr(target_family = "wasm", expect(clippy::useless_conversion))]
98 git_dirty: core_crypto::BUILD_METADATA.git_dirty.into(),
99 }
100}
101
102#[cfg(target_family = "wasm")]
103impl crate::CoreCrypto {
104 pub fn version() -> String {
106 version()
107 }
108
109 pub fn build_metadata() -> BuildMetadata {
111 build_metadata()
112 }
113}