https://github.com/royalicing/orbwasmtime
Run WebAssembly in Elixir via Wasmtime
https://github.com/royalicing/orbwasmtime
Last synced: 6 months ago
JSON representation
Run WebAssembly in Elixir via Wasmtime
- Host: GitHub
- URL: https://github.com/royalicing/orbwasmtime
- Owner: RoyalIcing
- License: bsd-3-clause
- Created: 2023-06-22T07:34:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-27T10:54:01.000Z (almost 2 years ago)
- Last Synced: 2025-05-08T21:29:07.102Z (about 1 year ago)
- Language: Elixir
- Homepage:
- Size: 3.21 MB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OrbWasmtime
Run WebAssembly modules in Elixir via Rust & Wasmtime.
**Note: this project is in alpha and will change. For another WebAssembly runtime for Elixir [check out Wasmex](https://github.com/tessi/wasmex).**
## Installation
Add `orb_wasmtime` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:orb_wasmtime, "~> 0.1.2"}
]
end
```
## About
OrbWasmtime lets you run WebAssembly modules. You can call functions, list exports, pass imports, get/set globals, and read/write memory.
```elixir
defmodule Example do
alias OrbWasmtime.Instance
def run() do
inst = Instance.run(example_wat())
add = Instance.capture(inst, :add, 2)
add.(2, 3) # 5
add.(4, 5) # 9
end
defp example_wat() do
"""
(module $Add
(func (export "add") (param $a i32) (param $b i32) (result i32)
(i32.add (local.get $a) (local.get $b))
)
)
"""
end
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at .
## Releasing
```bash
git tag v0.x.x
git push --tags
# Wait for GitHub Action to succeed
mix rustler_precompiled.download OrbWasmtime.Rust --all --print --ignore-unavailable
rm -rf native/orb_wasmtime/target/
mix hex.publish
```