Expand description
Configurable JavaScript runtime for WebAssembly.
Example usage:
let runtime = Runtime::default();
let context = runtime.context();
context
.global_object()
.unwrap()
.set_property(
"print",
context
.wrap_callback(move |_ctx, _this, args| {
let str = args
.first()
.ok_or(anyhow!("Need to pass an argument"))?
.to_string();
println!("{str}");
Ok(JSValue::Undefined)
})
.unwrap(),
)
.unwrap();
context.eval_global("hello.js", "print('hello!');").unwrap();
§Core concepts
§Features
export_alloc_fns
- exportsalloc::canonical_abi_realloc
andalloc::canonical_abi_free
from generated WebAssembly for allocating and freeing memoryjson
- functions for converting betweenquickjs::JSValueRef
and JSON byte slicesmessagepack
- functions for converting betweenquickjs::JSValueRef
and MessagePack byte slices
Re-exports§
pub use quickjs_wasm_rs as quickjs;
Modules§
Structs§
- A configuration for
Runtime
. - A JavaScript Runtime.