Host Functions
Host Functions
Section titled “Host Functions”WASM modules access runtime capabilities through host function imports. Each import is declared explicitly per entry in the imports list.
Import Types
Section titled “Import Types”| Import | Description |
|---|---|
wasi:cli | Environment, exit, stdin/stdout/stderr, terminal |
wasi:io | Streams and error handling |
wasi:poll | Async polling / cooperative yielding (interface wasi:io/poll) |
wasi:clocks | Wall clock and monotonic clock |
wasi:filesystem | File system access through mounted directories |
wasi:random | Cryptographically secure random numbers |
wasi:sockets | TCP/UDP networking and DNS resolution |
wasi:http | Outgoing HTTP client requests |
Enable imports in your entry configuration:
- name: my_function kind: function.wasm fs: myns:assets path: /module.wasm hash: sha256:... method: run imports: - wasi:cli - wasi:io - wasi:clocks - wasi:filesystem pool: type: inlineOnly declare the imports your module actually needs.
WASI Imports
Section titled “WASI Imports”Each wasi:* import enables a group of related WASI Preview 2 interfaces.
wasi:clocks
Section titled “wasi:clocks”Interfaces: wasi:clocks/wall-clock, wasi:clocks/monotonic-clock
Wall clock and monotonic clock for time operations. Monotonic clock integrates with the Wippy dispatcher for async sleep.
wasi:io
Section titled “wasi:io”Interfaces: wasi:io/error, wasi:io/streams
Stream read/write operations and error handling. The wasi:io/poll interface is provided separately by the wasi:poll import.
wasi:poll
Section titled “wasi:poll”Interfaces: wasi:io/poll
Async polling. The poll interface enables cooperative yielding through the dispatcher.
wasi:cli
Section titled “wasi:cli”Interfaces: wasi:cli/environment, wasi:cli/exit, wasi:cli/stdin, wasi:cli/stdout, wasi:cli/stderr, wasi:cli/terminal-stdin, wasi:cli/terminal-stdout, wasi:cli/terminal-stderr
Access to environment variables, process exit codes, and standard I/O streams. Environment variables are mapped from the Wippy environment registry through WASI configuration.
wasi:filesystem
Section titled “wasi:filesystem”Interfaces: wasi:filesystem/types, wasi:filesystem/preopens
File system access through mounted directories. Mounts are configured per-entry and map Wippy filesystem entries to guest paths.
wasi: mounts: - fs: myns:data guest: /data read_only: truewasi:random
Section titled “wasi:random”Interfaces: wasi:random/random, wasi:random/insecure, wasi:random/insecure-seed
Cryptographically secure and insecure random number generation.
wasi:sockets
Section titled “wasi:sockets”Interfaces: wasi:sockets/instance-network, wasi:sockets/ip-name-lookup, wasi:sockets/tcp, wasi:sockets/tcp-create-socket, wasi:sockets/udp, wasi:sockets/udp-create-socket
TCP and UDP networking with DNS resolution. Socket operations integrate with the dispatcher for async I/O.
wasi:http
Section titled “wasi:http”Interfaces: wasi:http/types, wasi:http/outgoing-handler
Outgoing HTTP client requests from within WASM modules. Supports request/response types defined by the WASI HTTP specification.