Skip to main content

Module core

Module core 

Source
Expand description

The embedding API over quickjs-oxide-core: one realm per runtime, values as Rust data or handles, the host as one trait, host functions with a Scope, module loaders with a ModuleScope.

Re-exports§

pub use crate::engine::api::error::Error;
pub use crate::engine::api::error::ErrorKind;
pub use crate::engine::api::error::NativeErrorKind;
pub use crate::engine::api::declare_thread_stack;
pub use crate::engine::api::number_to_string;
pub use crate::engine::api::quickjs_detect_module_bytes;

Structs§

CallableRef
An object reference known to be callable.
CompileOptions
Named source compilation options.
CompiledModule
A module compiled through a ModuleScope, to return from the loader.
Context
The runtime’s one realm.
CoreValue
The core’s value, which Host::promise_rejection receives. A JavaScript value, or the internal hole marker Value::EMPTY.
EvalOptions
Options of Context::eval_with_options.
FunctionBytecodeRef
A compiled script, run by Context::execute.
FunctionOptions
How a host function is made: its name and length, whether new may call it, and the values it captures (Scope::data). Captured values are traced by the collector; a Rust value the closure captures is not.
GcStats
The collector’s statistics.
HeapLimits
InterruptHandle
Interrupts a runtime’s running script from any thread: the script stops at its next poll (about every thousand loop back-edges and calls) with RuntimeError::Interrupted, uncatchable by the script. The flag stays set until InterruptHandle::clear, so every script after it is interrupted too.
JsBigInt
An ECMAScript BigInt using the same short/heap split as QuickJS.
JsString
ECMAScript strings are sequences of UTF-16 code units, not UTF-8 scalar values. Compact Latin-1/UTF-16 leaves and bounded ropes mirror QuickJS’s current representation while preserving lone surrogates.
MemoryReport
A runtime’s memory, part by part.
ModuleBytecodeRef
A compiled module, run by Context::execute_module.
ModuleImportAttribute
One decoded entry from a static import declaration’s with clause.
ModuleScope
A module loader’s view of the runtime: creating objects, errors, host functions and host objects, compiling a module source. It is the compile-time view (no job queue, no running script), so it has these operations and not those of Js. Values made through it are handles like any other and outlive the callback.
ObjectRef
A reference to an object of a runtime.
OrdinaryPropertyDescriptor
A property descriptor for [[DefineOwnProperty]], possibly partial.
PromiseCapability
A promise and its resolving functions (Js::new_promise). A host function returns promise at once and keeps the capability; when the embedder’s event arrives it settles the promise from the top level and drains the job queue.
PromiseSnapshot
A promise’s state and result, read without running JavaScript.
PropertyKey
A property key: a string, an array index or a symbol. Made by Runtime::intern_property_key or from a SymbolRef.
QjsHelpers
qjs’s helpers (Context::install_qjs_helpers).
Raw
The marker of a closure over the Scope alone.
Runtime
A runtime: one heap, one realm, one job queue. Cloning shares it.
RuntimeOptions
How a runtime is configured. Default is the behavior every runtime had before the options existed.
Scope
A host function’s view of the engine: its call, and every operation of Js. Values it hands out are handles like any other and outlive the call.
SymbolRef
A reference to a symbol of a runtime.
SystemHost
A default host over the process: its streams, the system clock, UTC. The default host: the process’s streams, the system clock, UTC.
TypedArrayView
A typed array’s window on its buffer (Js::typed_array_view).

Enums§

AccessorValue
A present get or set field: a function or undefined.
BigIntError
A failure produced by the BigInt value layer.
CompleteOrdinaryPropertyDescriptor
A complete own property, as [[GetOwnProperty]] reports it.
DebugInfoMode
Runtime-wide policy for the currently represented, JS-observable portion of QuickJS JS_SetStripInfo.
DescriptorField
A descriptor field: absent, or present with a value (Present(undefined) and Absent mean different things).
GcPolicy
When the collector runs.
JsStringError
Why a string-kernel operation failed. It becomes a QuickJS InternalError (ErrorKind::JsInternal) in the front end’s errors, and a RuntimeError in the embedding API.
ModuleImportAttributes
Syntactic import-attribute state for one requested module.
ModuleSource
What a loader returns for a module name.
PendingJobOutcome
What run_pending_job did.
PromiseState
A promise’s state.
RejectionEvent
What Host::promise_rejection reports (ECMAScript’s HostPromiseRejectionTracker operations).
RuntimeError
Why an API call failed.
Stream
Which output stream print and the console write to.
TypedArrayKind
A typed array’s element type. A typed array’s element type.
Value
A JavaScript value held by the embedder.
WellKnownSymbol
The well-known symbols.

Traits§

FromJs
A Rust value made from a JavaScript value, as the specification’s conversions make it (ToNumber, ToString, …). A conversion that may run JavaScript runs it through js.
Host
The embedder’s services. Every method has a default suitable for a standalone runtime: the process’s streams, the system clock and UTC.
HostFunction
What Js::new_function takes: a closure over a Scope. Args is the marker the closure’s shape selects on.
IntoJs
A JavaScript value made from a Rust value.
Js
The operations Context and a host function’s Scope share, for code generic over where it runs. Sealed; both types also have each as an inherent method, so calling one needs no import.
ModuleLoader
The embedder’s module loader. Errors are values to throw, made through the ModuleScope.

Type Aliases§

JsResult
What every operation returns.