Created
June 28, 2021 18:47
-
-
Save laverdet/d738fb3fa184d9ec4a4645605c593c4d to your computer and use it in GitHub Desktop.
Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "loop" | |
version = "0.0.1" | |
edition = "2018" | |
[lib] | |
crate-type = [ "cdylib" ] | |
[dependencies] | |
chrono = "0.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Goes in `src` folder | |
// brew install wasmtime | |
// cargo install cargo-wasi | |
#[link(wasm_import_module = "./binding.js")] | |
extern "C" { | |
#[link_name="getTime"] fn get_time() -> i32; | |
} | |
#[no_mangle] | |
pub unsafe extern "C" fn r#loop() { | |
println!("Starting tick[{}] @ {:?}", get_time(), chrono::offset::Local::now()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment