Skip to main content

Crate quickjs

Crate quickjs 

Source
Expand description

quickjs — an embeddable JavaScript engine written in pure Rust.

The crate is being built as a drop-in replacement for bellard/quickjs; the language level tracked is the upstream release whose version string is COMPAT_VERSION.

§Current state (M3)

Source is parsed, compiled to bytecode and executed: Context::eval runs a script and returns its completion value, and Context::output holds whatever print wrote.

let rt = quickjs::Runtime::new();
let mut ctx = quickjs::Context::new(&rt);
ctx.eval("print(1 + 1)").expect("runs");
assert_eq!(ctx.output(), "2\n");

Not there yet: the standard library beyond print, classes and generators, and modules. Those are later milestones (see docs/requirements.md).

Re-exports§

pub use interp::Interp;
pub use interp::Signal;
pub use object::Callable;
pub use object::JsObject;
pub use object::ObjectKind;
pub use object::Property;
pub use value::Cell;
pub use value::JsString;
pub use value::Value;
pub use js_compile;
pub use js_parse;

Modules§

builtins
The standard library: the globals a script reaches without an import.
interp
The bytecode interpreter.
object
The object model: property tables, arrays, functions, and the prototype chain.
value
JavaScript values, and the conversions between them.

Structs§

CollectStats
Statistics returned by Heap::collect.
Context
An execution context: a global object plus the builtins installed on it.
Gc
A strong, reference-counted handle to a heap value.
Heap
Owns the live-object registry for one JavaScript runtime.
Runtime
A JavaScript runtime: one heap, one memory limit, one set of host hooks.
Tracer
Visitor used by Trace implementations.
WeakGc
A non-owning handle to a heap value.

Enums§

Error
Error raised by the engine.

Constants§

COMPAT_VERSION
Version string of the upstream QuickJS release this port tracks.

Traits§

Trace
Types that may own Gc handles.

Type Aliases§

Result
Convenience alias used throughout the crate.