0.1
Build Rust functions for Deno.
Repository
Current version released
4 years ago
Versions
🦕
Build Rust functions for Deno
Usage:
You must have wasm-bindgen-cli
installed on your machine. To install run cargo install wasm-bindgen-cli
.
wasm-bindgen
to your project
Add In your cargo.toml
file, you need to specify the crate type
[lib]
crate-type = ["cdylib"]
under dependencies
add:
wasm-bindgen = "0.2"
Import wasm-bindgen
to your rust file:
use wasm_bindgen::prelude::*;
Add the macro to your functions:
#[wasm_bindgen]
pub fn my_awesome_function() -> String {
"This is from my awesome function in Rust!"
}
Install the script
deno install --allow-read --allow-write --allow-run -n deno-build-wasm https://raw.githubusercontent.com/meszarosdezso/deno-build-wasm/master/mod.ts
Build your functions
deno-build-wasm my-awesome-functions
This will generate a pkg
directory with the neccessary files.
Use your functions in Deno
import { my_awesome_function } from './pkg/my-awesome-functions.js'
console.log(my_awesome_function())
// Prints: This is from my awesome function in Rust!