Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }

Implementations§

Source§

impl Runtime

Source

pub fn invoke_hta( &mut self, qualified_var: &str, arguments_hta: &[u8], ) -> Result<Vec<u8>, InvokeHtaError>

§

impl Runtime

pub fn new() -> Runtime

pub fn core() -> Runtime

Creates the portable core-language evaluator without loading the language-level foundation. This is useful for small embedded surfaces whose commands only require core forms and should become interactive immediately.

pub fn set_test_runner(&mut self, runner: &str) -> Result<(), JsValue>

pub fn set_execution_backend(&mut self, backend: &str) -> Result<(), JsValue>

Selects the execution backend used by ordinary eval and Session evaluation. The default is interpreter; direct-native is an explicit native-target opt-in and never falls back to interpretation.

pub fn execution_backend(&self) -> String

Returns the selected ordinary evaluation backend.

pub fn eval_halc(&mut self, bytes: &[u8]) -> Result<String, String>

pub fn create_namespace(&mut self, name: &str) -> bool

pub fn use_namespace(&mut self, name: &str) -> bool

pub fn visible_symbols(&self) -> Vec<String>

pub fn current_namespace(&self) -> String

pub fn alias_namespace(&mut self, alias: &str, target: &str) -> bool

pub fn resolve_namespace(&self, name: &str) -> String

pub fn eval_in_namespace( &mut self, name: &str, source: &str, ) -> Result<String, JsValue>

Evaluates source after selecting a namespace.

pub fn require_resource_in_namespace( &mut self, resource: &str, namespace: &str, ) -> Result<String, JsValue>

pub fn install_memory_file_provider(&mut self, root: &str)

pub fn install_native_file_provider(&mut self, root: &str)

pub fn install_native_socket_provider(&mut self)

pub fn install_native_process_provider(&mut self)

pub fn install_loopback_socket_provider(&mut self)

pub fn file_resolve(&self, root: &str, path: &str) -> Result<String, JsValue>

