wasm

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer uint64

func Error

func Error(ctx context.Context, module api.Module, ptr Ptr, state State, err string) Buffer

func FromSlice

func FromSlice(value []byte) Buffer

func Malloc

func Malloc(ctx context.Context, module api.Module, data []byte) Buffer

func (Buffer) Address

func (buffer Buffer) Address() uint32

func (Buffer) Length

func (buffer Buffer) Length() uint32

func (Buffer) Slice

func (buffer Buffer) Slice() []byte

func (Buffer) String

func (buffer Buffer) String() string

type Ptr

type Ptr uint32

func PtrTo

func PtrTo[T any](value *T) Ptr

type State

type State uint32

State is used to convey the state of a host module function call. Given that a host function will generally do something the wasm module cannot do, it will likely do some sort of IO. This means that the call can either succeed or fail with some error. This allows us to interpret the returned memory buffer as either containing a value or an error.

State is a uint32 allowing us to define well-known generic errors that packages can use to express semantic meaning. It is not exhaustive. As new use cases are added, we can add new semantic errors.

Currently the only host function we expose is k8s.Lookup, this means means the host function can set any of the below states and the k8s package can use them to return meaningful error types to the user that they can in turn act upon.

const (
	StateOK State = iota
	StateFeatureNotGranted
	StateError
	StateNotFound
	StateUnauthenticated
	StateForbidden
)

type String

type String uint64

func FromString

func FromString(value string) String

func (String) Load

func (value String) Load(module api.Module) string

func (String) LoadBytes

func (value String) LoadBytes(module api.Module) []byte

Jump to

Keyboard shortcuts

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