extism

package module
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: BSD-3-Clause Imports: 7 Imported by: 1

README

Welcome!

Please note: This project still under active development and APIs may change until we hit v1.0.

If you're interested in working on or building with Extism, please join our Discord and let us know - we are happy to help get you started.

Discord

Extism

The universal plug-in system. Run WebAssembly extensions inside your app. Use idiomatic Host SDKs for Go, Ruby, Python, Node, Rust, C, C++, OCaml, Haskell, PHP, Elixir/Erlang, .NET, Java, Zig & more (others coming soon).

Plug-in development kits (PDK) for plug-in authors supported in Rust, AssemblyScript, Go, C/C++, Haskell, and Zig.

Extism embedded SDK language support

Add a flexible, secure, and bLaZiNg FaSt plug-in system to your project. Server, desktop, mobile, web, database -- you name it. Enable users to write and execute safe extensions to your software in 3 easy steps:

1. Import

Import an Extism Host SDK into your code as a library dependency.

2. Integrate

Identify the place(s) in your code where some arbitrary logic should run (the plug-in!), returning your code some results.

3. Execute

Load WebAssembly modules at any time in your app's lifetime and Extism will execute them in a secure sandbox, fully isolated from your program's memory.


Usage

Head to the project website for more information and docs. Also, consider reading an overview of Extism and its goals & approach.

Contribution

Thank you for considering a contribution to Extism, we are happy to help you make a PR or find something to work on!

The easiest way to start would be to join the Discord or open an issue on the extism/proposals issue tracker, which can eventually become an Extism Improvement Proposal (EIP).


Who's behind this?

Extism is an open-source product from the team at:

Reach out and tell us what you're building! We'd love to help.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtismVersion

func ExtismVersion() string

ExtismVersion gets the Extism version string

func SetLogFile

func SetLogFile(filename string, level string) bool

SetLogFile sets the log file and level, this is a global setting

func ValGetF32 added in v0.2.0

func ValGetF32(v unsafe.Pointer) float32

ValGetF32 returns a float32 from an ExtismVal, it accepts a pointer to a C.ExtismVal

func ValGetF64 added in v0.2.0

func ValGetF64(v unsafe.Pointer) float64

ValGetF32 returns a float64 from an ExtismVal, it accepts a pointer to a C.ExtismVal

func ValGetI32 added in v0.2.0

func ValGetI32(v unsafe.Pointer) int32

ValGetI32 returns an int32 from an ExtismVal, it accepts a pointer to a C.ExtismVal

func ValGetI64 added in v0.2.0

func ValGetI64(v unsafe.Pointer) int64

ValGetI64 returns an I64 from an ExtismVal, it accepts a pointer to a C.ExtismVal

func ValGetUInt added in v0.2.0

func ValGetUInt(v unsafe.Pointer) uint

ValGetUInt returns a uint from an ExtismVal, it accepts a pointer to a C.ExtismVal

func ValSetF32 added in v0.2.0

func ValSetF32(v unsafe.Pointer, i float32)

ValSetF32 stores a float32 in an ExtismVal, it accepts a pointer to a C.ExtismVal and the new value

func ValSetF64 added in v0.2.0

func ValSetF64(v unsafe.Pointer, f float64)

ValSetF64 stores a float64 in an ExtismVal, it accepts a pointer to a C.ExtismVal and the new value

func ValSetI32 added in v0.2.0

func ValSetI32(v unsafe.Pointer, i int32)

ValSetI32 stores an int32 in an ExtismVal, it accepts a pointer to a C.ExtismVal and the new value

func ValSetI64 added in v0.2.0

func ValSetI64(v unsafe.Pointer, i int64)

ValSetI64 stores an int64 in an ExtismVal, it accepts a pointer to a C.ExtismVal and the new value

Types

type CancelHandle added in v0.3.0

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

func (*CancelHandle) Cancel added in v0.3.0

func (c *CancelHandle) Cancel() bool

type Context

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

Context is used to manage Plugins

func NewContext

func NewContext() Context

NewContext creates a new context, it should be freed using the `Free` method

func (*Context) Free

func (ctx *Context) Free()

Free a context

func (*Context) Plugin

func (ctx *Context) Plugin(module io.Reader, functions []Function, wasi bool) (Plugin, error)

Plugin creates a plugin from a WASM module

func (*Context) PluginFromManifest

func (ctx *Context) PluginFromManifest(manifest Manifest, functions []Function, wasi bool) (Plugin, error)

PluginFromManifest creates a plugin from a `Manifest`

func (Context) Reset

func (ctx Context) Reset()

Reset removes all registered plugins in a Context

type CurrentPlugin added in v0.2.0

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

func GetCurrentPlugin added in v0.2.0

func GetCurrentPlugin(ptr unsafe.Pointer) CurrentPlugin

