wasi_snapshot_preview1

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const HostModuleName = "wasi_snapshot_preview1"

HostModuleName is the name of the host module.

Variables

View Source
var WasmEdgeV1 = Extension{
	"sock_accept":       wazergo.F2((*Module).WasmEdgeV1SockAccept),
	"sock_open":         wazergo.F3((*Module).WasmEdgeSockOpen),
	"sock_bind":         wazergo.F3((*Module).WasmEdgeSockBind),
	"sock_connect":      wazergo.F3((*Module).WasmEdgeSockConnect),
	"sock_listen":       wazergo.F2((*Module).WasmEdgeSockListen),
	"sock_send_to":      wazergo.F6((*Module).WasmEdgeSockSendTo),
	"sock_recv_from":    wazergo.F6((*Module).WasmEdgeV1SockRecvFrom),
	"sock_getsockopt":   wazergo.F5((*Module).WasmEdgeSockGetOpt),
	"sock_setsockopt":   wazergo.F5((*Module).WasmEdgeSockSetOpt),
	"sock_getlocaladdr": wazergo.F4((*Module).WasmEdgeV1SockLocalAddr),
	"sock_getpeeraddr":  wazergo.F4((*Module).WasmEdgeV1SockPeerAddr),
	"sock_getaddrinfo":  wazergo.F6((*Module).WasmEdgeSockAddrInfo),
}

WasmEdgeV1 is the original WasmEdge sockets extension to WASI preview 1.

View Source
var WasmEdgeV2 = Extension{
	"sock_open":         wazergo.F3((*Module).WasmEdgeSockOpen),
	"sock_bind":         wazergo.F3((*Module).WasmEdgeSockBind),
	"sock_connect":      wazergo.F3((*Module).WasmEdgeSockConnect),
	"sock_listen":       wazergo.F2((*Module).WasmEdgeSockListen),
	"sock_send_to":      wazergo.F6((*Module).WasmEdgeSockSendTo),
	"sock_recv_from":    wazergo.F7((*Module).WasmEdgeV2SockRecvFrom),
	"sock_getsockopt":   wazergo.F5((*Module).WasmEdgeSockGetOpt),
	"sock_setsockopt":   wazergo.F5((*Module).WasmEdgeSockSetOpt),
	"sock_getlocaladdr": wazergo.F3((*Module).WasmEdgeV2SockLocalAddr),
	"sock_getpeeraddr":  wazergo.F3((*Module).WasmEdgeV2SockPeerAddr),
	"sock_getaddrinfo":  wazergo.F6((*Module).WasmEdgeSockAddrInfo),
}

WasmEdgeV2 is V2 of the WasmEdge sockets extension to WASI preview 1.

Version 2 has a sock_accept function that's compatible with the WASI preview 1 specification. It widens addresses so that additional address families could be supported in future (e.g. AF_UNIX).

Functions

func NewHostModule

func NewHostModule(extensions ...Extension) wazergo.HostModule[*Module]

NewHostModule constructs a wazero host module for WASI.

The host module manages the interaction between the host and the guest WASM module. The host module does not implement WASI on its own, and instead calls out to an implementation of the wasi.System interface provided via the WithWASI host module Option. This design means that the implementation doesn't have to concern itself with ABI details nor access the guest's memory.

Types

type Decorator

type Decorator = wazergo.Decorator[*Module]

func DecoratorFunc

func DecoratorFunc(fn func(string, Function) Function) Decorator

DecoratorFunc is a helper used to create decorators from functions using type inference to keep the syntax simple.

type Extension

type Extension wazergo.Functions[*Module]

Extension is an extension to WASI preview 1.

type Function

type Function = wazergo.Function[*Module]

type Module

type Module struct {
	WASI wasi.System
	// contains filtered or unexported fields
}

func (*Module) ArgsGet

func (m *Module) ArgsGet(ctx context.Context, argv Pointer[Uint32], buf Pointer[Uint8]) Errno

func (*Module) ArgsSizesGet

func (m *Module) ArgsSizesGet(ctx context.Context, argc, bufLen Pointer[Int32]) Errno

func (*Module) ClockResGet

func (m *Module) ClockResGet(ctx context.Context, clockID Int32, precision Pointer[Uint64]) Errno

func (*Module) ClockTimeGet

func (m *Module) ClockTimeGet(ctx context.Context, clockID Int32, precision Uint64, timestamp Pointer[Uint64]) Errno

func (*Module) Close

func (m *Module) Close(ctx context.Context) error

func (*Module) EnvironGet

func (m *Module) EnvironGet(ctx context.Context, envv Pointer[Uint32], buf Pointer[Uint8]) Errno

func (*Module) EnvironSizesGet

