Documentation
¶
Index ¶
- func DetectExtensions(module wazero.CompiledModule) (ext []wasi_snapshot_preview1.Extension)
- func DetectSocketsExtension(module wazero.CompiledModule) *wasi_snapshot_preview1.Extension
- type Builder
- func (b *Builder) Instantiate(ctx context.Context, runtime wazero.Runtime) (ctxret context.Context, system wasi.System, err error)
- func (b *Builder) WithArgs(args ...string) *Builder
- func (b *Builder) WithDecorators(decorators ...wasi_snapshot_preview1.Decorator) *Builder
- func (b *Builder) WithDials(dials ...string) *Builder
- func (b *Builder) WithDirs(dirs ...string) *Builder
- func (b *Builder) WithEnv(env ...string) *Builder
- func (b *Builder) WithExit(fn func(context.Context, int) error) *Builder
- func (b *Builder) WithListens(listens ...string) *Builder
- func (b *Builder) WithMonotonicClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder
- func (b *Builder) WithName(name string) *Builder
- func (b *Builder) WithNonBlockingStdio(enable bool) *Builder
- func (b *Builder) WithRaise(fn func(context.Context, int) error) *Builder
- func (b *Builder) WithRealtimeClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder
- func (b *Builder) WithSocketsExtension(name string, module wazero.CompiledModule) *Builder
- func (b *Builder) WithStdio(stdin, stdout, stderr int) *Builder
- func (b *Builder) WithTracer(enable bool, w io.Writer) *Builder
- func (b *Builder) WithWrappers(wrappers ...func(wasi.System) wasi.System) *Builder
- func (b *Builder) WithYield(fn func(context.Context) error) *Builder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectExtensions ¶ added in v0.2.0
func DetectExtensions(module wazero.CompiledModule) (ext []wasi_snapshot_preview1.Extension)
DetectExtensions detects extensions to WASI preview 1.
func DetectSocketsExtension ¶ added in v0.2.0
func DetectSocketsExtension(module wazero.CompiledModule) *wasi_snapshot_preview1.Extension
DetectSocketsExtension determines the sockets extension in use by inspecting a WASM module's host imports.
This function can detect WasmEdge v1 and WasmEdge v2.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to setup and instantiate the WASI host module.
func (*Builder) Instantiate ¶
func (b *Builder) Instantiate(ctx context.Context, runtime wazero.Runtime) (ctxret context.Context, system wasi.System, err error)
Instantiate compiles and instantiates the WASI module and binds it to the specified context.
func (*Builder) WithDecorators ¶
func (b *Builder) WithDecorators(decorators ...wasi_snapshot_preview1.Decorator) *Builder
WithDecorators sets the host module decorators.
func (*Builder) WithDials ¶
WithDials specifies a list of addresses to dial before starting the module. The connection sockets are added to the set of preopens.
func (*Builder) WithDirs ¶
WithDirs specifies a set of directories to preopen.
The directory can either be a path, or a string of the form "path:path[:ro]" for compatibility with wazero's WASI preview 1 host module. Since virtual file systems are not supported by this implementation, the two paths must be the same when using this syntax. The optional ":ro" prefix means that this directory is read-only.
func (*Builder) WithListens ¶
WithListens specifies a list of addresses to listen on before starting the module. The listener sockets are added to the set of preopens.
func (*Builder) WithMonotonicClock ¶
func (b *Builder) WithMonotonicClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder
WithMonotonicClock sets the monotonic clock and precision.
func (*Builder) WithName ¶
WithName sets the name of the module, which is exposed to the module as argv[0].
func (*Builder) WithNonBlockingStdio ¶
WithNonBlockingStdio enables or disables non-blocking stdio. When enabled, stdio file descriptors will have the O_NONBLOCK flag set before the module is started.
func (*Builder) WithRealtimeClock ¶
func (b *Builder) WithRealtimeClock(clock func(context.Context) (uint64, error), precision time.Duration) *Builder
WithRealtimeClock sets the realtime clock and precision.
func (*Builder) WithSocketsExtension ¶
func (b *Builder) WithSocketsExtension(name string, module wazero.CompiledModule) *Builder
WithSocketsExtension enables a sockets extension.
The name can be one of: - none: disable sockets extensions (use vanilla WASI preview 1) - wasmedgev1: use WasmEdge sockets extension version 1 - wasmedgev2: use WasmEdge sockets extension version 2 - path_open: use the extension to the path_open system call (unix.PathOpenSockets) - auto: attempt to detect one of the extensions above
func (*Builder) WithStdio ¶
WithStdio sets stdio file descriptors.
Note that the file descriptors will be duplicated before the module takes ownership. The caller is responsible for managing the specified descriptors.
func (*Builder) WithTracer ¶
WithTracer enables the Tracer, and instructs it to write to the specified io.Writer.
func (*Builder) WithWrappers ¶
WithWrappers sets the wasi.System wrappers.