Crates.io | quickjs-wasm-rs |
lib.rs | quickjs-wasm-rs |
version | 3.1.0 |
source | src |
created_at | 2022-03-14 21:34:03.150211 |
updated_at | 2024-05-07 20:17:29.169715 |
description | High-level bindings and serializers for a Wasm build of QuickJS |
homepage | https://github.com/bytecodealliance/javy/tree/main/crates/quickjs-wasm-rs |
repository | https://github.com/bytecodealliance/javy/tree/main/crates/quickjs-wasm-rs |
max_upload_size | |
id | 550208 |
size | 135,033 |
The motivation for this change is explained in detail in https://github.com/bytecodealliance/javy/pull/618
We recommend using rquickjs
as the
high-level bindings for QuickJS.
High-level bindings and serializers for a Wasm build of QuickJS.
JSContextRef
corresponds to a QuickJS JSContext
and JSValueRef
corresponds to a QuickJS JSValue
.
use quickjs_wasm_rs::JSContextRef;
let mut context = JSContextRef::default();
will create a new context.
This crate provides optional transcoding features for converting between
serialization formats and JSValueRef
:
messagepack
provides quickjs_wasm_rs::messagepack
for msgpack, using rmp_serde
.json
provides quickjs_wasm_rs::json
for JSON, using serde_json
.msgpack example:
use quickjs_wasm_rs::{messagepack, JSContextRef, JSValueRef};
let context = JSContextRef::default();
let input_bytes: &[u8] = ...;
let input_value = messagepack::transcode_input(&context, input_bytes).unwrap();
let output_value: JSValueRef = ...;
let output = messagepack::transcode_output(output_value).unwrap();
To publish this crate to crates.io, run ./publish.sh
.
This crate can be compiled using a custom WASI SDK. When building this crate, set the QUICKJS_WASM_SYS_WASI_SDK_PATH
environment variable to the absolute path where you installed the SDK.