func (m *Module) EnvironSizesGet(ctx context.Context, envc, bufLen Pointer[Int32]) Errno

func (*Module) FDAdvise

func (m *Module) FDAdvise(ctx context.Context, fd Int32, offset, length Uint64, advice Int32) Errno

func (*Module) FDAllocate

func (m *Module) FDAllocate(ctx context.Context, fd Int32, offset, length Uint64) Errno

func (*Module) FDClose

func (m *Module) FDClose(ctx context.Context, fd Int32) Errno

func (*Module) FDDataSync

func (m *Module) FDDataSync(ctx context.Context, fd Int32) Errno

func (*Module) FDFileStatGet

func (m *Module) FDFileStatGet(ctx context.Context, fd Int32, stat Pointer[wasi.FileStat]) Errno

func (*Module) FDFileStatSetSize

func (m *Module) FDFileStatSetSize(ctx context.Context, fd Int32, size Uint64) Errno

func (*Module) FDFileStatSetTimes

func (m *Module) FDFileStatSetTimes(ctx context.Context, fd Int32, accessTime, modifyTime Uint64, flags Int32) Errno

func (*Module) FDPreStatDirName

func (m *Module) FDPreStatDirName(ctx context.Context, fd Int32, dirName Bytes) Errno

func (*Module) FDPreStatGet

func (m *Module) FDPreStatGet(ctx context.Context, fd Int32, prestat Pointer[wasi.PreStat]) Errno

func (*Module) FDPread

func (m *Module) FDPread(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], offset Uint64, nread Pointer[Int32]) Errno

func (*Module) FDPwrite

func (m *Module) FDPwrite(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], offset Uint64, nwritten Pointer[Int32]) Errno

func (*Module) FDRead

func (m *Module) FDRead(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], nread Pointer[Int32]) Errno

func (*Module) FDReadDir

func (m *Module) FDReadDir(ctx context.Context, fd Int32, buf Bytes, cookie Uint64, nwritten Pointer[Int32]) Errno

func (*Module) FDRenumber

func (m *Module) FDRenumber(ctx context.Context, from, to Int32) Errno

func (*Module) FDSeek

func (m *Module) FDSeek(ctx context.Context, fd Int32, delta Int64, whence Int32, size Pointer[Uint64]) Errno

func (*Module) FDStatGet

func (m *Module) FDStatGet(ctx context.Context, fd Int32, stat Pointer[wasi.FDStat]) Errno

func (*Module) FDStatSetFlags

func (m *Module) FDStatSetFlags(ctx context.Context, fd Int32, flags Uint32) Errno

func (*Module) FDStatSetRights

func (m *Module) FDStatSetRights(ctx context.Context, fd Int32, rightsBase, rightsInheriting Uint64) Errno

func (*Module) FDSync

func (m *Module) FDSync(ctx context.Context, fd Int32) Errno

func (*Module) FDTell

func (m *Module) FDTell(ctx context.Context, fd Int32, size Pointer[Uint64]) Errno

func (*Module) FDWrite

func (m *Module) FDWrite(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], nwritten Pointer[Int32]) Errno

func (*Module) PathCreateDirectory

func (m *Module) PathCreateDirectory(ctx context.Context, fd Int32, path String) Errno

func (*Module) PathFileStatGet

func (m *Module) PathFileStatGet(ctx context.Context, fd Int32, flags Int32, path String, stat Pointer[wasi.FileStat]) Errno

func (*Module) PathFileStatSetTimes

func (m *Module) PathFileStatSetTimes(ctx context.Context, fd Int32, lookupFlags Int32, path String, accessTime, modifyTime Uint64, fstFlags Int32) Errno
func (m *Module) PathLink(ctx context.Context, oldFD Int32, oldFlags Int32, oldPath Bytes, newFD Int32, newPath Bytes) Errno

func (*Module) PathOpen

func (m *Module) PathOpen(ctx context.Context, fd Int32, dirFlags Int32, path String, openFlags Int32, rightsBase, rightsInheriting Uint64, fdFlags Int32, openfd Pointer[Int32]) Errno
func (m *Module) PathReadLink(ctx context.Context, fd Int32, path String, buf Bytes, nwritten Pointer[Int32]) Errno

func (*Module) PathRemoveDirectory

func (m *Module) PathRemoveDirectory(ctx context.Context, fd Int32, path String) Errno

func (*Module) PathRename

func (m *Module) PathRename(ctx context.Context, oldFD Int32, oldPath String, newFD Int32, newPath String) Errno
func (m *Module) PathSymlink(ctx context.Context, oldPath String, fd Int32, newPath String) Errno

func (*Module) PathUnlinkFile

func (m *Module) PathUnlinkFile(ctx context.Context, fd Int32, path String) Errno

