[−][src]Crate rquickjs
High-level bindings to quickjs
The quickrjs
crate provides safe high-level bindings to the quickjs javascript engine. This crate is heavily inspired by the rlua crate. # The Runtime
and Context
objects The main entry point of this library is the Runtime
struct.
It represents the interperter state and is used to create Context
objects. As the quickjs library does not support threading the runtime is locked behind a
mutex. Multiple threads cannot run as script or create objects from the same runtime at the
same time.
The Context
object represents a global environment and a stack. Contexts of the same runtime
can share javascript objects like in browser between frames of the same origin.
Converting Values
This library has multiple traits for converting to and from javascript.
The ToJs
, ToJsMulti
traits are used for taking rust values
and turning them into javascript values.
ToJsMulti
is specificly used for place where a specific number of values
need to be converted to javascript like for example the arguments of functions.
FromJs
is for converting javascript value to rust.
Note that this trait does some automatic coercion.
For values which represent the name of variables or indecies the
trait ToAtom
is available to convert values to the represention
quickjs requires.
Modules
function |
Macros
static_fn | Implements StaticFn for a function |
Structs
Array | Rust representation of a javascript object optimized as an array. |
Atom | An atom is value representing the name of a variable of an objects and can be created from any javascript value. |
Context | A single execution context with its own global variables and stack. |
ContextBuilder | Used for building a |
Ctx | Context in use, passed to |
ExportList | An iterator over the items exported out a module |
Function | Rust representation of a javascript function. |
Module | Javascript module with certain exports and imports |
MultiValue | An list of Js values. |
Object | Rust representation of a javascript object. |
RegisteryKey | Key for a registery of a context. |
Runtime | Quickjs runtime, entry point of the library. |
String | Rust representation of a javascript string. |
Symbol | Rust representation of a javascript symbol. |
ValueIter | An iterator over a list of js values |
Enums
Error | Error type of the library. |
Value | Any javascript value. |
Traits
FromJs | For converting javascript values to rust values |
FromJsMulti | For converting multiple of value to javascript |
MultiWith | A trait for using multiple contexts at the same time. |
ToAtom | Trait for converting values to atoms. |
ToJs | For converting rust values to javascript values |
ToJsMulti | For converting multiple of value to javascript Mostly used for converting the arguments of a function from rust to javascript |
Type Definitions
Result | Result type used throught the library. |