Expand description
Host-function and prelude registration for the Submilli runtime.
Structs§
- Denial
- A denial the runtime threw that escaped the program, as the embedder sees it.
- Fatal
Host Error - A broken host invariant or exhausted host allocation must terminate the run,
rather than becoming an exception that guest code can catch and ignore.
Reaching the memory cap terminates it too, under its own name: see
is_memory_exhausted. - HostAbi
- Runtime handles host functions use to build real
$Object-subtype structs (currently$string/$Array/$Uint8Array) on the host side instead of returning the raw payload array for a Wasm shim to re-wrap. The canonicalStructType/ArrayTypehandles are declared directly viaRecGroupBuilder(see [build_intrinsic_types]); the vtable value is read from the prelude instance per call. - Permission
Denied - Marker for a capability denial that should surface to the guest as the
built-in
PermissionDeniedErrorsubclass, carrying the structured fields policy-aware recovery code reads (e.capability,e.caller,e.reason). Same contract asRangeError. - Quota
Exceeded Error - Marker for a host failure that should surface to the guest as the built-in
QuotaExceededErrorsubclass rather than a baseError. ReturnErr(quota_exceeded_error(...))from a host-fn body; theregister_host_fnwrapper downcasts for it when converting theErrinto a guest throw. The message is the guest-visiblee.message. - Range
Error - Marker for a host failure that should surface to the guest as the built-in
RangeErrorsubclass rather than a baseError. ReturnErr(range_error(...))from a host-fn body; theregister_host_fnwrapper downcasts for it when converting theErrinto a guest throw. The message is the guest-visiblee.message. - Syntax
Error - Marker for a host failure that should surface to the guest as the built-in
SyntaxErrorsubclass — same contract asRangeError. - Type
Error - Marker for a host failure that should surface to the guest as the built-in
TypeErrorsubclass — same contract asRangeError. Used for argument-boundary type mismatches (a null or wrong-typed value where the ABI promised another type) and for spec-TypeErrorconditions (invalid URL, fatal text decode, unsupported HTTP method). - UriError
- Marker for a host failure that should surface to the guest as the built-in
URIErrorsubclass — same contract asRangeError.
Enums§
- Denial
Source - Which layer refused. Absent from the guest ABI: the guest sees
caller/capability/reasonas before. It selects the closing paragraph of the rendered message and, for a denial that escapes the program, thesourcethe embedder reports.
Constants§
- INTERNAL_
MODULE_ NAME - Not user-importable;
__prefix keeps it out of any stdlib namespace. - NUMBER_
MODULE_ NAME
Functions§
- fatal_
host_ error - host_
package_ declarations - PackageDeclaration for host fns the consumer imports directly.
console.logandnumber.toStringare excluded — they’re wrapped by prelude exports and must not appear as free-function bindings in the user’s scope. - install_
async - Install the full runtime: the store-less host fns (prelude + stdlib + MCP) followed by the store-bound prelude state. There are no runtime Wasm modules — every built-in surface is Rust host fns resolved straight from the linker.
- install_
async_ for install_asyncfor an embedder that offersstdlib.- install_
host_ functions - install_
host_ functions_ for install_host_functionsfor an embedder that offersstdlib.- install_
store_ bound - The store-bound half of
install_async, for embedders that keep a reusable base linker of host fns and only need the per-store state. - internal_
host_ package_ declarations - Compiler-internal host fn definitions — wired into codegen but not visible in user scope.
- permission_
denied - A policy denial, thrown at the guest boundary as the built-in
PermissionDeniedError. - permission_
denied_ invariant - A denial the policy never got to weigh in on, because the runtime refuses this caller/capability pair outright.
- permission_
denied_ read_ only - A write into a volume mounted read-only.
- quota_
exceeded_ error - A host failure that throws the built-in
QuotaExceededErrorat the guest boundary. - range_
error - A host failure that throws the built-in
RangeErrorat the guest boundary. - read_
string_ arg - read_
string_ array_ arg - Read a real
$Array<$string>intoVec<String>. Null slots → empty string. - register_
host_ fn - Register a host fn under
mangled_name— the linker field codegen imports for it:mangle::host(module, name)for stdlib/host modules, or a prelude method’s dispatch key (e.g.submilli:prelude#String#repeat) so codegen’s method lookup resolves to it. - register_
host_ fn_ async - Async sibling of
register_host_fn: registers undermangled_name. The body returns a boxed future; the sameErr→throw_errormapping applies once it resolves. - stdlib_
package_ declarations - syntax_
error - A host failure that throws the built-in
SyntaxErrorat the guest boundary. - throw_
error - Raise a catchable Submilli
Errorfrom inside a host function. - type_
error - A host failure that throws the built-in
TypeErrorat the guest boundary. - uri_
error - A host failure that throws the built-in
URIErrorat the guest boundary. - write_
submilli_ array_ struct - Build a real
$Array(vtable +$rawArraybacking) from already-built element object refs (e.g.$strings for astring[]). Each elementValmust be a(ref null $Object)— a subtype ref orVal::AnyRef(None). - write_
submilli_ string - Encodes a Rust string as a Submilli packed-UTF-16
(array (mut i16))— the bare$rawStringpayload, without the$stringobject wrapper. - write_
submilli_ string_ struct - Build a real
$string(vtable + packed-UTF-16 payload). RequiresStoreData::host_abi, set once the prelude instantiates. - write_
submilli_ string_ struct_ units - Build a real
$stringdirectly from UTF-16 code units — the surrogate-faithful path for callers (e.g.String.fromCharCode) whose output may contain lone surrogates that a RustStringcan’t carry. RequiresStoreData::host_abi, set once the prelude instantiates. - write_
submilli_ uint8array_ struct - Build a real
$Uint8Array(vtable + packed-i8 payload). Mirror ofwrite_submilli_string_struct. RequiresStoreData::host_abi.