func (*Module) PollOneOff

func (m *Module) PollOneOff(ctx context.Context, in Pointer[wasi.Subscription], out Pointer[wasi.Event], nSubscriptions Int32, nEvents Pointer[Int32]) Errno

func (*Module) ProcExit

func (m *Module) ProcExit(ctx context.Context, mod api.Module, exitCode Int32)

func (*Module) ProcRaise

func (m *Module) ProcRaise(ctx context.Context, signal Int32) Errno

func (*Module) RandomGet

func (m *Module) RandomGet(ctx context.Context, buf Bytes) Errno

func (*Module) SchedYield

func (m *Module) SchedYield(ctx context.Context) Errno

func (*Module) SockAccept

func (m *Module) SockAccept(ctx context.Context, fd Int32, flags Int32, connfd Pointer[Int32]) Errno

func (*Module) SockRecv

func (m *Module) SockRecv(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], iflags Int32, nread Pointer[Int32], oflags Pointer[Int32]) Errno

func (*Module) SockSend

func (m *Module) SockSend(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], flags Int32, nwritten Pointer[Int32]) Errno

func (*Module) SockShutdown

func (m *Module) SockShutdown(ctx context.Context, fd Int32, flags Int32) Errno

func (*Module) WasmEdgeSockAddrInfo

func (m *Module) WasmEdgeSockAddrInfo(ctx context.Context, name String, service String, hintsPtr Pointer[wasmEdgeAddressInfo], resPtrPtr Pointer[Pointer[wasmEdgeAddressInfo]], maxResLength Uint32, resLengthPtr Pointer[Uint32]) Errno

func (*Module) WasmEdgeSockBind

func (m *Module) WasmEdgeSockBind(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], port Uint32) Errno

func (*Module) WasmEdgeSockConnect

func (m *Module) WasmEdgeSockConnect(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], port Uint32) Errno

func (*Module) WasmEdgeSockGetOpt

func (m *Module) WasmEdgeSockGetOpt(ctx context.Context, fd Int32, level Int32, option Int32, value Pointer[Int32], valueLen Int32) Errno

func (*Module) WasmEdgeSockListen

func (m *Module) WasmEdgeSockListen(ctx context.Context, fd Int32, backlog Int32) Errno

func (*Module) WasmEdgeSockOpen

func (m *Module) WasmEdgeSockOpen(ctx context.Context, family Int32, sockType Int32, openfd Pointer[Int32]) Errno

func (*Module) WasmEdgeSockSendTo

func (m *Module) WasmEdgeSockSendTo(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], addr Pointer[wasmEdgeAddress], port Int32, flags Uint32, nwritten Pointer[Int32]) Errno

func (*Module) WasmEdgeSockSetOpt

func (m *Module) WasmEdgeSockSetOpt(ctx context.Context, fd Int32, level Int32, option Int32, value Pointer[Int32], valueLen Int32) Errno

func (*Module) WasmEdgeV1SockAccept

func (m *Module) WasmEdgeV1SockAccept(ctx context.Context, fd Int32, connfd Pointer[Int32]) Errno

func (*Module) WasmEdgeV1SockLocalAddr

func (m *Module) WasmEdgeV1SockLocalAddr(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], addrType Pointer[Uint32], port Pointer[Uint32]) Errno

func (*Module) WasmEdgeV1SockPeerAddr

func (m *Module) WasmEdgeV1SockPeerAddr(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], addrType Pointer[Uint32], port Pointer[Uint32]) Errno

func (*Module) WasmEdgeV1SockRecvFrom

func (m *Module) WasmEdgeV1SockRecvFrom(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], addr Pointer[wasmEdgeAddress], iflags Uint32, nread Pointer[Int32], oflags Pointer[Int32]) Errno

func (*Module) WasmEdgeV2SockLocalAddr

func (m *Module) WasmEdgeV2SockLocalAddr(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], port Pointer[Uint32]) Errno

func (*Module) WasmEdgeV2SockPeerAddr

func (m *Module) WasmEdgeV2SockPeerAddr(ctx context.Context, fd Int32, addr Pointer[wasmEdgeAddress], port Pointer[Uint32]) Errno

func (*Module) WasmEdgeV2SockRecvFrom

func (m *Module) WasmEdgeV2SockRecvFrom(ctx context.Context, fd Int32, iovecs List[wasi.IOVec], addr Pointer[wasmEdgeAddress], iflags Uint32, port Pointer[Uint32], nread Pointer[Int32], oflags Pointer[Int32]) Errno

type Option

type Option = wazergo.Option[*Module]

Option configures the host module.

func WithWASI

func WithWASI(wasi wasi.System) Option

WithWASI sets the WASI implementation.

Jump to

Keyboard shortcuts

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