internal

package
v0.0.0-...-c2927df Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFunction

func NewFunction(runtime *Runtime, instanceWrn sdk.WRN, fn sdk.Function) *function

NewFunction creates a function for the given sdk.Function.

func NewGlobal

func NewGlobal(value interface{}) (*global, error)

Types

type GuestFunc

type GuestFunc func(*wasmtime.Caller, []wasmtime.Val) ([]wasmtime.Val, *wasmtime.Trap)

GuestFunc represents a function that can be used with wasmtime.

type HostFunc

type HostFunc func(...wasmtime.Val) (interface{}, error)

HostFunc translates between GuestFunc and sdk.Function.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance wraps an active Wasmtime instance with a helpful API for interacting with it.

func NewInstance

func NewInstance(rt *Runtime, hostImports runtime.HostImports) (*Instance, error)

func (*Instance) Call

func (i *Instance) Call(name string, args ...interface{}) (interface{}, error)

Call invokes an exported function by name with the given arguments.

func (*Instance) Close

func (i *Instance) Close() error

Close will free resources used by the underlying wasmtime instance.

func (*Instance) Read

func (i *Instance) Read(mem sdk.Memory) ([]byte, error)

Read memory of given length at a specific address location.

func (*Instance) Stderr

func (i *Instance) Stderr() string

Stderr returns the stderr stream for the instance.z

This will be empty if InheritStderr was not set on WasiConfigs.

func (*Instance) Stdout

func (i *Instance) Stdout() string

Stdout returns the stdout stream for the instance.

This will be empty if InheritStdout was not set on WasiConfig.

func (*Instance) WRN

func (i *Instance) WRN() sdk.WRN

WRN returns the resource name for the instance.

func (*Instance) Write

func (i *Instance) Write(addr int32, bytes []byte) (int32, error)

Write bytes to memory at a specific address location.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime encapsulates all Wasmtime state necessary to run WASM code.

func NewRuntime

func NewRuntime(mod sdk.Module, cfg runtime.Config) (*Runtime, error)

NewRuntime creates a new runtime.

func (*Runtime) Get

func (r *Runtime) Get(wrn sdk.WRN) (sdk.Instance, error)

Get returns the pool instance for the given wrn.

func (*Runtime) New

func (r *Runtime) New() (sdk.Instance, error)

New creates a new Instance for the runtime.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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