5 releases
0.1.4 | Jan 24, 2023 |
---|---|
0.1.3 | Jan 5, 2023 |
0.1.2 | Aug 9, 2022 |
0.1.1 | Jul 29, 2022 |
0.1.0 | Mar 14, 2022 |
#209 in WebAssembly
74 downloads per month
3MB
89K
SLoC
quickjs-wasm-rs
High-level bindings and serializers for a Wasm build of QuickJS.
Bindings
Context
corresponds to a QuickJS JSContext
and Value
corresponds to a QuickJS JSValue
.
use quickjs_wasm_rs::Context;
let mut context = Context::default();
will create a new context.
Serializers
This crate provides optional transcoding features for converting between
serialization formats and Value
:
messagepack
providesquickjs_wasm_rs::messagepack
for msgpack, usingrmp_serde
.json
providesquickjs_wasm_rs::json
for JSON, usingserde_json
.
msgpack example:
use quickjs_wasm_rs::{messagepack, Context, Value};
let context = Context::default();
let input_bytes: &[u8] = ...;
let input_value = messagepack::transcode_input(&context, input_bytes).unwrap();
let output_value: Value = ...;
let output = messagepack::transcode_output(output_value).unwrap();
Building a project using this crate
- Install the wasi-sdk for your platform
- Set the
QUICKJS_WASM_SYS_WASI_SDK_PATH
environment variable to the absolute path where you installed thewasi-sdk
For example, if you install the wasi-sdk
in /opt/wasi-sdk
, you can run:
export QUICKJS_WASM_SYS_WASI_SDK_PATH=/opt/wasi-sdk
Publishing to crates.io
To publish this crate to crates.io, run ./publish.sh
.