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§
- Audio
Engine - Multi-channel audio playback engine backed by rodio.
- Canvas
State - Current canvas snapshot for one frame: command list, dimensions, image atlas, and invalidation generation.
- Console
Entry - A single console log line: local time, severity, and message text.
- Decoded
Image - An image decoded to RGBA8 pixels for compositing in the host canvas renderer.
- Host
State - 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.
- Input
State - Per-frame input snapshot from the host (egui) for guest polling via
api_mouse_*,api_key_*, etc. - Timer
Entry - A scheduled timer: either a one-shot
setTimeoutor repeatingsetInterval.
Enums§
- Console
Level - Severity level for
ConsoleEntryandconsole_log. - Draw
Command - One canvas drawing operation produced by guest
api_canvas_*imports and consumed by the host renderer. - Widget
Command - UI control the guest requested for the current frame; the host egui layer renders these after canvas content.
- Widget
Value - Persistent control state for interactive widgets, keyed by widget
idacross frames.
Functions§
- console_
log - Append a
ConsoleEntrywith the current local timestamp to the shared console buffer. - drain_
expired_ timers - Remove due timers from
timers, collect each fired entry’sTimerEntry::callback_id, and return them. - register_
host_ functions - Register every
oxideimport onlinkerso guest modules can link against them.