runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interpreter

type Interpreter struct {
	Refs *MapRefs

	Config          InterpreterConfig
	ModuleContext   *cv.Context
	ProcessorConfig *config.Store
	// contains filtered or unexported fields
}

Interpreter is a WebAssembly interpreter that can load and run guest modules.

func New

New creates a new Interpreter.

func (*Interpreter) Close

func (intp *Interpreter) Close(ctx context.Context)

Close closes the interpreter.

func (*Interpreter) LoadProcessors

func (intp *Interpreter) LoadProcessors(ctx context.Context, processors []string) error

func (*Interpreter) Process

func (intp *Interpreter) Process(ctx context.Context, frm *cv.Frame) *cv.Frame

Process performs processing on a frame.

func (*Interpreter) Processors

func (intp *Interpreter) Processors() []guest.Module

Processors returns the guest modules registered with the interpreter.

func (*Interpreter) RegisterGuestModule

func (intp *Interpreter) RegisterGuestModule(ctx context.Context, name string, module []byte) error

RegisterGuestModule registers a guest module with the interpreter.

type InterpreterConfig

type InterpreterConfig struct {
	ProcessorsDir string
	ModelsDir     string
	Settings      map[string]string
}

type MapRefs

type MapRefs struct {
	Raw map[uint32]any
	// contains filtered or unexported fields
}

MapRefs is a [Refs] implementation powered by a map protected by a mutex. Indexes are generated randomly and checked for collisions.

Must be constructed with NewMapRefs.

func NewMapRefs

func NewMapRefs() *MapRefs

NewMapRefs creates a new MapRefs.

func (*MapRefs) Drop

func (r *MapRefs) Drop(idx uint32)

Drop removes a value by index.

func (*MapRefs) Get

func (r *MapRefs) Get(idx uint32, def any) (any, bool)

Get returns a value by index.

func (*MapRefs) Put

func (r *MapRefs) Put(val any) uint32

Put puts a value into the map and returns its index.

func (*MapRefs) Set

func (r *MapRefs) Set(idx uint32, val any)

Set sets a value by index.

Jump to

Keyboard shortcuts

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