Documentation
¶
Index ¶
- Constants
- Variables
- func BuildGuestComponent(config GuestBuildConfig) error
- func BuildPlugin(config PluginBuildConfig) error
- func CloseHandles(handles ...Handle) error
- func DescriptorUsesRuntimeHandles(descriptor InterfaceDescriptor) bool
- func EmbedPluginManifest(component []byte, manifest PluginManifest) ([]byte, error)
- func Generate(config Config) error
- func GenerateFile(config Config, filename string) error
- func GenerateFiles(config Config, filenames ...string) error
- func GeneratePackage(config Config, directory string) error
- func GenerateTree(config Config, directory string) error
- func InspectRequiredCapabilities(filename string) ([]string, error)
- func InspectRequiredCapabilitiesContext(ctx context.Context, filename string) ([]string, error)
- func InspectRequiredCapabilitiesWithOptions(filename string, options RuntimeOptions) ([]string, error)
- func InspectRequiredCapabilitiesWithOptionsContext(ctx context.Context, filename string, options RuntimeOptions) ([]string, error)
- func IsHostBuild() bool
- func IsPluginBuild() bool
- func MatchResult[T, E, Value any](r Result[T, E], ok func(T) Value, fail func(E) Value) Value
- func NewWITError[E any](value E) error
- func RequireCompatible(report ValidationReport) error
- func RequireHostBuild() error
- func RequirePluginBuild() error
- func TupleValue[T any](tuple Tuple, index int) (T, bool, error)
- type CallObserver
- type CallbackFuelPolicy
- type CapabilityPolicy
- type CapabilityPolicyError
- type CappedFuelAllowance
- type Char
- type ComponentComposition
- type CompositionPlug
- type Config
- type Contract
- func InspectComponent(filename string) (Contract, error)
- func InspectComponentBytes(data []byte) (Contract, error)
- func InspectComponentBytesContext(ctx context.Context, data []byte) (Contract, error)
- func InspectComponentBytesWithOptions(data []byte, options RuntimeOptions) (Contract, error)
- func InspectComponentBytesWithOptionsContext(ctx context.Context, data []byte, options RuntimeOptions) (Contract, error)
- func InspectComponentContext(ctx context.Context, filename string) (Contract, error)
- func InspectComponentWithOptions(filename string, options RuntimeOptions) (Contract, error)
- func InspectComponentWithOptionsContext(ctx context.Context, filename string, options RuntimeOptions) (Contract, error)
- type ContractDifference
- type ContractValidationError
- type CycleEvent
- type DenyFuelRequests
- type ExecutionLimitError
- type ExecutionRole
- type FixedFuelAllowance
- type FuelDecision
- type FuelDenialReason
- type FuelDisabledError
- type FuelGrant
- type FuelRequest
- type FuelRequestError
- type FuelRequestEvent
- type FuelRequestLimits
- type FuelRequestPolicy
- type GenerationMode
- type Generator
- type GuestBuildConfig
- type Handle
- func (h Handle) Close() error
- func (h Handle) ID() uint64
- func (h Handle) IsClosed() bool
- func (h Handle) IsKind(kind HandleKind) bool
- func (h Handle) Kind() HandleKind
- func (h Handle) MarshalJSON() ([]byte, error)
- func (h Handle) Owned() bool
- func (h Handle) String() string
- func (h *Handle) UnmarshalJSON(data []byte) error
- func (h Handle) Valid() error
- type HandleKind
- type Host
- func (h *Host) AutoResolveProvider(expected InterfaceDescriptor) (*ProviderHandle, error)
- func (h *Host) Close() error
- func (h *Host) RegisterProvider(name string, descriptor InterfaceDescriptor, call ProviderCall, ...) (*ProviderHandle, error)
- func (h *Host) ReplaceProvider(name string, descriptor InterfaceDescriptor, call ProviderCall, ...) (*ProviderHandle, error)
- func (h *Host) ResolveProvider(name string, expected InterfaceDescriptor) (*ProviderHandle, error)
- func (h *Host) UnregisterProvider(interfaceID, name string) error
- type HostFunc
- type HostFuncContext
- type HostImport
- type HostOptions
- type HostPolicy
- type InterfaceDescriptor
- type LimitEvent
- type Map
- type NativeBridgeBackend
- type NestedPluginOptions
- type NestedPluginRequest
- type NestedPluginResolver
- type Option
- type PerPluginFuelAllowance
- type Permissions
- type PluginBox
- type PluginBuildConfig
- type PluginCallContext
- type PluginCallError
- type PluginCallEvent
- type PluginCallFrame
- type PluginDependencyError
- type PluginGrant
- type PluginHost
- func (h *PluginHost) BoxCount() int
- func (h *PluginHost) Close() error
- func (h *PluginHost) OpenBox(filename string, options RuntimeOptions, imports []HostImport) (*PluginBox, error)
- func (h *PluginHost) OpenBoxContext(ctx context.Context, filename string, options RuntimeOptions, ...) (*PluginBox, error)
- type PluginLimits
- type PluginManifest
- type ProviderCall
- type ProviderEvent
- type ProviderHandle
- type RegisterOption
- type RegisterOptions
- type Result
- type Runtime
- func LoadRuntime(filename string) (*Runtime, error)
- func LoadRuntimeContext(ctx context.Context, filename string) (*Runtime, error)
- func LoadRuntimeFromBytes(data []byte) (*Runtime, error)
- func LoadRuntimeFromBytesContext(ctx context.Context, data []byte) (*Runtime, error)
- func LoadRuntimeFromBytesWithContract(data []byte, options RuntimeOptions, imports []HostImport, contract Contract) (*Runtime, error)
- func LoadRuntimeFromBytesWithContractContext(ctx context.Context, data []byte, options RuntimeOptions, imports []HostImport, ...) (*Runtime, error)
- func LoadRuntimeFromBytesWithImports(data []byte, options RuntimeOptions, imports []HostImport) (*Runtime, error)
- func LoadRuntimeFromBytesWithImportsContext(ctx context.Context, data []byte, options RuntimeOptions, imports []HostImport) (*Runtime, error)
- func LoadRuntimeFromBytesWithOptions(data []byte, options RuntimeOptions) (*Runtime, error)
- func LoadRuntimeFromBytesWithOptionsContext(ctx context.Context, data []byte, options RuntimeOptions) (*Runtime, error)
- func LoadRuntimeWithContract(filename string, options RuntimeOptions, imports []HostImport, ...) (*Runtime, error)
- func LoadRuntimeWithContractContext(ctx context.Context, filename string, options RuntimeOptions, ...) (*Runtime, error)
- func LoadRuntimeWithImports(filename string, options RuntimeOptions, imports []HostImport) (*Runtime, error)
- func LoadRuntimeWithImportsContext(ctx context.Context, filename string, options RuntimeOptions, ...) (*Runtime, error)
- func LoadRuntimeWithOptions(filename string, options RuntimeOptions) (*Runtime, error)
- func LoadRuntimeWithOptionsContext(ctx context.Context, filename string, options RuntimeOptions) (*Runtime, error)
- func (r *Runtime) AllPluginPaths() []string
- func (r *Runtime) Call(name string, args ...any) (any, error)
- func (r *Runtime) CallContext(ctx context.Context, name string, args ...any) (any, error)
- func (r *Runtime) Close() error
- func (r *Runtime) ComponentPath() string
- func (r *Runtime) Composition() ComponentComposition
- func (r *Runtime) EffectiveOptions() RuntimeOptions
- func (r *Runtime) FuelRemaining() (uint64, error)
- func (r *Runtime) IsClosed() bool
- func (r *Runtime) NestedPluginPaths() []string
- func (r *Runtime) SetFuel(fuel uint64) error
- type RuntimeCallInfo
- type RuntimeFuelInfo
- type RuntimeLimitError
- type RuntimeLimits
- type RuntimeOptions
- type RuntimeSecurityObserver
- type SignatureMismatch
- type Tuple
- type Tuple0
- type Tuple1
- type Tuple2
- type Tuple3
- type Tuple4
- type Tuple5
- type Tuple6
- type Tuple7
- type Tuple8
- type Tuple9
- type Tuple10
- type Tuple11
- type Tuple12
- type Tuple13
- type Tuple14
- type Tuple15
- type Tuple16
- type TypeCodec
- type TypeCodecFuncs
- type Unit
- type ValidationReport
- func CompareContracts(expected, actual Contract) (ValidationReport, error)
- func ValidateComponent(filename string, expected Contract) (ValidationReport, error)
- func ValidateComponentBytes(data []byte, expected Contract) (ValidationReport, error)
- func ValidateComponentBytesContext(ctx context.Context, data []byte, expected Contract) (ValidationReport, error)
- func ValidateComponentBytesWithOptions(data []byte, options RuntimeOptions, expected Contract) (ValidationReport, error)
- func ValidateComponentBytesWithOptionsContext(ctx context.Context, data []byte, options RuntimeOptions, expected Contract) (ValidationReport, error)
- func ValidateComponentContext(ctx context.Context, filename string, expected Contract) (ValidationReport, error)
- func ValidateComponentWithOptions(filename string, options RuntimeOptions, expected Contract) (ValidationReport, error)
- func ValidateComponentWithOptionsContext(ctx context.Context, filename string, options RuntimeOptions, ...) (ValidationReport, error)
- type ValueLimits
- type WITError
- type WITInputMode
Constants ¶
const RuntimeSystemInterfaceID = "witgo:runtime/runtime@1.0.0"
Variables ¶
var ( ErrPluginNotRegistered = errors.New("plugin provider is not registered") ErrPluginAlreadyRegistered = errors.New("plugin provider is already registered") ErrPluginDependencyMismatch = errors.New("plugin dependency contract mismatch") ErrPluginCallCycle = errors.New("plugin call cycle detected") ErrPluginCallDepthExceeded = errors.New("plugin call depth exceeded") ErrPluginProviderClosed = errors.New("plugin provider is closed") ErrCrossRuntimeHandle = errors.New("handle cannot cross plugin runtime boundary") )
var ( ErrHostOnlyAPI = errors.New("witgo API is only available in a host build") ErrPluginOnlyAPI = errors.New("witgo API is only available in a WebAssembly plugin build") )
var ( ErrUnknownWasmKind = errors.New("unknown WebAssembly kind") ErrCoreModule = errors.New("core WebAssembly modules are not supported; build a Component Model component") ErrFuelDisabled = errors.New("WebAssembly fuel metering is disabled") ErrRuntimeClosed = errors.New("component runtime is closed") ErrBridgeProtocolMismatch = errors.New("component bridge protocol mismatch") ErrBridgeVersionMismatch = errors.New("component bridge version mismatch") ErrContractMismatch = errors.New("component function contract mismatch") ErrCapabilityDenied = errors.New("component capability policy denied required host import") ErrHandleClosed = errors.New("component handle is closed or unknown") ErrResultTooLarge = errors.New("WebAssembly result exceeds configured limit") ErrNestedPluginNotFound = errors.New("nested plugin provider was not found") ErrNestedPluginAmbiguous = errors.New("multiple nested plugins provide the same import") ErrNestedPluginCycle = errors.New("nested plugin dependency cycle") ErrNestedPluginPathDenied = errors.New("nested plugin dependency path is outside the host policy") ErrNestedPluginBudget = errors.New("plugin box resource budget is too small") )
var ( ErrFuelRequestDisabled = errors.New("additional fuel requests are disabled") ErrFuelRequestDenied = errors.New("additional fuel request was denied") ErrFuelRequestTooLarge = errors.New("additional fuel request exceeds a hard limit") ErrFuelRequestLimitReached = errors.New("additional fuel request limit reached") ErrRuntimeClosing = errors.New("component runtime is closing") ErrArgumentTooLarge = errors.New("component argument exceeds configured limit") ErrValueDepthExceeded = errors.New("component value nesting exceeds configured limit") ErrProviderClosing = errors.New("plugin provider is closing") ErrCallCancelled = errors.New("component call was cancelled") )
var ErrCallTimeout = errors.New("WebAssembly call timed out")
var ErrFuelExhausted = errors.New("WebAssembly fuel exhausted")
Functions ¶
func BuildGuestComponent ¶ added in v1.1.0
func BuildGuestComponent(config GuestBuildConfig) error
BuildGuestComponent builds a registered Go guest as a WASI Preview 2 WebAssembly Component. Canonical ABI glue must have been generated in guest mode before this function is called.
func BuildPlugin ¶ added in v1.1.0
func BuildPlugin(config PluginBuildConfig) error
BuildPlugin generates guest bindings and builds the loadable component.
func CloseHandles ¶
CloseHandles closes every handle and returns the first error after all close operations have been attempted.
func DescriptorUsesRuntimeHandles ¶
func DescriptorUsesRuntimeHandles(descriptor InterfaceDescriptor) bool
DescriptorUsesRuntimeHandles reports whether an interface contains values whose ownership is tied to one Component Model Store.
func EmbedPluginManifest ¶
func EmbedPluginManifest(component []byte, manifest PluginManifest) ([]byte, error)
EmbedPluginManifest appends a witgo custom section to a binary Component Model component. It is intended for plugin build pipelines.
func GenerateFile ¶
GenerateFile creates bindings from exactly one .wit file.
func GenerateFiles ¶
GenerateFiles creates one binding package from an explicit set of .wit files. Every file must belong to the same WIT package.
func GeneratePackage ¶
GeneratePackage creates bindings from all .wit files directly inside a package directory. Nested package and deps directories are not traversed.
func GenerateTree ¶
GenerateTree recursively loads every .wit file below directory. It is useful for split source trees that contain one WIT package and no dependency packages.
func InspectRequiredCapabilities ¶
InspectRequiredCapabilities returns sorted component imports suitable for a capability decision before startup.
func InspectRequiredCapabilitiesWithOptions ¶
func InspectRequiredCapabilitiesWithOptions(filename string, options RuntimeOptions) ([]string, error)
InspectRequiredCapabilitiesWithOptions is InspectRequiredCapabilities with explicit bridge selection options.
func IsHostBuild ¶
func IsHostBuild() bool
func IsPluginBuild ¶
func IsPluginBuild() bool
func MatchResult ¶
Match evaluates the callback for the active branch.
func NewWITError ¶
NewWITError wraps a canonical WIT result error payload as a Go error.
func RequireCompatible ¶
func RequireCompatible(report ValidationReport) error
RequireCompatible returns nil when report is compatible and otherwise returns an error wrapping ErrContractMismatch.
func RequireHostBuild ¶
func RequireHostBuild() error
RequireHostBuild rejects APIs that need the native Component Model runtime when the current binary is itself a WebAssembly plugin.
func RequirePluginBuild ¶
func RequirePluginBuild() error
RequirePluginBuild can be used by generated guest entry points to reject an accidental native build.
Types ¶
type CallObserver ¶
type CallObserver interface {
OnCallStart(PluginCallEvent)
OnCallFinish(PluginCallEvent)
}
type CallbackFuelPolicy ¶
type CallbackFuelPolicy func(context.Context, FuelRequest) (FuelDecision, error)
func (CallbackFuelPolicy) DecideFuel ¶
func (p CallbackFuelPolicy) DecideFuel(ctx context.Context, request FuelRequest) (FuelDecision, error)
type CapabilityPolicy ¶
CapabilityPolicy controls which host import functions a component may require. Patterns support:
- exact function names: namespace:pkg/interface@1.0.0#func
- interface-level rules: namespace:pkg/interface@1.0.0
- prefix wildcards ending in *: namespace:pkg/interface@1.0.0#read*
- "*" to match everything
Deny rules override allow rules. If Allow is empty, every capability is allowed except those matched by Deny.
func (CapabilityPolicy) Allows ¶
func (p CapabilityPolicy) Allows(function string) bool
Allows reports whether function is allowed by policy.
func (CapabilityPolicy) ValidateImports ¶
func (p CapabilityPolicy) ValidateImports(imports []string) error
ValidateImports rejects required imports denied by policy.
type CapabilityPolicyError ¶
type CapabilityPolicyError struct {
Denied []string
}
CapabilityPolicyError reports which required capabilities were denied by a policy.
func (*CapabilityPolicyError) Error ¶
func (e *CapabilityPolicyError) Error() string
func (*CapabilityPolicyError) Unwrap ¶
func (e *CapabilityPolicyError) Unwrap() error
type CappedFuelAllowance ¶
type CappedFuelAllowance struct {
MaxGrantPerRequest uint64
MaxTotalGrant uint64
MaxRequestsPerCall uint32
}
func (CappedFuelAllowance) DecideFuel ¶
func (p CappedFuelAllowance) DecideFuel(_ context.Context, request FuelRequest) (FuelDecision, error)
type Char ¶
type Char rune
Char is a Unicode scalar value encoded according to the WIT char ABI.
func (Char) MarshalJSON ¶
func (*Char) UnmarshalJSON ¶
type ComponentComposition ¶
type ComponentComposition struct {
Component string `json:"component"`
Dependencies []CompositionPlug `json:"dependencies,omitempty"`
}
ComponentComposition is a complete same-Store composition rooted at a consumer component.
type CompositionPlug ¶
type CompositionPlug struct {
Interface string `json:"interface"`
Component string `json:"component"`
Dependencies []CompositionPlug `json:"dependencies,omitempty"`
}
CompositionPlug describes one exact Component Model import edge. Component provides Interface; Dependencies satisfy imports of that provider itself. Paths are normalized by the runtime before they reach the native bridge.
type Config ¶
type Config struct {
// WIT is a .wit file or directory. WITMode controls directory traversal.
WIT string
// WITFiles is an explicit, ordered-independent set of .wit files. It cannot
// be combined with WIT and is primarily used by GenerateFiles.
WITFiles []string
// WITMode defaults to WITInputAuto for backwards compatibility.
WITMode WITInputMode
// GoOverlay is an optional versioned YAML file that changes the public Go
// representation while preserving the canonical WIT wire types.
GoOverlay string
// Output is the directory where generated bindings are written.
Output string
// Package is the Go package name. When empty, it is derived from WIT package.
Package string
// Filename defaults to bindings.gen.go.
Filename string
// EnableRuntimeAPI emits the opt-in witgo:runtime@1.0.0 guest facade and
// enables its host binding in generated Open functions.
EnableRuntimeAPI bool
// Mode selects which side of the component boundary is generated. The zero
// value is GenerateHost and preserves the historical host SDK.
Mode GenerationMode
// World selects the WIT world in guest mode. It may be omitted when the
// input contains exactly one world.
World string
// PackageRoot is the Go import path of Output. Guest bindings use it for
// the packages generated below Output. When empty it is derived from the
// nearest go.mod.
PackageRoot string
// GuestBindgen is an optional path to wit-bindgen-go. The default searches
// PATH. It is used only in guest mode.
GuestBindgen string
}
type Contract ¶
Contract describes the functions expected by generated bindings. Names are either "interface#function" or a direct world function name. Signatures use a deterministic structural representation of Component Model value types.
func InspectComponent ¶
InspectComponent returns the imported and exported function names exposed by a WebAssembly component without instantiating it.
func InspectComponentBytes ¶
InspectComponentBytes inspects a component held in memory.
func InspectComponentBytesWithOptions ¶
func InspectComponentBytesWithOptions(data []byte, options RuntimeOptions) (Contract, error)
InspectComponentBytesWithOptions is InspectComponentBytes with explicit bridge options.
func InspectComponentContext ¶
func InspectComponentWithOptions ¶
func InspectComponentWithOptions(filename string, options RuntimeOptions) (Contract, error)
InspectComponentWithOptions is InspectComponent with bridge selection and resource options. Execution limits are not consumed because inspection does not instantiate or call the component.
func (Contract) ExportNames ¶
ExportNames returns a sorted copy of the provided plugin function names.
func (Contract) FunctionNames ¶
FunctionNames returns all imported and exported function names in sorted order without duplicates.
func (Contract) ImportNames ¶
ImportNames returns a sorted copy of the required host function names.
func (Contract) Provides ¶
Provides reports whether the component exports the named plugin function.
type ContractDifference ¶
ContractDifference describes missing and unexpected function names on one side of a component contract.
func (ContractDifference) Count ¶
func (d ContractDifference) Count() int
Count returns the total number of missing and unexpected functions.
func (ContractDifference) Empty ¶
func (d ContractDifference) Empty() bool
Empty reports whether there are no missing or unexpected functions.
type ContractValidationError ¶
type ContractValidationError struct {
Report ValidationReport
}
ContractValidationError wraps an incompatible report and supports errors.Is(err, ErrContractMismatch).
func (*ContractValidationError) Error ¶
func (e *ContractValidationError) Error() string
func (*ContractValidationError) Unwrap ¶
func (e *ContractValidationError) Unwrap() error
type CycleEvent ¶
type CycleEvent struct{ CallPath []PluginCallFrame }
type DenyFuelRequests ¶
type DenyFuelRequests struct{}
func (DenyFuelRequests) DecideFuel ¶
func (DenyFuelRequests) DecideFuel(context.Context, FuelRequest) (FuelDecision, error)
type ExecutionLimitError ¶
func (*ExecutionLimitError) Error ¶
func (e *ExecutionLimitError) Error() string
func (*ExecutionLimitError) Is ¶
func (e *ExecutionLimitError) Is(target error) bool
func (*ExecutionLimitError) Unwrap ¶
func (e *ExecutionLimitError) Unwrap() error
type ExecutionRole ¶
type ExecutionRole string
ExecutionRole identifies which side of the Component Model boundary this binary implements.
const ( ExecutionRoleHost ExecutionRole = "host" ExecutionRolePlugin ExecutionRole = "plugin" )
func CurrentExecutionRole ¶
func CurrentExecutionRole() ExecutionRole
CurrentExecutionRole is selected at compile time. Native targets are hosts; GOARCH=wasm targets are plugins.
type FixedFuelAllowance ¶
type FixedFuelAllowance struct{ Grant uint64 }
func (FixedFuelAllowance) DecideFuel ¶
func (p FixedFuelAllowance) DecideFuel(_ context.Context, request FuelRequest) (FuelDecision, error)
type FuelDecision ¶
type FuelDecision struct{ Grant uint64 }
type FuelDenialReason ¶
type FuelDenialReason string
const ( FuelDeniedDisabled FuelDenialReason = "disabled" FuelDeniedPolicy FuelDenialReason = "policy-denied" FuelDeniedRequestTooLarge FuelDenialReason = "request-too-large" FuelDeniedRequestLimitReached FuelDenialReason = "request-limit-reached" FuelDeniedCallFinishing FuelDenialReason = "call-finishing" FuelDeniedRuntimeClosing FuelDenialReason = "runtime-closing" FuelDeniedInvalidReason FuelDenialReason = "invalid-reason" )
type FuelDisabledError ¶
type FuelDisabledError struct{ Cause error }
func (*FuelDisabledError) Error ¶
func (e *FuelDisabledError) Error() string
func (*FuelDisabledError) Is ¶
func (e *FuelDisabledError) Is(target error) bool
func (*FuelDisabledError) Unwrap ¶
func (e *FuelDisabledError) Unwrap() error
type FuelRequest ¶
type FuelRequestError ¶
type FuelRequestError struct {
PluginID string
CallID string
Requested uint64
Reason FuelDenialReason
Cause error
}
func (*FuelRequestError) Error ¶
func (e *FuelRequestError) Error() string
func (*FuelRequestError) Is ¶
func (e *FuelRequestError) Is(target error) bool
func (*FuelRequestError) Unwrap ¶
func (e *FuelRequestError) Unwrap() error
type FuelRequestEvent ¶
type FuelRequestLimits ¶
type FuelRequestPolicy ¶
type FuelRequestPolicy interface {
DecideFuel(context.Context, FuelRequest) (FuelDecision, error)
}
type GenerationMode ¶ added in v1.1.0
type GenerationMode uint8
GenerationMode selects the API surface emitted from a WIT world.
const ( // GenerateHost emits loaders, validation and composition clients. GenerateHost GenerationMode = iota // GenerateGuest emits Go/TinyGo Component Model guest bindings. Host-only // constructors such as OpenPlugin are deliberately absent. GenerateGuest )
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates Go bindings from WIT contracts.
func NewGenerator ¶
NewGenerator validates the configuration and creates a reusable generator.
type GuestBuildConfig ¶ added in v1.1.0
type GuestBuildConfig struct {
// Main is the plugin main package or .go file.
Main string
// WITPackage is a WIT package accepted by TinyGo --wit-package. TinyGo
// accepts a WIT package directory; a packaged .wasm may also be used.
WITPackage string
// World is the implemented WIT world.
World string
// Output is the resulting component .wasm path.
Output string
// TinyGo optionally overrides the tinygo executable path.
TinyGo string
// NoDebug removes debug data from the component.
NoDebug bool
// Manifest is embedded after a successful build. A nil manifest omits the
// witgo custom section; an empty non-nil manifest is still embedded.
Manifest *PluginManifest
}
GuestBuildConfig describes a TinyGo WASI Preview 2 component build. The WIT package is embedded by TinyGo as Component Type metadata and used to turn the Canonical ABI core module into a WebAssembly Component.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is a live Component Model resource, future, stream, or error-context. Handles are bound to the Runtime that produced them and may be passed back to calls on that Runtime. Close releases the bridge-side handle explicitly. Copies of a Handle share the same lifecycle state.
func (Handle) Close ¶
Close explicitly drops a resource or closes a future/stream. Error-context handles are removed from the bridge table. Close is idempotent.
func (Handle) ID ¶
ID returns the runtime-local handle identifier. It is useful for logging, but it is not portable between Runtime values or process executions.
func (Handle) IsKind ¶
func (h Handle) IsKind(kind HandleKind) bool
IsKind reports whether this live handle has kind.
func (Handle) Kind ¶
func (h Handle) Kind() HandleKind
Kind returns the Component Model handle kind.
func (Handle) MarshalJSON ¶
MarshalJSON encodes the runtime-local token understood by the native bridge.
func (Handle) Owned ¶
Owned reports whether a resource handle was lifted as own<T>. It is false for borrow<T> and for handle kinds where ownership is implicit.
func (*Handle) UnmarshalJSON ¶
UnmarshalJSON rejects detached handle tokens. Handles must be created by a Runtime so they cannot accidentally be attached to the wrong Store.
type HandleKind ¶
type HandleKind string
HandleKind identifies an opaque Component Model handle.
const ( HandleResource HandleKind = "resource" HandleFuture HandleKind = "future" HandleStream HandleKind = "stream" HandleErrorContext HandleKind = "error-context" )
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host owns the provider registry and call policy. It never holds its registry mutex while user code or a component runtime is executing.
func NewHost ¶
func NewHost(options ...HostOptions) (*Host, error)
func (*Host) AutoResolveProvider ¶
func (h *Host) AutoResolveProvider(expected InterfaceDescriptor) (*ProviderHandle, error)
func (*Host) RegisterProvider ¶
func (h *Host) RegisterProvider(name string, descriptor InterfaceDescriptor, call ProviderCall, options ...RegisterOption) (*ProviderHandle, error)
func (*Host) ReplaceProvider ¶
func (h *Host) ReplaceProvider(name string, descriptor InterfaceDescriptor, call ProviderCall, options ...RegisterOption) (*ProviderHandle, error)
func (*Host) ResolveProvider ¶
func (h *Host) ResolveProvider(name string, expected InterfaceDescriptor) (*ProviderHandle, error)
func (*Host) UnregisterProvider ¶
type HostFunc ¶
HostFunc implements one imported WIT function. Arguments and the result use ordinary Go values with the same shape as their WIT types.
type HostFuncContext ¶
HostFuncContext implements an imported WIT function with cancellation and deadline propagation. New code should prefer it over HostFunc.
type HostImport ¶
type HostImport struct {
Interface string
Function string
Call HostFunc
CallContext HostFuncContext
}
HostImport grants a component one host capability.
type HostOptions ¶
type HostOptions struct {
MaxCallDepth int
RejectCycles bool
CallTimeout time.Duration
Observer CallObserver
FuelRequestPolicy FuelRequestPolicy
FuelRequestLimits FuelRequestLimits
SecurityObserver RuntimeSecurityObserver
}
HostOptions controls transparent calls between registered providers.
type HostPolicy ¶ added in v1.1.0
type HostPolicy struct {
Public PluginGrant
Plugins map[string]PluginGrant
RuntimeAPI bool
SearchPaths []string
Observer RuntimeSecurityObserver
BridgePath string
BridgeSHA256 string
}
HostPolicy is the convenient, secure entry point for configuring plugins. Public applies to every plugin; Plugins adds grants by PluginID.
func (HostPolicy) Options ¶ added in v1.1.0
func (p HostPolicy) Options(pluginID string) (RuntimeOptions, error)
Options resolves immutable runtime options for pluginID. Public and named permissions are combined, while non-zero named limits replace public ones.
type InterfaceDescriptor ¶
InterfaceDescriptor is the stable identity and structural contract of one generated WIT interface.
type LimitEvent ¶
type Map ¶
type Map[K comparable, V any] map[K]V
Map represents a Component Model map<K,V> using its ordered pair wire form. Go map iteration order is intentionally not part of the ABI.
func NewMap ¶
func NewMap[K comparable, V any](capacity ...int) Map[K, V]
NewMap constructs a map with optional initial capacity.
func (Map[K, V]) MarshalJSON ¶
func (*Map[K, V]) UnmarshalJSON ¶
type NativeBridgeBackend ¶
type NativeBridgeBackend string
NativeBridgeBackend identifies the platform loader selected at build time.
const ( NativeBridgeBackendPureGo NativeBridgeBackend = "purego" NativeBridgeBackendCGo NativeBridgeBackend = "cgo" NativeBridgeBackendUnsupported NativeBridgeBackend = "unsupported" )
func CurrentNativeBridgeBackend ¶
func CurrentNativeBridgeBackend() NativeBridgeBackend
CurrentNativeBridgeBackend reports which loader this binary uses.
type NestedPluginOptions ¶
type NestedPluginOptions struct {
Disabled bool
// SearchPaths is only a fallback for components without PluginManifest.
SearchPaths []string
// AllowedRoots restricts relative dependency paths declared by plugins.
// The zero value allows only the parent component directory tree.
AllowedRoots []string
MaxCandidates int
Resolver NestedPluginResolver
}
NestedPluginOptions controls automatic plugin-to-plugin dependency wiring. A component requests dependencies through ordinary WIT imports. When a manual HostImport is absent, witgo searches for a component exporting the exact same function name and structural signature.
type NestedPluginRequest ¶
NestedPluginRequest describes one unresolved WIT import.
type NestedPluginResolver ¶
type NestedPluginResolver func(ctx context.Context, request NestedPluginRequest) (string, error)
NestedPluginResolver returns a component path for an unresolved import. Returning an empty path means that no provider is available.
type Option ¶
Option represents a WIT option<T> without using nil as application state.
func FlatMapOption ¶
FlatMapOption chains an option-producing transformation.
func OptionFromPointer ¶
OptionFromPointer converts nil to None and a non-nil pointer to Some.
func (Option[T]) MarshalJSON ¶
func (Option[T]) Or ¶
func (o Option[T]) Or(fallback T) T
Or returns the contained value or fallback.
func (Option[T]) Pointer ¶
func (o Option[T]) Pointer() *T
Pointer returns a pointer to a copy of the contained value or nil.
func (*Option[T]) UnmarshalJSON ¶
type PerPluginFuelAllowance ¶
type PerPluginFuelAllowance map[string]FuelRequestPolicy
func (PerPluginFuelAllowance) DecideFuel ¶
func (p PerPluginFuelAllowance) DecideFuel(ctx context.Context, request FuelRequest) (FuelDecision, error)
type Permissions ¶ added in v1.1.0
type Permissions struct {
All bool
System bool
Network bool
Files bool
LoadPlugin bool
Allow []string
Deny []string
}
Permissions describes ambient capabilities granted by the host. Grants are additive: a plugin receives Public permissions plus its named grant. Deny rules always win. The zero value grants nothing.
type PluginBox ¶
type PluginBox struct {
// contains filtered or unexported fields
}
PluginBox is an isolated root runtime and all automatically loaded children.
func (*PluginBox) PluginPaths ¶
PluginPaths returns direct nested providers selected for the root runtime.
type PluginBuildConfig ¶ added in v1.1.0
type PluginBuildConfig struct {
Generate Config
Build GuestBuildConfig
}
PluginBuildConfig describes the complete generated-contract plugin build.
type PluginCallContext ¶
type PluginCallContext struct {
ID string
ParentID string
Depth int
Path []PluginCallFrame
Deadline time.Time
}
PluginCallContext describes the current nested call chain.
func PluginCallContextFromContext ¶
func PluginCallContextFromContext(ctx context.Context) (PluginCallContext, bool)
type PluginCallError ¶
type PluginCallError struct {
Consumer string
Provider string
Frame PluginCallFrame
Path []PluginCallFrame
Cause error
}
PluginCallError preserves the routed call path and underlying runtime error.
func (*PluginCallError) Error ¶
func (e *PluginCallError) Error() string
func (*PluginCallError) Unwrap ¶
func (e *PluginCallError) Unwrap() error
type PluginCallEvent ¶
type PluginCallEvent struct {
CallID string
ParentCallID string
Depth int
Consumer string
Provider string
Interface string
Function string
Path []PluginCallFrame
Started time.Time
Duration time.Duration
Err error
}
PluginCallEvent is delivered to an observer outside registry locks.
type PluginCallFrame ¶
PluginCallFrame identifies one routed provider call.
type PluginDependencyError ¶
type PluginDependencyError struct {
Consumer string
Provider string
Interface string
Report ValidationReport
CallPath []PluginCallFrame
}
PluginDependencyError reports a structural mismatch before a consumer is instantiated. It supports errors.Is(err, ErrPluginDependencyMismatch).
func (*PluginDependencyError) Error ¶
func (e *PluginDependencyError) Error() string
func (*PluginDependencyError) Unwrap ¶
func (e *PluginDependencyError) Unwrap() error
type PluginGrant ¶ added in v1.1.0
type PluginGrant struct {
Permissions Permissions
Limits PluginLimits
// AllowedPluginRoots bounds components loaded through a plugin manifest.
AllowedPluginRoots []string
}
PluginGrant adds permissions and optionally replaces public limits for one logical plugin ID.
type PluginHost ¶
type PluginHost struct {
// contains filtered or unexported fields
}
PluginHost owns immutable discovery settings. Each load performed through a host creates a separate box, so plugin instances and their state are never shared between top-level loads.
func NewPluginHost ¶
func NewPluginHost(options NestedPluginOptions) (*PluginHost, error)
NewPluginHost creates a host-router for automatic nested dependencies.
func (*PluginHost) BoxCount ¶
func (h *PluginHost) BoxCount() int
BoxCount returns the number of live independent root boxes.
func (*PluginHost) Close ¶
func (h *PluginHost) Close() error
Close closes every independent box created through this host. It is safe to call more than once; a closed host rejects new boxes.
func (*PluginHost) OpenBox ¶
func (h *PluginHost) OpenBox(filename string, options RuntimeOptions, imports []HostImport) (*PluginBox, error)
OpenBox is OpenBoxContext with context.Background().
func (*PluginHost) OpenBoxContext ¶
func (h *PluginHost) OpenBoxContext(ctx context.Context, filename string, options RuntimeOptions, imports []HostImport) (*PluginBox, error)
OpenBoxContext creates a completely independent component box using this host's discovery policy.
type PluginLimits ¶ added in v1.1.0
type PluginLimits struct {
Fuel uint64
FuelPerCall uint64
Timeout time.Duration
MemoryLimitBytes int64
MaxResultBytes uint64
InstanceLimit int64
ValueLimits ValueLimits
FuelRequests FuelRequestLimits
FuelPolicy FuelRequestPolicy
}
PluginLimits are host-owned execution limits for one plugin. A plugin manifest cannot increase them.
type PluginManifest ¶
PluginManifest is metadata owned by a plugin. Dependencies map a complete WIT import or an interface name to a component path relative to the plugin. Resource limits intentionally cannot be declared here; only the host owns the box budget.
func ReadPluginManifest ¶
func ReadPluginManifest(filename string) (PluginManifest, bool, error)
ReadPluginManifest reads an embedded manifest or the sidecar <component>.witgo.json used for textual components and development builds.
type ProviderCall ¶
ProviderCall is the typed-neutral core callback. Generated registration helpers create it from a strongly typed generated interface.
type ProviderEvent ¶
type ProviderHandle ¶
type ProviderHandle struct {
// contains filtered or unexported fields
}
ProviderHandle is a stable, concurrency-safe reference. Unregister prevents new leases and waits for calls that already acquired one.
func (*ProviderHandle) CallContext ¶
func (*ProviderHandle) CompositionPlug ¶
func (p *ProviderHandle) CompositionPlug() (CompositionPlug, bool)
CompositionPlug returns the exact edge needed to instantiate this provider in the consumer's Store. The full interface ID prevents short-name clashes.
func (*ProviderHandle) Descriptor ¶
func (p *ProviderHandle) Descriptor() InterfaceDescriptor
func (*ProviderHandle) Name ¶
func (p *ProviderHandle) Name() string
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
func ComponentProvider ¶
func ComponentProvider(composition ComponentComposition) RegisterOption
ComponentProvider marks a provider as an export of a Component Model graph. Generated consumers use this metadata to compose the provider into their own Store instead of proxying Store-owned handles through Go.
func ExternallyOwnedProvider ¶
func ExternallyOwnedProvider() RegisterOption
func OwnedProvider ¶
func OwnedProvider(close func() error) RegisterOption
type RegisterOptions ¶
type RegisterOptions struct {
Owned bool
Close func() error
Composition ComponentComposition
}
type Result ¶
type Result[T, E any] struct { // contains filtered or unexported fields }
Result is a type-safe WIT result<OK, Err>. Exactly one branch is active.
func MapResultErr ¶
MapResultErr transforms the error branch.
func (Result[T, E]) MarshalJSON ¶
func (Result[T, E]) Or ¶
func (r Result[T, E]) Or(fallback T) T
Or returns the success value or fallback.
func (*Result[T, E]) UnmarshalJSON ¶
type Runtime ¶
func LoadRuntime ¶
func LoadRuntimeContext ¶
func LoadRuntimeFromBytes ¶
func LoadRuntimeFromBytesWithContract ¶
func LoadRuntimeFromBytesWithContract(data []byte, options RuntimeOptions, imports []HostImport, contract Contract) (*Runtime, error)
LoadRuntimeFromBytesWithContract loads an in-memory component and verifies its manifest before instantiation.
func LoadRuntimeFromBytesWithContractContext ¶
func LoadRuntimeFromBytesWithContractContext(ctx context.Context, data []byte, options RuntimeOptions, imports []HostImport, contract Contract) (*Runtime, error)
func LoadRuntimeFromBytesWithImports ¶
func LoadRuntimeFromBytesWithImports(data []byte, options RuntimeOptions, imports []HostImport) (*Runtime, error)
func LoadRuntimeFromBytesWithImportsContext ¶
func LoadRuntimeFromBytesWithImportsContext(ctx context.Context, data []byte, options RuntimeOptions, imports []HostImport) (*Runtime, error)
func LoadRuntimeFromBytesWithOptions ¶
func LoadRuntimeFromBytesWithOptions(data []byte, options RuntimeOptions) (*Runtime, error)
func LoadRuntimeWithContract ¶
func LoadRuntimeWithContract(filename string, options RuntimeOptions, imports []HostImport, contract Contract) (*Runtime, error)
LoadRuntimeWithContract loads a component and rejects it when its imported or exported function names differ from the contract embedded in generated code.
func LoadRuntimeWithContractContext ¶
func LoadRuntimeWithContractContext(ctx context.Context, filename string, options RuntimeOptions, imports []HostImport, contract Contract) (*Runtime, error)
func LoadRuntimeWithImports ¶
func LoadRuntimeWithImports(filename string, options RuntimeOptions, imports []HostImport) (*Runtime, error)
LoadRuntimeWithImports loads a standard WebAssembly component and exposes only the explicitly listed host functions to it.
func LoadRuntimeWithImportsContext ¶
func LoadRuntimeWithImportsContext(ctx context.Context, filename string, options RuntimeOptions, imports []HostImport) (*Runtime, error)
func LoadRuntimeWithOptions ¶
func LoadRuntimeWithOptions(filename string, options RuntimeOptions) (*Runtime, error)
func (*Runtime) AllPluginPaths ¶
AllPluginPaths returns the root and all transitive nested components in this box.
func (*Runtime) CallContext ¶
CallContext invokes a component export and propagates ctx to host imports. Cancellation is observed before bridge operations and between bridge messages.
func (*Runtime) ComponentPath ¶
ComponentPath returns the normalized component filename used by this runtime.
func (*Runtime) Composition ¶
func (r *Runtime) Composition() ComponentComposition
Composition returns the exact same-Store graph used to instantiate this runtime. It is used by generated export clients when they become providers.
func (*Runtime) EffectiveOptions ¶
func (r *Runtime) EffectiveOptions() RuntimeOptions
EffectiveOptions returns the resource share assigned to this runtime inside its box. Router pointers are omitted from the returned copy.
func (*Runtime) FuelRemaining ¶
func (*Runtime) IsClosed ¶
IsClosed reports whether the runtime has been closed. A nil or uninitialized runtime is considered closed.
func (*Runtime) NestedPluginPaths ¶
NestedPluginPaths returns the direct child components selected automatically for this runtime. The returned slice is safe to modify.
type RuntimeCallInfo ¶
type RuntimeFuelInfo ¶
type RuntimeLimitError ¶
func (*RuntimeLimitError) Error ¶
func (e *RuntimeLimitError) Error() string
func (*RuntimeLimitError) Is ¶
func (e *RuntimeLimitError) Is(target error) bool
func (*RuntimeLimitError) Unwrap ¶
func (e *RuntimeLimitError) Unwrap() error
type RuntimeLimits ¶
type RuntimeLimits struct {
MaxCallDepth uint32 `json:"max-call-depth"`
RemainingCallDepth uint32 `json:"remaining-call-depth"`
MemoryLimitBytes Option[uint64] `json:"memory-limit-bytes"`
MaxMessageBytes Option[uint64] `json:"max-message-bytes"`
DeadlineUnixNanos Option[int64] `json:"deadline-unix-nanos"`
}
type RuntimeOptions ¶
type RuntimeOptions struct {
Fuel uint64
FuelPerCall uint64
Timeout time.Duration
MemoryLimitBytes int64
MaxResultBytes uint64
InstanceLimit int64
// EnableRuntimeAPI binds the versioned witgo:runtime/runtime@1.0.0 vendor
// capability. Read-only queries are safe; additional fuel remains default-deny.
EnableRuntimeAPI bool
// PluginID is the sanitized logical identity reported by RuntimeSystem.
// It must not contain a path or secret. The zero value is "plugin".
PluginID string
// Fuel request settings are used when no CompositionHost is attached.
FuelRequestPolicy FuelRequestPolicy
FuelRequestLimits FuelRequestLimits
SecurityObserver RuntimeSecurityObserver
ValueLimits ValueLimits
// BridgePath overrides the bundled library and WITGO_COMPONENT_LIBRARY.
BridgePath string
// BridgeSHA256 verifies BridgePath before loading. It is required when a
// custom bridge is supplied in security-sensitive deployments.
BridgeSHA256 string
// DisableEmbeddedBridge prevents extraction or loading of the library
// shipped with witgo. Set BridgePath to use an administrator-managed library.
DisableEmbeddedBridge bool
// Capabilities restricts which host import functions a component may require.
// Zero value allows everything.
Capabilities CapabilityPolicy
// NestedPlugins controls automatic resolution of missing imports through
// exports of sibling Component Model plugins. The zero value enables it.
NestedPlugins NestedPluginOptions
// PluginHost centralizes nested-plugin discovery policy. Every top-level
// load still creates an independent box of runtime instances.
PluginHost *PluginHost
// CompositionHost enables transparent registered-provider routing and call
// chain protection for this runtime.
CompositionHost *Host
// CompositionPlugs are exact provider edges encoded into one Component
// Model component and instantiated in the same Store. Generated bindings
// populate this field; ordinary applications should use their typed helpers.
CompositionPlugs []CompositionPlug
}
RuntimeOptions controls resource limits for a Component Model runtime.
type RuntimeSecurityObserver ¶
type RuntimeSecurityObserver interface {
OnFuelRequest(FuelRequestEvent)
OnCycleRejected(CycleEvent)
OnLimitExceeded(LimitEvent)
OnProviderRejected(ProviderEvent)
}
type SignatureMismatch ¶
SignatureMismatch describes a function whose Component Model type differs from the generated WIT contract.
type Tuple ¶
type Tuple []any
Tuple is the flexible representation used for WIT tuples with more than 16 items. Smaller tuples use the fully typed Tuple0...Tuple16 families.
type Tuple1 ¶
type Tuple1[A any] struct{ V0 A }
func (Tuple1[A]) MarshalJSON ¶
func (*Tuple1[A]) UnmarshalJSON ¶
type Tuple2 ¶
type Tuple2[A, B any] struct { V0 A V1 B }
func (Tuple2[A, B]) MarshalJSON ¶
func (*Tuple2[A, B]) UnmarshalJSON ¶
type Tuple3 ¶
type Tuple3[A, B, C any] struct { V0 A V1 B V2 C }
func (Tuple3[A, B, C]) MarshalJSON ¶
func (*Tuple3[A, B, C]) UnmarshalJSON ¶
type Tuple4 ¶
type Tuple4[A, B, C, D any] struct { V0 A V1 B V2 C V3 D }
func (Tuple4[A, B, C, D]) MarshalJSON ¶
func (*Tuple4[A, B, C, D]) UnmarshalJSON ¶
type Tuple5 ¶
type Tuple5[A, B, C, D, E any] struct { V0 A V1 B V2 C V3 D V4 E }
func (Tuple5[A, B, C, D, E]) MarshalJSON ¶
func (*Tuple5[A, B, C, D, E]) UnmarshalJSON ¶
type Tuple6 ¶
type Tuple6[A, B, C, D, E, F any] struct { V0 A V1 B V2 C V3 D V4 E V5 F }
func (Tuple6[A, B, C, D, E, F]) MarshalJSON ¶
func (*Tuple6[A, B, C, D, E, F]) UnmarshalJSON ¶
type Tuple7 ¶
type Tuple7[A, B, C, D, E, F, G any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G }
func (Tuple7[A, B, C, D, E, F, G]) MarshalJSON ¶
func (*Tuple7[A, B, C, D, E, F, G]) UnmarshalJSON ¶
type Tuple8 ¶
type Tuple8[A, B, C, D, E, F, G, H any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H }
func (Tuple8[A, B, C, D, E, F, G, H]) MarshalJSON ¶
func (*Tuple8[A, B, C, D, E, F, G, H]) UnmarshalJSON ¶
type Tuple9 ¶
type Tuple9[A, B, C, D, E, F, G, H, I any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I }
func (Tuple9[A, B, C, D, E, F, G, H, I]) MarshalJSON ¶
func (*Tuple9[A, B, C, D, E, F, G, H, I]) UnmarshalJSON ¶
type Tuple10 ¶
type Tuple10[A, B, C, D, E, F, G, H, I, J any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J }
func NewTuple10 ¶
func (Tuple10[A, B, C, D, E, F, G, H, I, J]) MarshalJSON ¶
func (*Tuple10[A, B, C, D, E, F, G, H, I, J]) UnmarshalJSON ¶
type Tuple11 ¶
type Tuple11[A, B, C, D, E, F, G, H, I, J, K any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K }
func NewTuple11 ¶
func (Tuple11[A, B, C, D, E, F, G, H, I, J, K]) MarshalJSON ¶
func (*Tuple11[A, B, C, D, E, F, G, H, I, J, K]) UnmarshalJSON ¶
type Tuple12 ¶
type Tuple12[A, B, C, D, E, F, G, H, I, J, K, L any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K V11 L }
func NewTuple12 ¶
func (Tuple12[A, B, C, D, E, F, G, H, I, J, K, L]) MarshalJSON ¶
func (*Tuple12[A, B, C, D, E, F, G, H, I, J, K, L]) UnmarshalJSON ¶
type Tuple13 ¶
type Tuple13[A, B, C, D, E, F, G, H, I, J, K, L, M any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K V11 L V12 M }
func NewTuple13 ¶
func (Tuple13[A, B, C, D, E, F, G, H, I, J, K, L, M]) MarshalJSON ¶
func (*Tuple13[A, B, C, D, E, F, G, H, I, J, K, L, M]) UnmarshalJSON ¶
type Tuple14 ¶
type Tuple14[A, B, C, D, E, F, G, H, I, J, K, L, M, N any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K V11 L V12 M V13 N }
func NewTuple14 ¶
func (Tuple14[A, B, C, D, E, F, G, H, I, J, K, L, M, N]) MarshalJSON ¶
func (*Tuple14[A, B, C, D, E, F, G, H, I, J, K, L, M, N]) UnmarshalJSON ¶
type Tuple15 ¶
type Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K V11 L V12 M V13 N V14 O }
func NewTuple15 ¶
func (Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]) MarshalJSON ¶
func (*Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]) UnmarshalJSON ¶
type Tuple16 ¶
type Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P any] struct { V0 A V1 B V2 C V3 D V4 E V5 F V6 G V7 H V8 I V9 J V10 K V11 L V12 M V13 N V14 O V15 P }
func NewTuple16 ¶
func (Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]) MarshalJSON ¶
func (*Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]) UnmarshalJSON ¶
type TypeCodec ¶
TypeCodec converts between a canonical WIT wire value and its optional public Go representation. Generated built-in codecs use direct functions, so component calls do not need reflection or a runtime registry.
type TypeCodecFuncs ¶
type TypeCodecFuncs[Wire, Go any] struct { EncodeFunc func(Go) (Wire, error) DecodeFunc func(Wire) (Go, error) }
TypeCodecFuncs adapts two typed functions to TypeCodec.
func (TypeCodecFuncs[Wire, Go]) Decode ¶
func (c TypeCodecFuncs[Wire, Go]) Decode(value Wire) (Go, error)
func (TypeCodecFuncs[Wire, Go]) Encode ¶
func (c TypeCodecFuncs[Wire, Go]) Encode(value Go) (Wire, error)
type Unit ¶
type Unit struct{}
Unit represents a WIT type slot without a payload.
func (Unit) MarshalJSON ¶
func (*Unit) UnmarshalJSON ¶
type ValidationReport ¶
type ValidationReport struct {
Compatible bool
Expected Contract
Actual Contract
Imports ContractDifference
Exports ContractDifference
Signatures []SignatureMismatch
}
ValidationReport is the result of inspecting a component without instantiating it or running guest code.
func CompareContracts ¶
func CompareContracts(expected, actual Contract) (ValidationReport, error)
CompareContracts compares two already-inspected manifests without loading a bridge or touching the filesystem.
func ValidateComponent ¶
func ValidateComponent(filename string, expected Contract) (ValidationReport, error)
ValidateComponent compares a component with a generated contract without instantiating it or running guest code. Incompatibility is returned in the report; err is reserved for inspection and bridge failures.
func ValidateComponentBytes ¶
func ValidateComponentBytes(data []byte, expected Contract) (ValidationReport, error)
ValidateComponentBytes compares an in-memory component with a contract.
func ValidateComponentBytesWithOptions ¶
func ValidateComponentBytesWithOptions(data []byte, options RuntimeOptions, expected Contract) (ValidationReport, error)
ValidateComponentBytesWithOptions is ValidateComponentBytes with explicit bridge options.
func ValidateComponentBytesWithOptionsContext ¶
func ValidateComponentBytesWithOptionsContext(ctx context.Context, data []byte, options RuntimeOptions, expected Contract) (ValidationReport, error)
func ValidateComponentWithOptions ¶
func ValidateComponentWithOptions(filename string, options RuntimeOptions, expected Contract) (ValidationReport, error)
ValidateComponentWithOptions is ValidateComponent with explicit runtime options controlling bridge selection and inspection limits.
func ValidateComponentWithOptionsContext ¶
func ValidateComponentWithOptionsContext(ctx context.Context, filename string, options RuntimeOptions, expected Contract) (ValidationReport, error)
func (ValidationReport) Err ¶
func (r ValidationReport) Err() error
Err converts an incompatible report into an error. It returns nil for a compatible report.
func (ValidationReport) ProblemCount ¶
func (r ValidationReport) ProblemCount() int
ProblemCount returns the number of missing, unexpected, and type-mismatched functions in the report.
func (ValidationReport) Summary ¶
func (r ValidationReport) Summary() string
Summary returns a concise deterministic description suitable for logs.
type ValueLimits ¶
type WITError ¶
type WITError[E any] struct { Value E }
WITError preserves a structured WIT result error payload while implementing Go's error interface. Use errors.As to recover Value without losing its type.
type WITInputMode ¶
type WITInputMode uint8
WITInputMode controls how a WIT input path is expanded.
const ( // WITInputAuto accepts a file or recursively scans a directory. This keeps // the behaviour of Config.WIT from earlier releases. WITInputAuto WITInputMode = iota // WITInputFile requires exactly one .wit file. WITInputFile // WITInputPackage loads .wit files directly inside one package directory. // Nested directories such as deps are package boundaries and are ignored. WITInputPackage // WITInputTree recursively loads every .wit file and requires them all to // declare the same WIT package. WITInputTree )
Source Files
¶
- call.go
- capability_policy.go
- char.go
- codec.go
- component_bridge.go
- composition.go
- composition_graph.go
- config.go
- fuel.go
- generate.go
- guest_build.go
- handle.go
- host_policy.go
- map.go
- native_bridge.go
- native_bridge_unix.go
- nested.go
- option.go
- plugin_manifest.go
- result.go
- role.go
- role_host.go
- runtime.go
- runtime_system.go
- tuple.go
- unit.go
- validation.go
- value_limits.go
- version.go
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
components/basic
command
Command plugin prints the expected output path for the shared example component binary.
|
Command plugin prints the expected output path for the shared example component binary. |
|
contracts/basic
command
|
|
|
scenarios/collections
command
|
|
|
scenarios/handles
command
|
|
|
scenarios/inspect
command
|
|
|
scenarios/nested
command
|
|
|
scenarios/server
command
|
|
|
scenarios/validate
command
|
|
|
Package generator turns WIT contracts into Go bindings.
|
Package generator turns WIT contracts into Go bindings. |
|
internal
|
|
|
bridgebin
Package bridgebin contains platform-specific Wasmtime shared libraries.
|
Package bridgebin contains platform-specific Wasmtime shared libraries. |
