Skip to main content

Module capabilities

Module capabilities 

Source
Expand description

Host capabilities and shared state for WebAssembly guests.

This module defines HostState and the data structures the host and guest share (console, canvas, timers, input, widgets, navigation, and more). register_host_functions attaches the oxide Wasm import module to a Wasmtime [Linker]: every host function that guest modules may call—api_log, api_canvas_*, api_storage_*, api_navigate, audio and UI APIs, etc.—is registered there under the import module name oxide.

Guest code imports these symbols from oxide; implementations run on the host and read or mutate the HostState held in the Wasmtime store attached to the linker.

Structs§

AudioEngine
Multi-channel audio playback engine backed by rodio.
CanvasState
Current canvas snapshot for one frame: command list, dimensions, image atlas, and invalidation generation.
ConsoleEntry
A single console log line: local time, severity, and message text.
DecodedImage
An image decoded to RGBA8 pixels for compositing in the host canvas renderer.
HostState
All shared state between the browser host and a guest Wasm module (and dynamically loaded children).
Hyperlink
A clickable axis-aligned rectangle on the canvas that navigates to a URL when hit-tested.
InputState
Per-frame input snapshot from the host (egui) for guest polling via api_mouse_*, api_key_*, etc.
TimerEntry
A scheduled timer: either a one-shot setTimeout or repeating setInterval.

Enums§

ConsoleLevel
Severity level for ConsoleEntry and console_log.
DrawCommand
One canvas drawing operation produced by guest api_canvas_* imports and consumed by the host renderer.
WidgetCommand
UI control the guest requested for the current frame; the host egui layer renders these after canvas content.
WidgetValue
Persistent control state for interactive widgets, keyed by widget id across frames.

Functions§

console_log
Append a ConsoleEntry with the current local timestamp to the shared console buffer.
drain_expired_timers
Remove due timers from timers, collect each fired entry’s TimerEntry::callback_id, and return them.
register_host_functions
Register every oxide import on linker so guest modules can link against them.