pub fn file_read(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_write( &self, path: &str, bytes: Vec<u8>, ) -> Result<PromiseHandle, JsValue>

pub fn file_exists(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_stat(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_list(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_mkdir(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_walk(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn file_delete(&self, path: &str) -> Result<PromiseHandle, JsValue>

pub fn extension_available(&self, name: &str) -> bool

pub fn require_extension(&mut self, name: &str) -> Result<String, JsValue>

pub fn register_resource(&mut self, name: &str, source: &str)

Registers a host-supplied Hara resource. Resources are source text, not executable host code.

pub fn unregister_resource(&mut self, name: &str) -> Result<(), JsValue>

Detaches a host-supplied namespace while leaving already captured values alive. Package providers use this to deactivate one generation.

pub fn register_package_lock(&mut self, source: &str) -> Result<(), JsValue>

Registers exact package ownership from project.lock.edn without downloading or loading any namespace.

pub fn load_resource(&mut self, name: &str) -> Result<String, JsValue>

Evaluates a registered resource in the current lexical namespace.

pub fn require_resource(&mut self, name: &str) -> Result<String, JsValue>

Loads a resource once; subsequent requires return the current loaded marker.

pub fn file_supported(&self) -> bool

pub fn socket_supported(&self) -> bool

pub fn socket_connect(&self, host: &str, port: u16) -> Result<u64, JsValue>

Opens a callback-based socket and returns its provider-owned handle.

pub fn socket_send(&self, socket: u64, bytes: Vec<u8>) -> Result<usize, JsValue>

pub fn socket_close(&self, socket: u64) -> Result<(), JsValue>

pub fn has_protocol_method(&self, protocol: &str, method: &str) -> bool

Returns whether a protocol method is registered in this runtime context.

pub fn eval(&mut self, source: &str) -> Result<String, JsValue>

pub fn eval_traced(&mut self, source: &str) -> Result<String, JsValue>

pub fn compile_bytecode_artifact_js( &self, source: &str, ) -> Result<Vec<u8>, JsValue>

pub fn compile_bytecode_manifest_js( &self, source: &str, ) -> Result<String, JsValue>

Returns the immutable manifest for the HBC0 artifact produced from source. Hosts can cache the bytes and manifest without guessing the target or ABI from a filename.

pub fn eval_bytecode_artifact_js( &mut self, bytes: &[u8], ) -> Result<String, JsValue>

pub fn eval_bytecode_bundle_js(&mut self, bytes: &[u8]) -> Result<(), JsValue>

Installs a verified HBX0 namespace bundle. The bundle indexes each module’s bytecode without making package loading implicit; callers still choose when to require a registered namespace.

pub fn eval_native(&mut self, source: &str) -> Result<String, String>

pub fn eval_native_traced(&mut self, source: &str) -> Result<String, String>

§

impl Runtime

pub fn eval_native_diagnostic( &mut self, source: &str, ) -> ((Result<String, String>, Vec<TraceFrame>), Option<Value>)

Evaluates native source while retaining the typed exception and callable frames needed by embedding protocols. The ordinary eval_native and eval_native_traced string contracts remain unchanged.

pub fn register_source_catalog(&mut self, catalog: &SourceCatalog)

Replaces the native project source catalog used by namespace loading. Only paths are retained; source bodies are read at the require boundary. Existing in-memory resources and bytecode remain higher priority than the mounted paths.

pub fn clear_source_catalog(&mut self)

Detaches every mounted native project source path and removes its source-only namespace state. Materialized source namespaces are intentionally discarded at this explicit teardown boundary.

pub fn bootstrap_source_foundation(&mut self) -> Result<(), String>

Loads the language-level Foundation from the mounted source catalog. This is intentionally an interpreter bootstrap: the resulting macros, aliases, and protocol wiring form the compiler environment for later direct-native namespace loads.

§

impl Runtime

pub fn with_native_engine(engine: NativeEngine) -> Self

Creates a Runtime whose native-substrate telemetry is shared with another Runtime owner. Namespace registries, providers, and mutable Hara state remain owned by each Runtime; bytecode program images remain owned by the execution that prepared them.

pub fn native_execution_telemetry(&self) -> NativeExecutionTelemetry

Returns cumulative counters from the Runtime-owned bytecode VM and native-substrate boundary. The counters belong to the reusable native engine and are not cleared merely by switching the selected backend; callers sharing an engine can explicitly call crate::direct_native::NativeEngine::reset at their lifecycle boundary.

Source§

impl Runtime

Source

pub fn install_native_kernel_provider(&mut self, provider: Rc<KernelProvider>)

Installs the typed native driver behind std.native.Kernel/*.

Source

pub fn install_native_host_handler( &mut self, handler: Rc<dyn Fn(String, String, Vec<Value>) -> Result<Value, String>>, )

Installs the native host service handler used by std.native.Host/call. Embedders can expose process-local services without converting values through JavaScript or textual serialization.

Source

pub fn install_native_module( &mut self, module: Arc<dyn NativeModule>, ) -> Result<(), String>

Installs a publication-linked native ABI module and exposes it through the same promise-returning Host/call boundary used by browser embedders.

Source

pub fn native_module_services(&self) -> Vec<String>

Source§

impl Runtime

Source

pub fn compile_bytecode(&self, source: &str) -> Result<Rc<Program>, String>

Compiles source against this runtime’s namespace registry: std.foundation vars and anything already interned are visible to the compiler’s two-phase global check (issue #223). The program is validated but not executed; globals intern only at execution.

Source

pub fn execute_compiled_bytecode( &mut self, program: Rc<Program>, ) -> Result<String, String>

Executes an already compiled program against this runtime’s namespace registry. Embedding hosts use this for prepare-once/call-many paths without decoding an artifact or rebuilding the program on every call.

Source

pub fn execute_compiled_bytecode_value( &mut self, program: Rc<Program>, ) -> Result<Value, String>

Executes an already compiled program and returns its immutable runtime value directly. This avoids display serialization and lets native hosts inspect persistent results through their shared representation.

Source

pub fn execute_compiled_bytecode_registry_value( &mut self, program: Rc<Program>, ) -> Result<Value, String>

Executes a prepared program directly against the namespace registry, without copying bindings into the compatibility environment per call.

Source

pub fn eval_bytecode_native(&mut self, source: &str) -> Result<String, String>

Compiles and executes through the experimental VM against this runtime’s registry, then syncs the flat env so later eval_native calls see the vars the program interned. No fallback: unsupported forms fail as compile errors. eval_native is unaffected.

Source

pub fn execute_compiled_direct_native( &mut self, program: Rc<Program>, ) -> Result<NativeExecutionReport, String>

Executes a validated program through the opt-in bytecode VM plus native-substrate boundary. Ordinary Hara functions remain VM-owned; only the closed native/protocol/evaluator target inventory crosses into Rust callouts.

Source

pub fn eval_direct_native(&mut self, source: &str) -> Result<String, String>

Compiles and executes source through the bytecode VM/native-substrate backend. Compilation-time namespace preparation and macro expansion retain their existing evaluator seam; no evaluator call is permitted once the validated program enters the native backend.

Source

pub fn compile_bytecode_artifact(&self, source: &str) -> Result<Vec<u8>, String>

Compiles against this runtime’s namespaces and persists the validated program for later native or browser execution.

Source

pub fn compile_halc_bytecode_artifact( &mut self, bytes: &[u8], ) -> Result<Vec<u8>, String>

Lowers a HALC module directly to persistent bytecode. No source text is reconstructed, and the module’s normalized schema graph is embedded in the HBC artifact for later inference and specialization tiers.

Source

pub fn eval_bytecode_artifact(&mut self, bytes: &[u8]) -> Result<String, String>

Executes a persisted artifact against this runtime’s namespaces.

§

impl Runtime

pub fn halc_schema(&self, qualified_var: &str) -> Option<&Form>

Returns the canonical schema value loaded from HALC for a named schema Var.

pub fn halc_function_schema(&self, qualified_var: &str) -> Option<&Form>

Returns the canonical schema annotation loaded from HALC for a function Var.

pub fn halc_schema_type(&self, qualified_var: &str) -> Option<&SchemaType>

Returns the normalized compiler type for a named schema Var.

pub fn halc_inferred_function_type( &self, qualified_var: &str, ) -> Option<&SchemaType>

Returns a conservative body-derived function signature, when the compiler could prove one independently of the declared contract.

pub fn halc_function_type(&self, qualified_var: &str) -> Option<&SchemaType>

Returns a function’s normalized annotation, resolving one named edge.

pub fn eval_native_value(&mut self, source: &str) -> Result<Value, String>

Evaluates native Hara source and returns its runtime value without a display round trip. Embedding hosts use this to inspect declarative values containing Vars, functions, bytes, and persistent collections.

pub fn add_extension_root(&mut self, root: impl Into<PathBuf>)

pub fn install_wasm_extension<P: WasmExtensionProvider + 'static>( &mut self, manifest_source: &str, origin: &str, provider: P, ) -> Result<(), String>

pub fn install_direct_wasm_import( &mut self, logical: &str, bytes: &[u8], ) -> Result<(), String>

Installs one package-verified raw WASM module behind a logical import coordinate. :import binds its exports directly and never creates an HTA or generated Hara namespace.

pub fn cancel_wasm_extension( &self, name: &str, request: u64, ) -> Result<(), String>

pub fn invoke_wasm_extension( &mut self, namespace: &str, export: &str, arguments: &[Value], ) -> Result<Value, String>

Invokes an installed WASM extension without routing the call through source text. Service hosts use this binary-safe boundary for HTA0 arguments and results.

Trait Implementations§

Source§

impl Drop for Runtime

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<Runtime> for JsValue

Source§

fn from(value: Runtime) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for Runtime

Source§

type Abi = WasmPtr<WasmRefCell<Runtime>>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for Runtime

Source§

type Abi = WasmPtr<WasmRefCell<Runtime>>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for Runtime

Source§

type Abi = WasmPtr<WasmRefCell<Runtime>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<Runtime>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for Runtime

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for Runtime

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for Runtime

Source§

type Abi = WasmPtr<WasmRefCell<Runtime>>

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<Runtime>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for Runtime

Source§

type Abi = WasmPtr<WasmRefCell<Runtime>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<Runtime>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl SupportsConstructor for Runtime

Source§

impl SupportsInstanceProperty for Runtime

Source§

impl SupportsStaticProperty for Runtime

Source§

impl TryFromJsValue for Runtime

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for Runtime

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Runtime]>

Source§

impl VectorIntoWasmAbi for Runtime

Source§

impl WasmDescribe for Runtime

Source§

impl WasmDescribeVector for Runtime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more