Skip to main content

Crate gasm_host

Crate gasm_host 

Source
Expand description

Native host for gasm games.

Load a guest .wasm with host::Game::load, drive it with host::Game::frame at the guest’s frame rate, and plug in the pieces you need: assets::Assets (memory, file-backed, folders), gfx::Gfx (wgpu: window, offscreen or null), audio::AudioSink (cpal), net::Net (WebSocket, ws:///wss://), storage::Storage (per-game key/value). The gasm-run binary in this crate is a complete runner built from these parts; gasm-relay is the room relay.

ABI: https://gasm.emdzej.pl/docs/abi (machine-readable: spec/abi.json).

Modules§

assets
Read-only guest assets: in-memory buffers, or files opened (not read) at start.
audio
Audio output: guest samples -> linear resampler -> ring buffer -> cpal device.
gfx
gasm:gfx on wgpu, plus the 2D video_present blit.
host
The gasm ABI v0 host: instantiates a guest and implements the “gasm”, “gasm:gfx” and “gasm:net” imports.
keymap
Keyboard layouts: the same text format as the web player (gasm-host.js parseKeymap). A line per binding: <pad 1-4> <button> <key code>..., where key codes are W3C KeyboardEvent.code names (winit’s KeyCode uses the same names). Keyboard bindings for pad N >= 2 apply while fewer than N gamepads are connected.
net
gasm:net for the native runner: WebSocket client connections.
script
Scripted input for headless runs (--input), mirrored by runners/web/headless.mjs.
storage
gasm:storage for the native runner: one directory per game, one file per key.