quickjspp-rs
This is a fork of quickjs-rs but replaces the binding to the original quickjs by Fabrice Bellard with its fork quickjspp by Andrew Fedoniouk, which is MSVC compatible/compileable.
QuickJS is a new, small Javascript engine by Fabrice Bellard and Charlie Gordon. It is fast and supports the full ES2020 specification.
QuickJSpp is a fork of Quickjs By Andrew Fedoniouk (a.k.a. c-smile).
This crate allows you to easily run and integrate with Javascript code from Rust.
Quickstart
[]
= "0.5.0"
use ;
let context = new.unwrap;
// Eval.
let value = context.eval.unwrap;
assert_eq!;
let value = context..unwrap;
assert_eq!;
// Callbacks.
context.add_callback.unwrap;
context.eval.unwrap;
Optional Features
The crate supports the following features:
-
serde: (default enabled). enable serde methodfrom_jsandto_jsto transform between Rust types and js value in quickjs context. It should compatible withserde_jsonbut not tested yet. See more on the example. -
chrono: chrono integration- adds a
JsValue::Datevariant that can be (de)serialized to/from a JSDate
- adds a
-
bigint: arbitrary precision integer support via num-bigint -
log: allows forwardingconsole.logmessages to thelogcrate. Note: must be enabled withContextBuilder::console(quickjspp::console::LogConsole); -
patchedEnabled automatically for some other features, likebigint. You should not need to enable this manually. Applies QuickJS patches that can be found inlibquickjs-sys/embed/patchesdirectory.
Installation
By default, quickjs is bundled with the libquickjs-sys crate and
automatically compiled, assuming you have the appropriate dependencies.
Windows Support
quickjspp-rs can be used under target x86_64-pc-windows-msvc,
System installation
To use the system installation, without the bundled feature, first install the required dependencies, and then compile and install quickjspp.
You then need to disable the bundled feature in the libquickjs-sys crate to
force using the system version.