From 925180e2dcb2b95cb2777a75e1491499c0d69936 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Fri, 5 Apr 2024 16:40:12 -0500 Subject: Add rust Signed-off-by: Matt Strapp --- libs/zora-rs/src/lib.rs | 13 +++++++++++++ libs/zora-rs/src/utils.rs | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 libs/zora-rs/src/lib.rs create mode 100644 libs/zora-rs/src/utils.rs (limited to 'libs/zora-rs/src') diff --git a/libs/zora-rs/src/lib.rs b/libs/zora-rs/src/lib.rs new file mode 100644 index 0000000..239f3af --- /dev/null +++ b/libs/zora-rs/src/lib.rs @@ -0,0 +1,13 @@ +mod utils; + +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + fn alert(s: &str); +} + +#[wasm_bindgen] +pub fn greet() { + alert("Hello, zora-rs!"); +} diff --git a/libs/zora-rs/src/utils.rs b/libs/zora-rs/src/utils.rs new file mode 100644 index 0000000..b1d7929 --- /dev/null +++ b/libs/zora-rs/src/utils.rs @@ -0,0 +1,10 @@ +pub fn set_panic_hook() { + // When the `console_error_panic_hook` feature is enabled, we can call the + // `set_panic_hook` function at least once during initialization, and then + // we will get better error messages if our code ever panics. + // + // For more details see + // https://github.com/rustwasm/console_error_panic_hook#readme + #[cfg(feature = "console_error_panic_hook")] + console_error_panic_hook::set_once(); +} -- cgit v1.2.3