Documentation
¶
Overview ¶
Example (Custom) ¶
This shows how to customize the underlying wasmer engine used by waPC.
// Set up the context used to instantiate the engine. ctx := context.Background() cfg := wasmtime.NewConfig() cfg.SetWasmMemory64(true) e := EngineWithRuntime(func() (*wasmtime.Engine, error) { return wasmtime.NewEngineWithConfig(cfg), nil }) // Configure waPC to use a specific wasmer feature. // Instantiate a module normally. m, err := e.New(ctx, wapc.NoOpHostCallHandler, guest, mc) if err != nil { log.Panicf("Error creating module - %v\n", err) } defer m.Close(ctx)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRuntime ¶ added in v0.5.5
func DefaultRuntime() (*wasmtime.Engine, error)
DefaultRuntime implements NewRuntime by returning a wasmtime Engine
func Engine ¶
func Engine() wapc.Engine
Engine returns a new wapc.Engine which uses the DefaultRuntime.
func EngineWithRuntime ¶ added in v0.5.5
func EngineWithRuntime(newRuntime NewRuntime) wapc.Engine
EngineWithRuntime allows you to customize or return an alternative to DefaultRuntime,
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a single instantiation of a module with its own memory.
func (*Instance) Close ¶
Close closes the single instance. This should be called before calling `Close` on the Module itself.
func (*Instance) Invoke ¶
Invoke calls `operation` with `payload` on the module and returns a byte slice payload.
func (*Instance) MemorySize ¶
MemorySize returns the memory length of the underlying instance.
func (*Instance) Unwrap ¶ added in v0.5.5
func (i *Instance) Unwrap() *wasmtime.Instance
Unwrap allows access to wasmtime-specific features.
func (*Instance) UnwrapStore ¶ added in v0.5.5
func (i *Instance) UnwrapStore() *wasmtime.Store
UnwrapStore allows access to wasmtime-specific features.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module represents a compile waPC module.
func (*Module) Close ¶
Close closes the module. This should be called after calling `Close` on any instances that were created.
func (*Module) Instantiate ¶
Instantiate creates a single instance of the module with its own memory.
func (*Module) Unwrap ¶ added in v0.5.5
func (m *Module) Unwrap() *wasmtime.Module
Unwrap allows access to wasmtime-specific features.
func (*Module) UnwrapStore ¶ added in v0.5.5
func (m *Module) UnwrapStore() *wasmtime.Store
UnwrapStore allows access to wasmtime-specific features.
type NewRuntime ¶ added in v0.5.5
type NewRuntime func() (*wasmtime.Engine, error)
NewRuntime returns a new wazero runtime which is called when the New method on wapc.Engine is called. The result is closed upon wapc.Module Close.