You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Tait Hoyem 96365c02f4
Initial commit
8 months ago
src Initial commit 8 months ago
.gitignore Initial commit 8 months ago
Cargo.toml Initial commit 8 months ago
README.md Initial commit 8 months ago
index.html Initial commit 8 months ago

README.md

roll_lib

An example library to show how to set up Rust as a Webassembly module.

Building Instructions

To build the library, use the wasm-pack cargo extension. It can be installed with cargo install wasm-pack.

After installing, use wasm-pack build --release --target web to build the artifacts into the pkg directory.

Then, you can use WASM APIs in Javascript to use the library within Javascript. Note that you need the entire pkg/ directory available to your browser to have it function correctly.

<script type="module">
  import init, { roll } from "./pkg/roll_lib.js";
  init().then(() => {
    console.log(roll("1d20"));
  });
</script>

Since WASN files can not generally be loaded from file:// for security reasons, you can use python -m http.server to open a quick localhost server for testing.

Features

There is one function roll(string) -> string. It follows the format given in the README of the caith library. It may return an error or "Invalid format" if something goes wrong.