wasmtime

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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

func (i *Instance) Close(context.Context) error

Close closes the single instance. This should be called before calling `Close` on the Module itself.

func (*Instance) Invoke

func (i *Instance) Invoke(ctx context.Context, operation string, payload []byte) ([]byte, error)

Invoke calls `operation` with `payload` on the module and returns a byte slice payload.

func (*Instance) MemorySize

func (i *Instance) MemorySize() uint32

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

func (m *Module) Close(context.Context) error

Close closes the module. This should be called after calling `Close` on any instances that were created.

func (*Module) Instantiate

func (m *Module) Instantiate(ctx context.Context) (wapc.Instance, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL