205 lines
5.7 KiB
Go
205 lines
5.7 KiB
Go
|
|
// Code generated by ndpgen. DO NOT EDIT.
|
||
|
|
//
|
||
|
|
// This file contains wrapper functions for the extism/go-pdk package.
|
||
|
|
// For WASM builds, it provides type aliases and function wrappers that delegate
|
||
|
|
// to the real extism/go-pdk package with zero overhead.
|
||
|
|
//
|
||
|
|
//go:build wasip1
|
||
|
|
|
||
|
|
package pdk
|
||
|
|
|
||
|
|
import (
|
||
|
|
extism "github.com/extism/go-pdk"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Type aliases - zero overhead, full compatibility
|
||
|
|
type HTTPMethod = extism.HTTPMethod
|
||
|
|
type HTTPRequest = extism.HTTPRequest
|
||
|
|
type HTTPRequestMeta = extism.HTTPRequestMeta
|
||
|
|
type HTTPResponse = extism.HTTPResponse
|
||
|
|
type LogLevel = extism.LogLevel
|
||
|
|
type Memory = extism.Memory
|
||
|
|
|
||
|
|
// Constants
|
||
|
|
|
||
|
|
const (
|
||
|
|
LogDebug = extism.LogDebug
|
||
|
|
LogError = extism.LogError
|
||
|
|
LogInfo = extism.LogInfo
|
||
|
|
LogTrace = extism.LogTrace
|
||
|
|
LogWarn = extism.LogWarn
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
MethodConnect = extism.MethodConnect
|
||
|
|
MethodDelete = extism.MethodDelete
|
||
|
|
MethodGet = extism.MethodGet
|
||
|
|
MethodHead = extism.MethodHead
|
||
|
|
MethodOptions = extism.MethodOptions
|
||
|
|
MethodPatch = extism.MethodPatch
|
||
|
|
MethodPost = extism.MethodPost
|
||
|
|
MethodPut = extism.MethodPut
|
||
|
|
MethodTrace = extism.MethodTrace
|
||
|
|
)
|
||
|
|
|
||
|
|
// Functions
|
||
|
|
func Allocate(length int) Memory {
|
||
|
|
return extism.Allocate(length)
|
||
|
|
}
|
||
|
|
func AllocateBytes(data []byte) Memory {
|
||
|
|
return extism.AllocateBytes(data)
|
||
|
|
}
|
||
|
|
|
||
|
|
// AllocateJSON AllocateJSON allocates and saves the type `any` into Memory on the host.
|
||
|
|
func AllocateJSON(v any) (Memory, error) {
|
||
|
|
return extism.AllocateJSON(v)
|
||
|
|
}
|
||
|
|
|
||
|
|
// AllocateString AllocateString allocates and saves the UTF-8 string `data` into Memory on the host.
|
||
|
|
func AllocateString(data string) Memory {
|
||
|
|
return extism.AllocateString(data)
|
||
|
|
}
|
||
|
|
|
||
|
|
// FindMemory FindMemory finds the host memory block at the given `offset`.
|
||
|
|
func FindMemory(offset uint64) Memory {
|
||
|
|
return extism.FindMemory(offset)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetConfig GetConfig returns the config string associated with `key` (if any).
|
||
|
|
func GetConfig(key string) (string, bool) {
|
||
|
|
return extism.GetConfig(key)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetVar GetVar returns the byte slice (if any) associated with `key`.
|
||
|
|
func GetVar(key string) []byte {
|
||
|
|
return extism.GetVar(key)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetVarInt GetVarInt returns the int associated with `key` (or 0 if none).
|
||
|
|
func GetVarInt(key string) int {
|
||
|
|
return extism.GetVarInt(key)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Input Input returns a slice of bytes from the host.
|
||
|
|
func Input() []byte {
|
||
|
|
return extism.Input()
|
||
|
|
}
|
||
|
|
|
||
|
|
// InputJSON InputJSON returns unmartialed JSON data from the host "input".
|
||
|
|
func InputJSON(v any) error {
|
||
|
|
return extism.InputJSON(v)
|
||
|
|
}
|
||
|
|
|
||
|
|
// InputString InputString returns the input data from the host as a UTF-8 string.
|
||
|
|
func InputString() string {
|
||
|
|
return extism.InputString()
|
||
|
|
}
|
||
|
|
|
||
|
|
// JSONFrom JSONFrom unmarshals a `Memory` block located at `offset` from the host into the provided data `v`.
|
||
|
|
func JSONFrom(offset uint64, v any) error {
|
||
|
|
return extism.JSONFrom(offset, v)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Log Log logs the provided UTF-8 string `s` on the host using the provided log `level`.
|
||
|
|
func Log(level LogLevel, s string) {
|
||
|
|
extism.Log(level, s)
|
||
|
|
}
|
||
|
|
|
||
|
|
// LogMemory LogMemory logs the `memory` block on the host using the provided log `level`.
|
||
|
|
func LogMemory(level LogLevel, m Memory) {
|
||
|
|
extism.LogMemory(level, m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewHTTPRequest NewHTTPRequest returns a new `HTTPRequest`.
|
||
|
|
func NewHTTPRequest(method HTTPMethod, url string) *HTTPRequest {
|
||
|
|
return extism.NewHTTPRequest(method, url)
|
||
|
|
}
|
||
|
|
func NewMemory(offset uint64, length uint64) Memory {
|
||
|
|
return extism.NewMemory(offset, length)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Output Output sends the `data` slice of bytes to the host output.
|
||
|
|
func Output(data []byte) {
|
||
|
|
extism.Output(data)
|
||
|
|
}
|
||
|
|
|
||
|
|
// OutputJSON OutputJSON marshals the provided data `v` as output to the host.
|
||
|
|
func OutputJSON(v any) error {
|
||
|
|
return extism.OutputJSON(v)
|
||
|
|
}
|
||
|
|
|
||
|
|
// OutputMemory OutputMemory sends the `mem` Memory to the host output.
|
||
|
|
func OutputMemory(mem Memory) {
|
||
|
|
extism.OutputMemory(mem)
|
||
|
|
}
|
||
|
|
|
||
|
|
// OutputString OutputString sends the UTF-8 string `s` to the host output.
|
||
|
|
func OutputString(s string) {
|
||
|
|
extism.OutputString(s)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ParamBytes ParamBytes returns bytes from Extism host memory given an offset.
|
||
|
|
func ParamBytes(offset uint64) []byte {
|
||
|
|
return extism.ParamBytes(offset)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ParamString ParamString returns UTF-8 string data from Extism host memory given an offset.
|
||
|
|
func ParamString(offset uint64) string {
|
||
|
|
return extism.ParamString(offset)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ParamU32 ParamU32 returns a uint32 from Extism host memory given an offset.
|
||
|
|
func ParamU32(offset uint64) uint32 {
|
||
|
|
return extism.ParamU32(offset)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ParamU64 ParamU64 returns a uint64 from Extism host memory given an offset.
|
||
|
|
func ParamU64(offset uint64) uint64 {
|
||
|
|
return extism.ParamU64(offset)
|
||
|
|
}
|
||
|
|
|
||
|
|
// RemoveVar RemoveVar removes (and frees) the host variable associated with `key`.
|
||
|
|
func RemoveVar(key string) {
|
||
|
|
extism.RemoveVar(key)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ResultBytes ResultBytes allocates bytes and returns the offset in Extism host memory.
|
||
|
|
func ResultBytes(d []byte) uint64 {
|
||
|
|
return extism.ResultBytes(d)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ResultString ResultString allocates a UTF-8 string and returns the offset in Extism host memory.
|
||
|
|
func ResultString(s string) uint64 {
|
||
|
|
return extism.ResultString(s)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ResultU32 ResultU32 allocates a uint32 and returns the offset in Extism host memory.
|
||
|
|
func ResultU32(d uint32) uint64 {
|
||
|
|
return extism.ResultU32(d)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ResultU64 ResultU64 allocates a uint64 and returns the offset in Extism host memory.
|
||
|
|
func ResultU64(d uint64) uint64 {
|
||
|
|
return extism.ResultU64(d)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetError SetError sets the host error string from `err`.
|
||
|
|
func SetError(err error) {
|
||
|
|
extism.SetError(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetErrorString SetErrorString sets the host error string from `err`.
|
||
|
|
func SetErrorString(err string) {
|
||
|
|
extism.SetErrorString(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetVar SetVar sets the host variable associated with `key` to the `value` byte slice.
|
||
|
|
func SetVar(key string, value []byte) {
|
||
|
|
extism.SetVar(key, value)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetVarInt SetVarInt sets the host variable associated with `key` to the `value` int.
|
||
|
|
func SetVarInt(key string, value int) {
|
||
|
|
extism.SetVarInt(key, value)
|
||
|
|
}
|