Skip to content

Instantly share code, notes, and snippets.

@laverdet
Created June 28, 2021 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laverdet/d738fb3fa184d9ec4a4645605c593c4d to your computer and use it in GitHub Desktop.
Save laverdet/d738fb3fa184d9ec4a4645605c593c4d to your computer and use it in GitHub Desktop.
Cargo.toml
[package]
name = "loop"
version = "0.0.1"
edition = "2018"
[lib]
crate-type = [ "cdylib" ]
[dependencies]
chrono = "0.4"
// 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