zwasm Public API Boundary

April 24, 2026 ยท View on GitHub

Defines the stable public surface of @import("zwasm"). Types and functions listed here are covered by SemVer guarantees.

Stable types

TypeDescriptionSince
WasmModuleLoad, execute, and manage a Wasm modulev0.1.0
WasmFnBound wrapper for an exported functionv0.1.0
WasmValTypeEnum of Wasm value types (i32, i64, f32, f64, v128, funcref, externref)v0.1.0
ExportInfoMetadata for an exported function (name, param/result types)v0.1.0
ImportEntryMaps an import module name to a sourcev0.2.0
WasmModule.ConfigUnified loading configurationvNEXT
ImportSourceUnion: wasm_module or host_fnsv0.2.0
HostFnEntryA single host function (name, callback, context)v0.2.0
HostFnFunction type: fn (*anyopaque, usize) anyerror!voidv0.2.0
ImportFuncInfoImport metadata (module, name, param/result count)v0.2.0
WasiOptionsWASI configuration (args, env, preopen, capabilities). Default caps: cli_defaultv0.2.0
CapabilitiesWASI capability flags (presets: all, cli_default, sandbox)v1.0.0
VmVM type for host function callbacksv0.2.0

Stable functions

WasmModule

MethodSignatureSince
loadWithOptions(Allocator, []const u8, Config) !*WasmModulevNEXT
load(Allocator, []const u8) !*WasmModulev0.1.0
loadFromWat(Allocator, []const u8) !*WasmModulev0.2.0
loadWasi(Allocator, []const u8) !*WasmModulev0.2.0
loadWasiWithOptions(Allocator, []const u8, WasiOptions) !*WasmModulev0.2.0
loadWithImports(Allocator, []const u8, ?[]const ImportEntry) !*WasmModulev0.2.0
loadWasiWithImports(Allocator, []const u8, ?[]const ImportEntry, WasiOptions) !*WasmModulev0.2.0
loadWithFuel(Allocator, []const u8, u64) !*WasmModulev0.3.0
deinit(*WasmModule) voidv0.1.0
invoke(*WasmModule, []const u8, []u64, []u64) !voidv0.1.0
cancel(*WasmModule) voidvNEXT
invokeInterpreterOnly(*WasmModule, []const u8, []u64, []u64) !voidvNEXT
memoryRead(*WasmModule, Allocator, u32, u32) ![]const u8v0.2.0
memoryWrite(*WasmModule, u32, []const u8) !voidv0.2.0
getExportInfo(*WasmModule, []const u8) ?ExportInfov0.2.0
getExportFn(*WasmModule, []const u8) ?*const WasmFnv0.2.0
getWasiExitCode(*WasmModule) ?u32v0.2.0
registerExports(*WasmModule, []const u8) !voidv0.3.0

WasmFn

MethodSignatureSince
invokeRaw(*const WasmFn, []u64, []u64) !voidv0.2.0

Free functions

FunctionSignatureSince
inspectImportFunctions(Allocator, []const u8) ![]const ImportFuncInfov0.2.0

Experimental (may change)

Type/FunctionDescription
runtime.StoreInternal store for cross-module testing
runtime.ModuleInternal decoded module
runtime.InstanceInternal instance
runtime.VmImplInternal VM implementation
WasmModule.loadLinkedTwo-phase instantiation with shared store. Note: If OOM occurs after Phase 1, the returned module will have vm = null and apply_error = error.OutOfMemory. Such a module is discoverable (e.g., via exports), but unusable: any attempt to invoke will return error.ModuleNotFullyLoaded. This is intentional for shared store consistency.
WasmModule.registerExportsToRegister to external store
WasmModule.setWitInfoAttach WIT metadata
WasmModule.getWitFuncLookup WIT function
WasmFn.cabiReallocComponent Model memory realloc

Internal (not exported)

All types in src/ files other than types.zig are internal and not accessible to library consumers. They may change without notice.