func (*CurrentPlugin) Alloc added in v0.2.0

func (p *CurrentPlugin) Alloc(n uint) uint

Alloc a new memory block of the given length, returning its offset

func (*CurrentPlugin) Free added in v0.2.0

func (p *CurrentPlugin) Free(offs uint)

Free the memory block specified by the given offset

func (*CurrentPlugin) InputBytes added in v0.3.0

func (p *CurrentPlugin) InputBytes(v unsafe.Pointer) []byte

func (*CurrentPlugin) InputString added in v0.3.0

func (p *CurrentPlugin) InputString(v unsafe.Pointer) string

func (*CurrentPlugin) Length added in v0.2.0

func (p *CurrentPlugin) Length(offs uint) uint

Length returns the number of bytes allocated at the specified offset

func (*CurrentPlugin) Memory added in v0.2.0

func (p *CurrentPlugin) Memory(offs uint) []byte

func (*CurrentPlugin) ReturnBytes added in v0.3.0

func (p *CurrentPlugin) ReturnBytes(v unsafe.Pointer, b []byte)

func (*CurrentPlugin) ReturnString added in v0.3.0

func (p *CurrentPlugin) ReturnString(v unsafe.Pointer, s string)

type Function added in v0.2.0

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

Function is used to define host functions

func NewFunction added in v0.2.0

func NewFunction(name string, inputs []ValType, outputs []ValType, f unsafe.Pointer, userData interface{}) Function

NewFunction creates a new host function with the given name, input/outputs and optional user data, which can be an arbitrary `interface{}`

func (*Function) Free added in v0.2.0

func (f *Function) Free()

Free a function

func (*Function) SetNamespace added in v0.3.0

func (f *Function) SetNamespace(s string)

func (Function) WithNamespace added in v0.3.0

func (f Function) WithNamespace(s string) Function

type Manifest

type Manifest struct {
	Wasm   []Wasm `json:"wasm"`
	Memory struct {
		MaxPages uint32 `json:"max_pages,omitempty"`
	} `json:"memory,omitempty"`
	Config       map[string]string `json:"config,omitempty"`
	AllowedHosts []string          `json:"allowed_hosts,omitempty"`
	AllowedPaths map[string]string `json:"allowed_paths,omitempty"`
	Timeout      uint              `json:"timeout_ms,omitempty"`
}

type Plugin

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

Plugin is used to call WASM functions

func NewPlugin added in v0.4.0

func NewPlugin(module io.Reader, functions []Function, wasi bool) (Plugin, error)

NewPlugin creates a plugin in its own context

func NewPluginFromManifest added in v0.4.0

func NewPluginFromManifest(manifest Manifest, functions []Function, wasi bool) (Plugin, error)

NewPlugin creates a plugin in its own context from a manifest

func (Plugin) Call

func (plugin Plugin) Call(functionName string, input []byte) ([]byte, error)

Call a function by name with the given input, returning the output

func (*Plugin) CancelHandle added in v0.3.0

func (p *Plugin) CancelHandle() CancelHandle

func (*Plugin) Free

func (plugin *Plugin) Free()

Free a plugin

func (Plugin) FunctionExists

func (plugin Plugin) FunctionExists(functionName string) bool

FunctionExists returns true when the named function is present in the plugin

func (Plugin) SetConfig

func (plugin Plugin) SetConfig(data map[string][]byte) error

Set configuration values

func (*Plugin) Update

func (p *Plugin) Update(module io.Reader, functions []Function, wasi bool) error

Update a plugin with a new WASM module

func (*Plugin) UpdateManifest

func (p *Plugin) UpdateManifest(manifest Manifest, functions []Function, wasi bool) error

Update a plugin with a new Manifest

type Size added in v0.2.0

type Size = C.ExtismSize

type Val added in v0.2.0

type Val = C.ExtismVal

type ValType added in v0.2.0

type ValType = C.ExtismValType
var (
	I32       ValType = C.I32
	I64       ValType = C.I64
	F32       ValType = C.F32
	F64       ValType = C.F64
	V128      ValType = C.V128
	FuncRef   ValType = C.FuncRef
	ExternRef ValType = C.ExternRef
)

type Wasm

type Wasm interface{}

type WasmData

type WasmData struct {
	Data []byte `json:"data"`
	Hash string `json:"hash,omitempty"`
	Name string `json:"name,omitempty"`
}

type WasmFile

type WasmFile struct {
	Path string `json:"path"`
	Hash string `json:"hash,omitempty"`
	Name string `json:"name,omitempty"`
}

type WasmUrl

type WasmUrl struct {
	Url     string            `json:"url"`
	Hash    string            `json:"hash,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Name    string            `json:"name,omitempty"`
	Method  string            `json:"method,omitempty"`
}

Jump to

Keyboard shortcuts

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