diff --git a/.github/workflows/west.yml b/.github/workflows/west.yml index d3ce753..0a31147 100644 --- a/.github/workflows/west.yml +++ b/.github/workflows/west.yml @@ -50,8 +50,8 @@ jobs: - run: rustup show #- run: cargo test --workspace --all-targets - run: cargo binstall -y wasm-tools@1.217 - - run: go generate ./go/... - - run: go test ./go/... + - run: go generate ./... + - run: go test ./... - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: west-${{ matrix.config.target }} diff --git a/go/bindings/bindings.go b/bindings/bindings.go similarity index 81% rename from go/bindings/bindings.go rename to bindings/bindings.go index 72d3188..a122b7b 100644 --- a/go/bindings/bindings.go +++ b/bindings/bindings.go @@ -3,11 +3,11 @@ package bindings import ( - west "github.com/rvolosatovs/west/go" - github_com__rvolosatovs__west__go__bindings__wasi__clocks__monotonic___clock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock" - github_com__rvolosatovs__west__go__bindings__wasi__http__types "github.com/rvolosatovs/west/go/bindings/wasi/http/types" - github_com__rvolosatovs__west__go__bindings__wasi__io__poll "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" - github_com__rvolosatovs__west__go__bindings__wasi__io__streams "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + west "github.com/rvolosatovs/west" + github_com__rvolosatovs__west__bindings__wasi__clocks__monotonic___clock "github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock" + github_com__rvolosatovs__west__bindings__wasi__http__types "github.com/rvolosatovs/west/bindings/wasi/http/types" + github_com__rvolosatovs__west__bindings__wasi__io__poll "github.com/rvolosatovs/west/bindings/wasi/io/poll" + github_com__rvolosatovs__west__bindings__wasi__io__streams "github.com/rvolosatovs/west/bindings/wasi/io/streams" github_com__ydnar__wasm___tools___go__cm "github.com/ydnar/wasm-tools-go/cm" "runtime" "unsafe" @@ -17,7 +17,7 @@ const _ string = runtime.Compiler var _ unsafe.Pointer -//go:linkname wasmimport_Now github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock.wasmimport_Now +//go:linkname wasmimport_Now github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock.wasmimport_Now func wasmimport_Now() (result0 uint64) { var __p runtime.Pinner defer __p.Unpin() @@ -33,7 +33,7 @@ func wasmimport_Now() (result0 uint64) { return } -//go:linkname wasmimport_Resolution github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock.wasmimport_Resolution +//go:linkname wasmimport_Resolution github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock.wasmimport_Resolution func wasmimport_Resolution() (result0 uint64) { var __p runtime.Pinner defer __p.Unpin() @@ -49,7 +49,7 @@ func wasmimport_Resolution() (result0 uint64) { return } -//go:linkname wasmimport_SubscribeDuration github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock.wasmimport_SubscribeDuration +//go:linkname wasmimport_SubscribeDuration github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock.wasmimport_SubscribeDuration func wasmimport_SubscribeDuration(when0 uint64) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -69,7 +69,7 @@ func wasmimport_SubscribeDuration(when0 uint64) (result0 uint32) { return } -//go:linkname wasmimport_SubscribeInstant github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock.wasmimport_SubscribeInstant +//go:linkname wasmimport_SubscribeInstant github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock.wasmimport_SubscribeInstant func wasmimport_SubscribeInstant(when0 uint64) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -89,7 +89,7 @@ func wasmimport_SubscribeInstant(when0 uint64) (result0 uint32) { return } -//go:linkname wasmimport_NewFields github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_NewFields +//go:linkname wasmimport_NewFields github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_NewFields func wasmimport_NewFields() (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -105,7 +105,7 @@ func wasmimport_NewFields() (result0 uint32) { return } -//go:linkname wasmimport_NewOutgoingRequest github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_NewOutgoingRequest +//go:linkname wasmimport_NewOutgoingRequest github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_NewOutgoingRequest func wasmimport_NewOutgoingRequest(headers0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -125,7 +125,7 @@ func wasmimport_NewOutgoingRequest(headers0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_NewOutgoingResponse github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_NewOutgoingResponse +//go:linkname wasmimport_NewOutgoingResponse github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_NewOutgoingResponse func wasmimport_NewOutgoingResponse(headers0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -145,7 +145,7 @@ func wasmimport_NewOutgoingResponse(headers0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_NewRequestOptions github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_NewRequestOptions +//go:linkname wasmimport_NewRequestOptions github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_NewRequestOptions func wasmimport_NewRequestOptions() (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -161,8 +161,8 @@ func wasmimport_NewRequestOptions() (result0 uint32) { return } -//go:linkname wasmimport_FieldsAppend github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsAppend -func wasmimport_FieldsAppend(self0 uint32, name0 *uint8, name1 uint32, value0 *uint8, value1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError]) { +//go:linkname wasmimport_FieldsAppend github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsAppend +func wasmimport_FieldsAppend(self0 uint32, name0 *uint8, name1 uint32, value0 *uint8, value1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -197,7 +197,7 @@ func wasmimport_FieldsAppend(self0 uint32, name0 *uint8, name1 uint32, value0 *u return } -//go:linkname wasmimport_FieldsClone github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsClone +//go:linkname wasmimport_FieldsClone github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsClone func wasmimport_FieldsClone(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -217,8 +217,8 @@ func wasmimport_FieldsClone(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_FieldsDelete github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsDelete -func wasmimport_FieldsDelete(self0 uint32, name0 *uint8, name1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError]) { +//go:linkname wasmimport_FieldsDelete github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsDelete +func wasmimport_FieldsDelete(self0 uint32, name0 *uint8, name1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -245,8 +245,8 @@ func wasmimport_FieldsDelete(self0 uint32, name0 *uint8, name1 uint32, result *g return } -//go:linkname wasmimport_FieldsEntries github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsEntries -func wasmimport_FieldsEntries(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldKey, github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldValue]]) { +//go:linkname wasmimport_FieldsEntries github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsEntries +func wasmimport_FieldsEntries(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__bindings__wasi__http__types.FieldKey, github_com__rvolosatovs__west__bindings__wasi__http__types.FieldValue]]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -265,8 +265,8 @@ func wasmimport_FieldsEntries(self0 uint32, result *github_com__ydnar__wasm___to return } -//go:linkname wasmimport_FieldsGet github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsGet -func wasmimport_FieldsGet(self0 uint32, name0 *uint8, name1 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldValue]) { +//go:linkname wasmimport_FieldsGet github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsGet +func wasmimport_FieldsGet(self0 uint32, name0 *uint8, name1 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[github_com__rvolosatovs__west__bindings__wasi__http__types.FieldValue]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -293,7 +293,7 @@ func wasmimport_FieldsGet(self0 uint32, name0 *uint8, name1 uint32, result *gith return } -//go:linkname wasmimport_FieldsHas github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsHas +//go:linkname wasmimport_FieldsHas github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsHas func wasmimport_FieldsHas(self0 uint32, name0 *uint8, name1 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -321,8 +321,8 @@ func wasmimport_FieldsHas(self0 uint32, name0 *uint8, name1 uint32) (result0 uin return } -//go:linkname wasmimport_FieldsSet github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsSet -func wasmimport_FieldsSet(self0 uint32, name0 *uint8, name1 uint32, value0 *github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldValue, value1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError]) { +//go:linkname wasmimport_FieldsSet github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsSet +func wasmimport_FieldsSet(self0 uint32, name0 *uint8, name1 uint32, value0 *github_com__rvolosatovs__west__bindings__wasi__http__types.FieldValue, value1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError, struct{}, github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -357,8 +357,8 @@ func wasmimport_FieldsSet(self0 uint32, name0 *uint8, name1 uint32, value0 *gith return } -//go:linkname wasmimport_FutureIncomingResponseGet github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureIncomingResponseGet -func wasmimport_FutureIncomingResponseGet(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCodeShape, github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingResponse, github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode], github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCodeShape, github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingResponse, github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode], struct{}]]) { +//go:linkname wasmimport_FutureIncomingResponseGet github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureIncomingResponseGet +func wasmimport_FutureIncomingResponseGet(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCodeShape, github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingResponse, github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode], github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCodeShape, github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingResponse, github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode], struct{}]]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -377,7 +377,7 @@ func wasmimport_FutureIncomingResponseGet(self0 uint32, result *github_com__ydna return } -//go:linkname wasmimport_FutureIncomingResponseSubscribe github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureIncomingResponseSubscribe +//go:linkname wasmimport_FutureIncomingResponseSubscribe github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureIncomingResponseSubscribe func wasmimport_FutureIncomingResponseSubscribe(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -397,8 +397,8 @@ func wasmimport_FutureIncomingResponseSubscribe(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_FutureTrailersGet github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureTrailersGet -func wasmimport_FutureTrailersGet(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCodeShape, github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__http__types.Fields], github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode], github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCodeShape, github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__http__types.Fields], github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode], struct{}]]) { +//go:linkname wasmimport_FutureTrailersGet github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureTrailersGet +func wasmimport_FutureTrailersGet(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCodeShape, github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__http__types.Fields], github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode], github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCodeShape, github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__http__types.Fields], github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode], struct{}]]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -417,7 +417,7 @@ func wasmimport_FutureTrailersGet(self0 uint32, result *github_com__ydnar__wasm_ return } -//go:linkname wasmimport_FutureTrailersSubscribe github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureTrailersSubscribe +//go:linkname wasmimport_FutureTrailersSubscribe github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureTrailersSubscribe func wasmimport_FutureTrailersSubscribe(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -437,8 +437,8 @@ func wasmimport_FutureTrailersSubscribe(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_IncomingBodyStream github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingBodyStream -func wasmimport_IncomingBodyStream(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.InputStream, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.InputStream, struct{}]) { +//go:linkname wasmimport_IncomingBodyStream github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingBodyStream +func wasmimport_IncomingBodyStream(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.InputStream, github_com__rvolosatovs__west__bindings__wasi__io__streams.InputStream, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -457,7 +457,7 @@ func wasmimport_IncomingBodyStream(self0 uint32, result *github_com__ydnar__wasm return } -//go:linkname wasmimport_IncomingRequestAuthority github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestAuthority +//go:linkname wasmimport_IncomingRequestAuthority github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestAuthority func wasmimport_IncomingRequestAuthority(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[string]) { var __p runtime.Pinner defer __p.Unpin() @@ -477,8 +477,8 @@ func wasmimport_IncomingRequestAuthority(self0 uint32, result *github_com__ydnar return } -//go:linkname wasmimport_IncomingRequestConsume github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestConsume -func wasmimport_IncomingRequestConsume(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingBody, github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingBody, struct{}]) { +//go:linkname wasmimport_IncomingRequestConsume github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestConsume +func wasmimport_IncomingRequestConsume(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingBody, github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingBody, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -497,7 +497,7 @@ func wasmimport_IncomingRequestConsume(self0 uint32, result *github_com__ydnar__ return } -//go:linkname wasmimport_IncomingRequestHeaders github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestHeaders +//go:linkname wasmimport_IncomingRequestHeaders github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestHeaders func wasmimport_IncomingRequestHeaders(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -517,8 +517,8 @@ func wasmimport_IncomingRequestHeaders(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_IncomingRequestMethod github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestMethod -func wasmimport_IncomingRequestMethod(self0 uint32, result *github_com__rvolosatovs__west__go__bindings__wasi__http__types.Method) { +//go:linkname wasmimport_IncomingRequestMethod github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestMethod +func wasmimport_IncomingRequestMethod(self0 uint32, result *github_com__rvolosatovs__west__bindings__wasi__http__types.Method) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -537,7 +537,7 @@ func wasmimport_IncomingRequestMethod(self0 uint32, result *github_com__rvolosat return } -//go:linkname wasmimport_IncomingRequestPathWithQuery github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestPathWithQuery +//go:linkname wasmimport_IncomingRequestPathWithQuery github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestPathWithQuery func wasmimport_IncomingRequestPathWithQuery(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[string]) { var __p runtime.Pinner defer __p.Unpin() @@ -557,8 +557,8 @@ func wasmimport_IncomingRequestPathWithQuery(self0 uint32, result *github_com__y return } -//go:linkname wasmimport_IncomingRequestScheme github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestScheme -func wasmimport_IncomingRequestScheme(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__http__types.Scheme]) { +//go:linkname wasmimport_IncomingRequestScheme github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestScheme +func wasmimport_IncomingRequestScheme(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__http__types.Scheme]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -577,8 +577,8 @@ func wasmimport_IncomingRequestScheme(self0 uint32, result *github_com__ydnar__w return } -//go:linkname wasmimport_IncomingResponseConsume github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingResponseConsume -func wasmimport_IncomingResponseConsume(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingBody, github_com__rvolosatovs__west__go__bindings__wasi__http__types.IncomingBody, struct{}]) { +//go:linkname wasmimport_IncomingResponseConsume github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingResponseConsume +func wasmimport_IncomingResponseConsume(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingBody, github_com__rvolosatovs__west__bindings__wasi__http__types.IncomingBody, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -597,7 +597,7 @@ func wasmimport_IncomingResponseConsume(self0 uint32, result *github_com__ydnar_ return } -//go:linkname wasmimport_IncomingResponseHeaders github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingResponseHeaders +//go:linkname wasmimport_IncomingResponseHeaders github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingResponseHeaders func wasmimport_IncomingResponseHeaders(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -617,7 +617,7 @@ func wasmimport_IncomingResponseHeaders(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_IncomingResponseStatus github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingResponseStatus +//go:linkname wasmimport_IncomingResponseStatus github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingResponseStatus func wasmimport_IncomingResponseStatus(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -637,8 +637,8 @@ func wasmimport_IncomingResponseStatus(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutgoingBodyWrite github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingBodyWrite -func wasmimport_OutgoingBodyWrite(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.OutputStream, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.OutputStream, struct{}]) { +//go:linkname wasmimport_OutgoingBodyWrite github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingBodyWrite +func wasmimport_OutgoingBodyWrite(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.OutputStream, github_com__rvolosatovs__west__bindings__wasi__io__streams.OutputStream, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -657,7 +657,7 @@ func wasmimport_OutgoingBodyWrite(self0 uint32, result *github_com__ydnar__wasm_ return } -//go:linkname wasmimport_OutgoingRequestAuthority github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestAuthority +//go:linkname wasmimport_OutgoingRequestAuthority github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestAuthority func wasmimport_OutgoingRequestAuthority(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[string]) { var __p runtime.Pinner defer __p.Unpin() @@ -677,8 +677,8 @@ func wasmimport_OutgoingRequestAuthority(self0 uint32, result *github_com__ydnar return } -//go:linkname wasmimport_OutgoingRequestBody github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestBody -func wasmimport_OutgoingRequestBody(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.OutgoingBody, github_com__rvolosatovs__west__go__bindings__wasi__http__types.OutgoingBody, struct{}]) { +//go:linkname wasmimport_OutgoingRequestBody github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestBody +func wasmimport_OutgoingRequestBody(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.OutgoingBody, github_com__rvolosatovs__west__bindings__wasi__http__types.OutgoingBody, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -697,7 +697,7 @@ func wasmimport_OutgoingRequestBody(self0 uint32, result *github_com__ydnar__was return } -//go:linkname wasmimport_OutgoingRequestHeaders github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestHeaders +//go:linkname wasmimport_OutgoingRequestHeaders github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestHeaders func wasmimport_OutgoingRequestHeaders(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -717,8 +717,8 @@ func wasmimport_OutgoingRequestHeaders(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutgoingRequestMethod github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestMethod -func wasmimport_OutgoingRequestMethod(self0 uint32, result *github_com__rvolosatovs__west__go__bindings__wasi__http__types.Method) { +//go:linkname wasmimport_OutgoingRequestMethod github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestMethod +func wasmimport_OutgoingRequestMethod(self0 uint32, result *github_com__rvolosatovs__west__bindings__wasi__http__types.Method) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -737,7 +737,7 @@ func wasmimport_OutgoingRequestMethod(self0 uint32, result *github_com__rvolosat return } -//go:linkname wasmimport_OutgoingRequestPathWithQuery github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestPathWithQuery +//go:linkname wasmimport_OutgoingRequestPathWithQuery github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestPathWithQuery func wasmimport_OutgoingRequestPathWithQuery(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[string]) { var __p runtime.Pinner defer __p.Unpin() @@ -757,8 +757,8 @@ func wasmimport_OutgoingRequestPathWithQuery(self0 uint32, result *github_com__y return } -//go:linkname wasmimport_OutgoingRequestScheme github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestScheme -func wasmimport_OutgoingRequestScheme(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__http__types.Scheme]) { +//go:linkname wasmimport_OutgoingRequestScheme github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestScheme +func wasmimport_OutgoingRequestScheme(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__http__types.Scheme]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -777,7 +777,7 @@ func wasmimport_OutgoingRequestScheme(self0 uint32, result *github_com__ydnar__w return } -//go:linkname wasmimport_OutgoingRequestSetAuthority github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestSetAuthority +//go:linkname wasmimport_OutgoingRequestSetAuthority github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestSetAuthority func wasmimport_OutgoingRequestSetAuthority(self0 uint32, authority0 uint32, authority1 *uint8, authority2 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -809,7 +809,7 @@ func wasmimport_OutgoingRequestSetAuthority(self0 uint32, authority0 uint32, aut return } -//go:linkname wasmimport_OutgoingRequestSetMethod github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestSetMethod +//go:linkname wasmimport_OutgoingRequestSetMethod github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestSetMethod func wasmimport_OutgoingRequestSetMethod(self0 uint32, method0 uint32, method1 *uint8, method2 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -841,7 +841,7 @@ func wasmimport_OutgoingRequestSetMethod(self0 uint32, method0 uint32, method1 * return } -//go:linkname wasmimport_OutgoingRequestSetPathWithQuery github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestSetPathWithQuery +//go:linkname wasmimport_OutgoingRequestSetPathWithQuery github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestSetPathWithQuery func wasmimport_OutgoingRequestSetPathWithQuery(self0 uint32, pathWithQuery0 uint32, pathWithQuery1 *uint8, pathWithQuery2 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -873,7 +873,7 @@ func wasmimport_OutgoingRequestSetPathWithQuery(self0 uint32, pathWithQuery0 uin return } -//go:linkname wasmimport_OutgoingRequestSetScheme github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestSetScheme +//go:linkname wasmimport_OutgoingRequestSetScheme github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestSetScheme func wasmimport_OutgoingRequestSetScheme(self0 uint32, scheme0 uint32, scheme1 uint32, scheme2 *uint8, scheme3 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -909,8 +909,8 @@ func wasmimport_OutgoingRequestSetScheme(self0 uint32, scheme0 uint32, scheme1 u return } -//go:linkname wasmimport_OutgoingResponseBody github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingResponseBody -func wasmimport_OutgoingResponseBody(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.OutgoingBody, github_com__rvolosatovs__west__go__bindings__wasi__http__types.OutgoingBody, struct{}]) { +//go:linkname wasmimport_OutgoingResponseBody github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingResponseBody +func wasmimport_OutgoingResponseBody(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.OutgoingBody, github_com__rvolosatovs__west__bindings__wasi__http__types.OutgoingBody, struct{}]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -929,7 +929,7 @@ func wasmimport_OutgoingResponseBody(self0 uint32, result *github_com__ydnar__wa return } -//go:linkname wasmimport_OutgoingResponseHeaders github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingResponseHeaders +//go:linkname wasmimport_OutgoingResponseHeaders github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingResponseHeaders func wasmimport_OutgoingResponseHeaders(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -949,7 +949,7 @@ func wasmimport_OutgoingResponseHeaders(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutgoingResponseSetStatusCode github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingResponseSetStatusCode +//go:linkname wasmimport_OutgoingResponseSetStatusCode github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingResponseSetStatusCode func wasmimport_OutgoingResponseSetStatusCode(self0 uint32, statusCode0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -973,7 +973,7 @@ func wasmimport_OutgoingResponseSetStatusCode(self0 uint32, statusCode0 uint32) return } -//go:linkname wasmimport_OutgoingResponseStatusCode github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingResponseStatusCode +//go:linkname wasmimport_OutgoingResponseStatusCode github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingResponseStatusCode func wasmimport_OutgoingResponseStatusCode(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -993,8 +993,8 @@ func wasmimport_OutgoingResponseStatusCode(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_RequestOptionsBetweenBytesTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsBetweenBytesTimeout -func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__clocks__monotonic___clock.Duration]) { +//go:linkname wasmimport_RequestOptionsBetweenBytesTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsBetweenBytesTimeout +func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__clocks__monotonic___clock.Duration]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1013,8 +1013,8 @@ func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *github_c return } -//go:linkname wasmimport_RequestOptionsConnectTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsConnectTimeout -func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__clocks__monotonic___clock.Duration]) { +//go:linkname wasmimport_RequestOptionsConnectTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsConnectTimeout +func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__clocks__monotonic___clock.Duration]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1033,8 +1033,8 @@ func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *github_com__y return } -//go:linkname wasmimport_RequestOptionsFirstByteTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsFirstByteTimeout -func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__clocks__monotonic___clock.Duration]) { +//go:linkname wasmimport_RequestOptionsFirstByteTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsFirstByteTimeout +func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__clocks__monotonic___clock.Duration]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1053,7 +1053,7 @@ func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *github_com_ return } -//go:linkname wasmimport_RequestOptionsSetBetweenBytesTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsSetBetweenBytesTimeout +//go:linkname wasmimport_RequestOptionsSetBetweenBytesTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsSetBetweenBytesTimeout func wasmimport_RequestOptionsSetBetweenBytesTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1081,7 +1081,7 @@ func wasmimport_RequestOptionsSetBetweenBytesTimeout(self0 uint32, duration0 uin return } -//go:linkname wasmimport_RequestOptionsSetConnectTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsSetConnectTimeout +//go:linkname wasmimport_RequestOptionsSetConnectTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsSetConnectTimeout func wasmimport_RequestOptionsSetConnectTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1109,7 +1109,7 @@ func wasmimport_RequestOptionsSetConnectTimeout(self0 uint32, duration0 uint32, return } -//go:linkname wasmimport_RequestOptionsSetFirstByteTimeout github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsSetFirstByteTimeout +//go:linkname wasmimport_RequestOptionsSetFirstByteTimeout github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsSetFirstByteTimeout func wasmimport_RequestOptionsSetFirstByteTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1137,7 +1137,7 @@ func wasmimport_RequestOptionsSetFirstByteTimeout(self0 uint32, duration0 uint32 return } -//go:linkname wasmimport_FieldsResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsResourceDrop +//go:linkname wasmimport_FieldsResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsResourceDrop func wasmimport_FieldsResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1153,7 +1153,7 @@ func wasmimport_FieldsResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_FutureIncomingResponseResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureIncomingResponseResourceDrop +//go:linkname wasmimport_FutureIncomingResponseResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureIncomingResponseResourceDrop func wasmimport_FutureIncomingResponseResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1169,7 +1169,7 @@ func wasmimport_FutureIncomingResponseResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_FutureTrailersResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FutureTrailersResourceDrop +//go:linkname wasmimport_FutureTrailersResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FutureTrailersResourceDrop func wasmimport_FutureTrailersResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1185,7 +1185,7 @@ func wasmimport_FutureTrailersResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_IncomingBodyResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingBodyResourceDrop +//go:linkname wasmimport_IncomingBodyResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingBodyResourceDrop func wasmimport_IncomingBodyResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1201,7 +1201,7 @@ func wasmimport_IncomingBodyResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_IncomingRequestResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingRequestResourceDrop +//go:linkname wasmimport_IncomingRequestResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingRequestResourceDrop func wasmimport_IncomingRequestResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1217,7 +1217,7 @@ func wasmimport_IncomingRequestResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_IncomingResponseResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingResponseResourceDrop +//go:linkname wasmimport_IncomingResponseResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingResponseResourceDrop func wasmimport_IncomingResponseResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1233,7 +1233,7 @@ func wasmimport_IncomingResponseResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_OutgoingBodyResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingBodyResourceDrop +//go:linkname wasmimport_OutgoingBodyResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingBodyResourceDrop func wasmimport_OutgoingBodyResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1249,7 +1249,7 @@ func wasmimport_OutgoingBodyResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_OutgoingRequestResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingRequestResourceDrop +//go:linkname wasmimport_OutgoingRequestResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingRequestResourceDrop func wasmimport_OutgoingRequestResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1265,7 +1265,7 @@ func wasmimport_OutgoingRequestResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_OutgoingResponseResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingResponseResourceDrop +//go:linkname wasmimport_OutgoingResponseResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingResponseResourceDrop func wasmimport_OutgoingResponseResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1281,7 +1281,7 @@ func wasmimport_OutgoingResponseResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_RequestOptionsResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_RequestOptionsResourceDrop +//go:linkname wasmimport_RequestOptionsResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_RequestOptionsResourceDrop func wasmimport_RequestOptionsResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1297,7 +1297,7 @@ func wasmimport_RequestOptionsResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_ResponseOutparamResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_ResponseOutparamResourceDrop +//go:linkname wasmimport_ResponseOutparamResourceDrop github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_ResponseOutparamResourceDrop func wasmimport_ResponseOutparamResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1313,8 +1313,8 @@ func wasmimport_ResponseOutparamResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_FieldsFromList github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_FieldsFromList -func wasmimport_FieldsFromList(entries0 *github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldKey, github_com__rvolosatovs__west__go__bindings__wasi__http__types.FieldValue], entries1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.Fields, github_com__rvolosatovs__west__go__bindings__wasi__http__types.Fields, github_com__rvolosatovs__west__go__bindings__wasi__http__types.HeaderError]) { +//go:linkname wasmimport_FieldsFromList github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_FieldsFromList +func wasmimport_FieldsFromList(entries0 *github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__bindings__wasi__http__types.FieldKey, github_com__rvolosatovs__west__bindings__wasi__http__types.FieldValue], entries1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.Fields, github_com__rvolosatovs__west__bindings__wasi__http__types.Fields, github_com__rvolosatovs__west__bindings__wasi__http__types.HeaderError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1337,7 +1337,7 @@ func wasmimport_FieldsFromList(entries0 *github_com__ydnar__wasm___tools___go__c return } -//go:linkname wasmimport_IncomingBodyFinish github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_IncomingBodyFinish +//go:linkname wasmimport_IncomingBodyFinish github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_IncomingBodyFinish func wasmimport_IncomingBodyFinish(this0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1357,8 +1357,8 @@ func wasmimport_IncomingBodyFinish(this0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutgoingBodyFinish github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_OutgoingBodyFinish -func wasmimport_OutgoingBodyFinish(this0 uint32, trailers0 uint32, trailers1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode]) { +//go:linkname wasmimport_OutgoingBodyFinish github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_OutgoingBodyFinish +func wasmimport_OutgoingBodyFinish(this0 uint32, trailers0 uint32, trailers1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode, struct{}, github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1385,7 +1385,7 @@ func wasmimport_OutgoingBodyFinish(this0 uint32, trailers0 uint32, trailers1 uin return } -//go:linkname wasmimport_ResponseOutparamSet github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_ResponseOutparamSet +//go:linkname wasmimport_ResponseOutparamSet github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_ResponseOutparamSet func wasmimport_ResponseOutparamSet(param0 uint32, response0 uint32, response1 uint32, response2 uint32, response3 uint64, response4 uint32, response5 uint32, response6 uint32, response7 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1433,8 +1433,8 @@ func wasmimport_ResponseOutparamSet(param0 uint32, response0 uint32, response1 u return } -//go:linkname wasmimport_HTTPErrorCode github.com/rvolosatovs/west/go/bindings/wasi/http/types.wasmimport_HTTPErrorCode -func wasmimport_HTTPErrorCode(err0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ErrorCode]) { +//go:linkname wasmimport_HTTPErrorCode github.com/rvolosatovs/west/bindings/wasi/http/types.wasmimport_HTTPErrorCode +func wasmimport_HTTPErrorCode(err0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Option[github_com__rvolosatovs__west__bindings__wasi__http__types.ErrorCode]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1453,7 +1453,7 @@ func wasmimport_HTTPErrorCode(err0 uint32, result *github_com__ydnar__wasm___too return } -//go:linkname wasmimport_ErrorToDebugString github.com/rvolosatovs/west/go/bindings/wasi/io/error.wasmimport_ErrorToDebugString +//go:linkname wasmimport_ErrorToDebugString github.com/rvolosatovs/west/bindings/wasi/io/error.wasmimport_ErrorToDebugString func wasmimport_ErrorToDebugString(self0 uint32, result *string) { var __p runtime.Pinner defer __p.Unpin() @@ -1473,7 +1473,7 @@ func wasmimport_ErrorToDebugString(self0 uint32, result *string) { return } -//go:linkname wasmimport_ErrorResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/io/error.wasmimport_ErrorResourceDrop +//go:linkname wasmimport_ErrorResourceDrop github.com/rvolosatovs/west/bindings/wasi/io/error.wasmimport_ErrorResourceDrop func wasmimport_ErrorResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1489,7 +1489,7 @@ func wasmimport_ErrorResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_PollableBlock github.com/rvolosatovs/west/go/bindings/wasi/io/poll.wasmimport_PollableBlock +//go:linkname wasmimport_PollableBlock github.com/rvolosatovs/west/bindings/wasi/io/poll.wasmimport_PollableBlock func wasmimport_PollableBlock(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1505,7 +1505,7 @@ func wasmimport_PollableBlock(self0 uint32) { return } -//go:linkname wasmimport_PollableReady github.com/rvolosatovs/west/go/bindings/wasi/io/poll.wasmimport_PollableReady +//go:linkname wasmimport_PollableReady github.com/rvolosatovs/west/bindings/wasi/io/poll.wasmimport_PollableReady func wasmimport_PollableReady(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1525,7 +1525,7 @@ func wasmimport_PollableReady(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_PollableResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/io/poll.wasmimport_PollableResourceDrop +//go:linkname wasmimport_PollableResourceDrop github.com/rvolosatovs/west/bindings/wasi/io/poll.wasmimport_PollableResourceDrop func wasmimport_PollableResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1541,8 +1541,8 @@ func wasmimport_PollableResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_Poll github.com/rvolosatovs/west/go/bindings/wasi/io/poll.wasmimport_Poll -func wasmimport_Poll(in0 *github_com__rvolosatovs__west__go__bindings__wasi__io__poll.Pollable, in1 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[uint32]) { +//go:linkname wasmimport_Poll github.com/rvolosatovs/west/bindings/wasi/io/poll.wasmimport_Poll +func wasmimport_Poll(in0 *github_com__rvolosatovs__west__bindings__wasi__io__poll.Pollable, in1 uint32, result *github_com__ydnar__wasm___tools___go__cm.List[uint32]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1565,8 +1565,8 @@ func wasmimport_Poll(in0 *github_com__rvolosatovs__west__go__bindings__wasi__io_ return } -//go:linkname wasmimport_InputStreamBlockingRead github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamBlockingRead -func wasmimport_InputStreamBlockingRead(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_InputStreamBlockingRead github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamBlockingRead +func wasmimport_InputStreamBlockingRead(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1589,8 +1589,8 @@ func wasmimport_InputStreamBlockingRead(self0 uint32, len0 uint64, result *githu return } -//go:linkname wasmimport_InputStreamBlockingSkip github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamBlockingSkip -func wasmimport_InputStreamBlockingSkip(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_InputStreamBlockingSkip github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamBlockingSkip +func wasmimport_InputStreamBlockingSkip(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1613,8 +1613,8 @@ func wasmimport_InputStreamBlockingSkip(self0 uint32, len0 uint64, result *githu return } -//go:linkname wasmimport_InputStreamRead github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamRead -func wasmimport_InputStreamRead(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_InputStreamRead github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamRead +func wasmimport_InputStreamRead(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__ydnar__wasm___tools___go__cm.List[uint8], github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1637,8 +1637,8 @@ func wasmimport_InputStreamRead(self0 uint32, len0 uint64, result *github_com__y return } -//go:linkname wasmimport_InputStreamSkip github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamSkip -func wasmimport_InputStreamSkip(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_InputStreamSkip github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamSkip +func wasmimport_InputStreamSkip(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1661,7 +1661,7 @@ func wasmimport_InputStreamSkip(self0 uint32, len0 uint64, result *github_com__y return } -//go:linkname wasmimport_InputStreamSubscribe github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamSubscribe +//go:linkname wasmimport_InputStreamSubscribe github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamSubscribe func wasmimport_InputStreamSubscribe(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1681,8 +1681,8 @@ func wasmimport_InputStreamSubscribe(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutputStreamBlockingFlush github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingFlush -func wasmimport_OutputStreamBlockingFlush(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamBlockingFlush github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingFlush +func wasmimport_OutputStreamBlockingFlush(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1701,8 +1701,8 @@ func wasmimport_OutputStreamBlockingFlush(self0 uint32, result *github_com__ydna return } -//go:linkname wasmimport_OutputStreamBlockingSplice github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingSplice -func wasmimport_OutputStreamBlockingSplice(self0 uint32, src0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamBlockingSplice github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingSplice +func wasmimport_OutputStreamBlockingSplice(self0 uint32, src0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1729,8 +1729,8 @@ func wasmimport_OutputStreamBlockingSplice(self0 uint32, src0 uint32, len0 uint6 return } -//go:linkname wasmimport_OutputStreamBlockingWriteAndFlush github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingWriteAndFlush -func wasmimport_OutputStreamBlockingWriteAndFlush(self0 uint32, contents0 *uint8, contents1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamBlockingWriteAndFlush github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingWriteAndFlush +func wasmimport_OutputStreamBlockingWriteAndFlush(self0 uint32, contents0 *uint8, contents1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1757,8 +1757,8 @@ func wasmimport_OutputStreamBlockingWriteAndFlush(self0 uint32, contents0 *uint8 return } -//go:linkname wasmimport_OutputStreamBlockingWriteZeroesAndFlush github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingWriteZeroesAndFlush -func wasmimport_OutputStreamBlockingWriteZeroesAndFlush(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamBlockingWriteZeroesAndFlush github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamBlockingWriteZeroesAndFlush +func wasmimport_OutputStreamBlockingWriteZeroesAndFlush(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1781,8 +1781,8 @@ func wasmimport_OutputStreamBlockingWriteZeroesAndFlush(self0 uint32, len0 uint6 return } -//go:linkname wasmimport_OutputStreamCheckWrite github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamCheckWrite -func wasmimport_OutputStreamCheckWrite(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamCheckWrite github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamCheckWrite +func wasmimport_OutputStreamCheckWrite(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1801,8 +1801,8 @@ func wasmimport_OutputStreamCheckWrite(self0 uint32, result *github_com__ydnar__ return } -//go:linkname wasmimport_OutputStreamFlush github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamFlush -func wasmimport_OutputStreamFlush(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamFlush github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamFlush +func wasmimport_OutputStreamFlush(self0 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1821,8 +1821,8 @@ func wasmimport_OutputStreamFlush(self0 uint32, result *github_com__ydnar__wasm_ return } -//go:linkname wasmimport_OutputStreamSplice github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamSplice -func wasmimport_OutputStreamSplice(self0 uint32, src0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamSplice github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamSplice +func wasmimport_OutputStreamSplice(self0 uint32, src0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[uint64, uint64, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1849,7 +1849,7 @@ func wasmimport_OutputStreamSplice(self0 uint32, src0 uint32, len0 uint64, resul return } -//go:linkname wasmimport_OutputStreamSubscribe github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamSubscribe +//go:linkname wasmimport_OutputStreamSubscribe github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamSubscribe func wasmimport_OutputStreamSubscribe(self0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1869,8 +1869,8 @@ func wasmimport_OutputStreamSubscribe(self0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_OutputStreamWrite github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamWrite -func wasmimport_OutputStreamWrite(self0 uint32, contents0 *uint8, contents1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamWrite github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamWrite +func wasmimport_OutputStreamWrite(self0 uint32, contents0 *uint8, contents1 uint32, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1897,8 +1897,8 @@ func wasmimport_OutputStreamWrite(self0 uint32, contents0 *uint8, contents1 uint return } -//go:linkname wasmimport_OutputStreamWriteZeroes github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamWriteZeroes -func wasmimport_OutputStreamWriteZeroes(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__go__bindings__wasi__io__streams.StreamError]) { +//go:linkname wasmimport_OutputStreamWriteZeroes github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamWriteZeroes +func wasmimport_OutputStreamWriteZeroes(self0 uint32, len0 uint64, result *github_com__ydnar__wasm___tools___go__cm.Result[github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError, struct{}, github_com__rvolosatovs__west__bindings__wasi__io__streams.StreamError]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { @@ -1921,7 +1921,7 @@ func wasmimport_OutputStreamWriteZeroes(self0 uint32, len0 uint64, result *githu return } -//go:linkname wasmimport_InputStreamResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_InputStreamResourceDrop +//go:linkname wasmimport_InputStreamResourceDrop github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_InputStreamResourceDrop func wasmimport_InputStreamResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1937,7 +1937,7 @@ func wasmimport_InputStreamResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_OutputStreamResourceDrop github.com/rvolosatovs/west/go/bindings/wasi/io/streams.wasmimport_OutputStreamResourceDrop +//go:linkname wasmimport_OutputStreamResourceDrop github.com/rvolosatovs/west/bindings/wasi/io/streams.wasmimport_OutputStreamResourceDrop func wasmimport_OutputStreamResourceDrop(self0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1953,7 +1953,7 @@ func wasmimport_OutputStreamResourceDrop(self0 uint32) { return } -//go:linkname wasmimport_NewIncomingRequest github.com/rvolosatovs/west/go/bindings/west/test/http-test.wasmimport_NewIncomingRequest +//go:linkname wasmimport_NewIncomingRequest github.com/rvolosatovs/west/bindings/west/test/http-test.wasmimport_NewIncomingRequest func wasmimport_NewIncomingRequest(req0 uint32) (result0 uint32) { var __p runtime.Pinner defer __p.Unpin() @@ -1973,8 +1973,8 @@ func wasmimport_NewIncomingRequest(req0 uint32) (result0 uint32) { return } -//go:linkname wasmimport_NewResponseOutparam github.com/rvolosatovs/west/go/bindings/west/test/http-test.wasmimport_NewResponseOutparam -func wasmimport_NewResponseOutparam(result *github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__go__bindings__wasi__http__types.ResponseOutparam, github_com__rvolosatovs__west__go__bindings__wasi__http__types.FutureIncomingResponse]) { +//go:linkname wasmimport_NewResponseOutparam github.com/rvolosatovs/west/bindings/west/test/http-test.wasmimport_NewResponseOutparam +func wasmimport_NewResponseOutparam(result *github_com__ydnar__wasm___tools___go__cm.Tuple[github_com__rvolosatovs__west__bindings__wasi__http__types.ResponseOutparam, github_com__rvolosatovs__west__bindings__wasi__http__types.FutureIncomingResponse]) { var __p runtime.Pinner defer __p.Unpin() if __err := west.WithCurrentInstance(func(__instance *west.Instance) error { diff --git a/go/bindings/wasi/cli/environment/empty.s b/bindings/wasi/cli/environment/empty.s similarity index 100% rename from go/bindings/wasi/cli/environment/empty.s rename to bindings/wasi/cli/environment/empty.s diff --git a/go/bindings/wasi/cli/environment/environment.wit.go b/bindings/wasi/cli/environment/environment.wit.go similarity index 100% rename from go/bindings/wasi/cli/environment/environment.wit.go rename to bindings/wasi/cli/environment/environment.wit.go diff --git a/go/bindings/wasi/cli/exit/empty.s b/bindings/wasi/cli/exit/empty.s similarity index 100% rename from go/bindings/wasi/cli/exit/empty.s rename to bindings/wasi/cli/exit/empty.s diff --git a/go/bindings/wasi/cli/exit/exit.wit.go b/bindings/wasi/cli/exit/exit.wit.go similarity index 100% rename from go/bindings/wasi/cli/exit/exit.wit.go rename to bindings/wasi/cli/exit/exit.wit.go diff --git a/go/bindings/wasi/cli/imports/imports.wit.go b/bindings/wasi/cli/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/cli/imports/imports.wit.go rename to bindings/wasi/cli/imports/imports.wit.go diff --git a/go/bindings/wasi/cli/stderr/empty.s b/bindings/wasi/cli/stderr/empty.s similarity index 100% rename from go/bindings/wasi/cli/stderr/empty.s rename to bindings/wasi/cli/stderr/empty.s diff --git a/go/bindings/wasi/cli/stderr/stderr.wit.go b/bindings/wasi/cli/stderr/stderr.wit.go similarity index 90% rename from go/bindings/wasi/cli/stderr/stderr.wit.go rename to bindings/wasi/cli/stderr/stderr.wit.go index 5346589..da7dee1 100644 --- a/go/bindings/wasi/cli/stderr/stderr.wit.go +++ b/bindings/wasi/cli/stderr/stderr.wit.go @@ -4,7 +4,7 @@ package stderr import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/cli/stdin/empty.s b/bindings/wasi/cli/stdin/empty.s similarity index 100% rename from go/bindings/wasi/cli/stdin/empty.s rename to bindings/wasi/cli/stdin/empty.s diff --git a/go/bindings/wasi/cli/stdin/stdin.wit.go b/bindings/wasi/cli/stdin/stdin.wit.go similarity index 90% rename from go/bindings/wasi/cli/stdin/stdin.wit.go rename to bindings/wasi/cli/stdin/stdin.wit.go index 4a2c99d..6b36f2a 100644 --- a/go/bindings/wasi/cli/stdin/stdin.wit.go +++ b/bindings/wasi/cli/stdin/stdin.wit.go @@ -4,7 +4,7 @@ package stdin import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/cli/stdout/empty.s b/bindings/wasi/cli/stdout/empty.s similarity index 100% rename from go/bindings/wasi/cli/stdout/empty.s rename to bindings/wasi/cli/stdout/empty.s diff --git a/go/bindings/wasi/cli/stdout/stdout.wit.go b/bindings/wasi/cli/stdout/stdout.wit.go similarity index 90% rename from go/bindings/wasi/cli/stdout/stdout.wit.go rename to bindings/wasi/cli/stdout/stdout.wit.go index 2c27c52..139b848 100644 --- a/go/bindings/wasi/cli/stdout/stdout.wit.go +++ b/bindings/wasi/cli/stdout/stdout.wit.go @@ -4,7 +4,7 @@ package stdout import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/cli/terminal-input/empty.s b/bindings/wasi/cli/terminal-input/empty.s similarity index 100% rename from go/bindings/wasi/cli/terminal-input/empty.s rename to bindings/wasi/cli/terminal-input/empty.s diff --git a/go/bindings/wasi/cli/terminal-input/terminal-input.wit.go b/bindings/wasi/cli/terminal-input/terminal-input.wit.go similarity index 100% rename from go/bindings/wasi/cli/terminal-input/terminal-input.wit.go rename to bindings/wasi/cli/terminal-input/terminal-input.wit.go diff --git a/go/bindings/wasi/cli/terminal-output/empty.s b/bindings/wasi/cli/terminal-output/empty.s similarity index 100% rename from go/bindings/wasi/cli/terminal-output/empty.s rename to bindings/wasi/cli/terminal-output/empty.s diff --git a/go/bindings/wasi/cli/terminal-output/terminal-output.wit.go b/bindings/wasi/cli/terminal-output/terminal-output.wit.go similarity index 100% rename from go/bindings/wasi/cli/terminal-output/terminal-output.wit.go rename to bindings/wasi/cli/terminal-output/terminal-output.wit.go diff --git a/go/bindings/wasi/cli/terminal-stderr/empty.s b/bindings/wasi/cli/terminal-stderr/empty.s similarity index 100% rename from go/bindings/wasi/cli/terminal-stderr/empty.s rename to bindings/wasi/cli/terminal-stderr/empty.s diff --git a/go/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go b/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go similarity index 91% rename from go/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go rename to bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go index a9f8d5b..f5db3e6 100644 --- a/go/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go +++ b/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go @@ -7,7 +7,7 @@ package terminalstderr import ( - terminaloutput "github.com/rvolosatovs/west/go/bindings/wasi/cli/terminal-output" + terminaloutput "github.com/rvolosatovs/west/bindings/wasi/cli/terminal-output" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/cli/terminal-stdin/empty.s b/bindings/wasi/cli/terminal-stdin/empty.s similarity index 100% rename from go/bindings/wasi/cli/terminal-stdin/empty.s rename to bindings/wasi/cli/terminal-stdin/empty.s diff --git a/go/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go b/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go similarity index 91% rename from go/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go rename to bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go index d99c239..607134c 100644 --- a/go/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go +++ b/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go @@ -7,7 +7,7 @@ package terminalstdin import ( - terminalinput "github.com/rvolosatovs/west/go/bindings/wasi/cli/terminal-input" + terminalinput "github.com/rvolosatovs/west/bindings/wasi/cli/terminal-input" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/cli/terminal-stdout/empty.s b/bindings/wasi/cli/terminal-stdout/empty.s similarity index 100% rename from go/bindings/wasi/cli/terminal-stdout/empty.s rename to bindings/wasi/cli/terminal-stdout/empty.s diff --git a/go/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go b/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go similarity index 91% rename from go/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go rename to bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go index ed7ca8e..88dc70b 100644 --- a/go/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go +++ b/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go @@ -7,7 +7,7 @@ package terminalstdout import ( - terminaloutput "github.com/rvolosatovs/west/go/bindings/wasi/cli/terminal-output" + terminaloutput "github.com/rvolosatovs/west/bindings/wasi/cli/terminal-output" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/clocks/imports/imports.wit.go b/bindings/wasi/clocks/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/clocks/imports/imports.wit.go rename to bindings/wasi/clocks/imports/imports.wit.go diff --git a/go/bindings/wasi/clocks/monotonic-clock/empty.s b/bindings/wasi/clocks/monotonic-clock/empty.s similarity index 100% rename from go/bindings/wasi/clocks/monotonic-clock/empty.s rename to bindings/wasi/clocks/monotonic-clock/empty.s diff --git a/go/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go b/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go similarity index 98% rename from go/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go rename to bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go index 804fc20..0d55b04 100644 --- a/go/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go +++ b/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go @@ -15,7 +15,7 @@ package monotonicclock import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/clocks/wall-clock/empty.s b/bindings/wasi/clocks/wall-clock/empty.s similarity index 100% rename from go/bindings/wasi/clocks/wall-clock/empty.s rename to bindings/wasi/clocks/wall-clock/empty.s diff --git a/go/bindings/wasi/clocks/wall-clock/wall-clock.wit.go b/bindings/wasi/clocks/wall-clock/wall-clock.wit.go similarity index 100% rename from go/bindings/wasi/clocks/wall-clock/wall-clock.wit.go rename to bindings/wasi/clocks/wall-clock/wall-clock.wit.go diff --git a/go/bindings/wasi/filesystem/imports/imports.wit.go b/bindings/wasi/filesystem/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/filesystem/imports/imports.wit.go rename to bindings/wasi/filesystem/imports/imports.wit.go diff --git a/go/bindings/wasi/filesystem/preopens/empty.s b/bindings/wasi/filesystem/preopens/empty.s similarity index 100% rename from go/bindings/wasi/filesystem/preopens/empty.s rename to bindings/wasi/filesystem/preopens/empty.s diff --git a/go/bindings/wasi/filesystem/preopens/preopens.wit.go b/bindings/wasi/filesystem/preopens/preopens.wit.go similarity index 91% rename from go/bindings/wasi/filesystem/preopens/preopens.wit.go rename to bindings/wasi/filesystem/preopens/preopens.wit.go index 40c0008..d46fb92 100644 --- a/go/bindings/wasi/filesystem/preopens/preopens.wit.go +++ b/bindings/wasi/filesystem/preopens/preopens.wit.go @@ -4,7 +4,7 @@ package preopens import ( - "github.com/rvolosatovs/west/go/bindings/wasi/filesystem/types" + "github.com/rvolosatovs/west/bindings/wasi/filesystem/types" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/filesystem/types/abi.go b/bindings/wasi/filesystem/types/abi.go similarity index 94% rename from go/bindings/wasi/filesystem/types/abi.go rename to bindings/wasi/filesystem/types/abi.go index f800bcd..7379909 100644 --- a/go/bindings/wasi/filesystem/types/abi.go +++ b/bindings/wasi/filesystem/types/abi.go @@ -3,7 +3,7 @@ package types import ( - wallclock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/wall-clock" + wallclock "github.com/rvolosatovs/west/bindings/wasi/clocks/wall-clock" "github.com/ydnar/wasm-tools-go/cm" "unsafe" ) diff --git a/go/bindings/wasi/filesystem/types/empty.s b/bindings/wasi/filesystem/types/empty.s similarity index 100% rename from go/bindings/wasi/filesystem/types/empty.s rename to bindings/wasi/filesystem/types/empty.s diff --git a/go/bindings/wasi/filesystem/types/types.wit.go b/bindings/wasi/filesystem/types/types.wit.go similarity index 99% rename from go/bindings/wasi/filesystem/types/types.wit.go rename to bindings/wasi/filesystem/types/types.wit.go index d5f036c..4777e30 100644 --- a/go/bindings/wasi/filesystem/types/types.wit.go +++ b/bindings/wasi/filesystem/types/types.wit.go @@ -29,9 +29,9 @@ package types import ( - wallclock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/wall-clock" - ioerror "github.com/rvolosatovs/west/go/bindings/wasi/io/error" - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + wallclock "github.com/rvolosatovs/west/bindings/wasi/clocks/wall-clock" + ioerror "github.com/rvolosatovs/west/bindings/wasi/io/error" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/http/types/abi.go b/bindings/wasi/http/types/abi.go similarity index 98% rename from go/bindings/wasi/http/types/abi.go rename to bindings/wasi/http/types/abi.go index fcdb1b1..522754b 100644 --- a/go/bindings/wasi/http/types/abi.go +++ b/bindings/wasi/http/types/abi.go @@ -3,7 +3,7 @@ package types import ( - monotonicclock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock" + monotonicclock "github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock" "github.com/ydnar/wasm-tools-go/cm" "unsafe" ) diff --git a/go/bindings/wasi/http/types/empty.s b/bindings/wasi/http/types/empty.s similarity index 100% rename from go/bindings/wasi/http/types/empty.s rename to bindings/wasi/http/types/empty.s diff --git a/go/bindings/wasi/http/types/types.wit.go b/bindings/wasi/http/types/types.wit.go similarity index 99% rename from go/bindings/wasi/http/types/types.wit.go rename to bindings/wasi/http/types/types.wit.go index 042d4f1..27c1352 100644 --- a/go/bindings/wasi/http/types/types.wit.go +++ b/bindings/wasi/http/types/types.wit.go @@ -8,10 +8,10 @@ package types import ( - monotonicclock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock" - ioerror "github.com/rvolosatovs/west/go/bindings/wasi/io/error" - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" + monotonicclock "github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock" + ioerror "github.com/rvolosatovs/west/bindings/wasi/io/error" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/io/error/empty.s b/bindings/wasi/io/error/empty.s similarity index 100% rename from go/bindings/wasi/io/error/empty.s rename to bindings/wasi/io/error/empty.s diff --git a/go/bindings/wasi/io/error/error.wit.go b/bindings/wasi/io/error/error.wit.go similarity index 100% rename from go/bindings/wasi/io/error/error.wit.go rename to bindings/wasi/io/error/error.wit.go diff --git a/go/bindings/wasi/io/imports/imports.wit.go b/bindings/wasi/io/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/io/imports/imports.wit.go rename to bindings/wasi/io/imports/imports.wit.go diff --git a/go/bindings/wasi/io/poll/empty.s b/bindings/wasi/io/poll/empty.s similarity index 100% rename from go/bindings/wasi/io/poll/empty.s rename to bindings/wasi/io/poll/empty.s diff --git a/go/bindings/wasi/io/poll/poll.wit.go b/bindings/wasi/io/poll/poll.wit.go similarity index 100% rename from go/bindings/wasi/io/poll/poll.wit.go rename to bindings/wasi/io/poll/poll.wit.go diff --git a/go/bindings/wasi/io/streams/abi.go b/bindings/wasi/io/streams/abi.go similarity index 100% rename from go/bindings/wasi/io/streams/abi.go rename to bindings/wasi/io/streams/abi.go diff --git a/go/bindings/wasi/io/streams/empty.s b/bindings/wasi/io/streams/empty.s similarity index 100% rename from go/bindings/wasi/io/streams/empty.s rename to bindings/wasi/io/streams/empty.s diff --git a/go/bindings/wasi/io/streams/streams.wit.go b/bindings/wasi/io/streams/streams.wit.go similarity index 99% rename from go/bindings/wasi/io/streams/streams.wit.go rename to bindings/wasi/io/streams/streams.wit.go index d88bcfa..cfd7bb3 100644 --- a/go/bindings/wasi/io/streams/streams.wit.go +++ b/bindings/wasi/io/streams/streams.wit.go @@ -10,8 +10,8 @@ package streams import ( - ioerror "github.com/rvolosatovs/west/go/bindings/wasi/io/error" - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" + ioerror "github.com/rvolosatovs/west/bindings/wasi/io/error" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/random/imports/imports.wit.go b/bindings/wasi/random/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/random/imports/imports.wit.go rename to bindings/wasi/random/imports/imports.wit.go diff --git a/go/bindings/wasi/random/insecure-seed/empty.s b/bindings/wasi/random/insecure-seed/empty.s similarity index 100% rename from go/bindings/wasi/random/insecure-seed/empty.s rename to bindings/wasi/random/insecure-seed/empty.s diff --git a/go/bindings/wasi/random/insecure-seed/insecure-seed.wit.go b/bindings/wasi/random/insecure-seed/insecure-seed.wit.go similarity index 100% rename from go/bindings/wasi/random/insecure-seed/insecure-seed.wit.go rename to bindings/wasi/random/insecure-seed/insecure-seed.wit.go diff --git a/go/bindings/wasi/random/insecure/empty.s b/bindings/wasi/random/insecure/empty.s similarity index 100% rename from go/bindings/wasi/random/insecure/empty.s rename to bindings/wasi/random/insecure/empty.s diff --git a/go/bindings/wasi/random/insecure/insecure.wit.go b/bindings/wasi/random/insecure/insecure.wit.go similarity index 100% rename from go/bindings/wasi/random/insecure/insecure.wit.go rename to bindings/wasi/random/insecure/insecure.wit.go diff --git a/go/bindings/wasi/random/random/empty.s b/bindings/wasi/random/random/empty.s similarity index 100% rename from go/bindings/wasi/random/random/empty.s rename to bindings/wasi/random/random/empty.s diff --git a/go/bindings/wasi/random/random/random.wit.go b/bindings/wasi/random/random/random.wit.go similarity index 100% rename from go/bindings/wasi/random/random/random.wit.go rename to bindings/wasi/random/random/random.wit.go diff --git a/go/bindings/wasi/sockets/imports/imports.wit.go b/bindings/wasi/sockets/imports/imports.wit.go similarity index 100% rename from go/bindings/wasi/sockets/imports/imports.wit.go rename to bindings/wasi/sockets/imports/imports.wit.go diff --git a/go/bindings/wasi/sockets/instance-network/empty.s b/bindings/wasi/sockets/instance-network/empty.s similarity index 100% rename from go/bindings/wasi/sockets/instance-network/empty.s rename to bindings/wasi/sockets/instance-network/empty.s diff --git a/go/bindings/wasi/sockets/instance-network/instance-network.wit.go b/bindings/wasi/sockets/instance-network/instance-network.wit.go similarity index 92% rename from go/bindings/wasi/sockets/instance-network/instance-network.wit.go rename to bindings/wasi/sockets/instance-network/instance-network.wit.go index a25c5f9..a27d546 100644 --- a/go/bindings/wasi/sockets/instance-network/instance-network.wit.go +++ b/bindings/wasi/sockets/instance-network/instance-network.wit.go @@ -6,7 +6,7 @@ package instancenetwork import ( - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/sockets/ip-name-lookup/abi.go b/bindings/wasi/sockets/ip-name-lookup/abi.go similarity index 82% rename from go/bindings/wasi/sockets/ip-name-lookup/abi.go rename to bindings/wasi/sockets/ip-name-lookup/abi.go index 7cc1912..6eeb465 100644 --- a/go/bindings/wasi/sockets/ip-name-lookup/abi.go +++ b/bindings/wasi/sockets/ip-name-lookup/abi.go @@ -3,7 +3,7 @@ package ipnamelookup import ( - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" "unsafe" ) diff --git a/go/bindings/wasi/sockets/ip-name-lookup/empty.s b/bindings/wasi/sockets/ip-name-lookup/empty.s similarity index 100% rename from go/bindings/wasi/sockets/ip-name-lookup/empty.s rename to bindings/wasi/sockets/ip-name-lookup/empty.s diff --git a/go/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go b/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go similarity index 97% rename from go/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go rename to bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go index 7fdc971..5ddc60b 100644 --- a/go/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go +++ b/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go @@ -4,8 +4,8 @@ package ipnamelookup import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/sockets/network/abi.go b/bindings/wasi/sockets/network/abi.go similarity index 100% rename from go/bindings/wasi/sockets/network/abi.go rename to bindings/wasi/sockets/network/abi.go diff --git a/go/bindings/wasi/sockets/network/empty.s b/bindings/wasi/sockets/network/empty.s similarity index 100% rename from go/bindings/wasi/sockets/network/empty.s rename to bindings/wasi/sockets/network/empty.s diff --git a/go/bindings/wasi/sockets/network/network.wit.go b/bindings/wasi/sockets/network/network.wit.go similarity index 100% rename from go/bindings/wasi/sockets/network/network.wit.go rename to bindings/wasi/sockets/network/network.wit.go diff --git a/go/bindings/wasi/sockets/tcp-create-socket/empty.s b/bindings/wasi/sockets/tcp-create-socket/empty.s similarity index 100% rename from go/bindings/wasi/sockets/tcp-create-socket/empty.s rename to bindings/wasi/sockets/tcp-create-socket/empty.s diff --git a/go/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go b/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go similarity index 94% rename from go/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go rename to bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go index 7259f53..4951d54 100644 --- a/go/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go +++ b/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go @@ -4,8 +4,8 @@ package tcpcreatesocket import ( - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/tcp" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/sockets/tcp" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/sockets/tcp/abi.go b/bindings/wasi/sockets/tcp/abi.go similarity index 95% rename from go/bindings/wasi/sockets/tcp/abi.go rename to bindings/wasi/sockets/tcp/abi.go index 61d723b..36dd66a 100644 --- a/go/bindings/wasi/sockets/tcp/abi.go +++ b/bindings/wasi/sockets/tcp/abi.go @@ -3,8 +3,8 @@ package tcp import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" "unsafe" ) diff --git a/go/bindings/wasi/sockets/tcp/empty.s b/bindings/wasi/sockets/tcp/empty.s similarity index 100% rename from go/bindings/wasi/sockets/tcp/empty.s rename to bindings/wasi/sockets/tcp/empty.s diff --git a/go/bindings/wasi/sockets/tcp/tcp.wit.go b/bindings/wasi/sockets/tcp/tcp.wit.go similarity index 99% rename from go/bindings/wasi/sockets/tcp/tcp.wit.go rename to bindings/wasi/sockets/tcp/tcp.wit.go index aa63fa1..5f14861 100644 --- a/go/bindings/wasi/sockets/tcp/tcp.wit.go +++ b/bindings/wasi/sockets/tcp/tcp.wit.go @@ -4,10 +4,10 @@ package tcp import ( - monotonicclock "github.com/rvolosatovs/west/go/bindings/wasi/clocks/monotonic-clock" - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" - "github.com/rvolosatovs/west/go/bindings/wasi/io/streams" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + monotonicclock "github.com/rvolosatovs/west/bindings/wasi/clocks/monotonic-clock" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/sockets/udp-create-socket/empty.s b/bindings/wasi/sockets/udp-create-socket/empty.s similarity index 100% rename from go/bindings/wasi/sockets/udp-create-socket/empty.s rename to bindings/wasi/sockets/udp-create-socket/empty.s diff --git a/go/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go b/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go similarity index 94% rename from go/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go rename to bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go index 0901d84..719fa39 100644 --- a/go/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go +++ b/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go @@ -4,8 +4,8 @@ package udpcreatesocket import ( - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/udp" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/sockets/udp" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/wasi/sockets/udp/abi.go b/bindings/wasi/sockets/udp/abi.go similarity index 97% rename from go/bindings/wasi/sockets/udp/abi.go rename to bindings/wasi/sockets/udp/abi.go index 57e722a..75b46b8 100644 --- a/go/bindings/wasi/sockets/udp/abi.go +++ b/bindings/wasi/sockets/udp/abi.go @@ -3,7 +3,7 @@ package udp import ( - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" "unsafe" ) diff --git a/go/bindings/wasi/sockets/udp/empty.s b/bindings/wasi/sockets/udp/empty.s similarity index 100% rename from go/bindings/wasi/sockets/udp/empty.s rename to bindings/wasi/sockets/udp/empty.s diff --git a/go/bindings/wasi/sockets/udp/udp.wit.go b/bindings/wasi/sockets/udp/udp.wit.go similarity index 99% rename from go/bindings/wasi/sockets/udp/udp.wit.go rename to bindings/wasi/sockets/udp/udp.wit.go index c1030ce..2be6d6e 100644 --- a/go/bindings/wasi/sockets/udp/udp.wit.go +++ b/bindings/wasi/sockets/udp/udp.wit.go @@ -4,8 +4,8 @@ package udp import ( - "github.com/rvolosatovs/west/go/bindings/wasi/io/poll" - "github.com/rvolosatovs/west/go/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/bindings/wasi/sockets/network" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/west.go b/bindings/west.go similarity index 63% rename from go/bindings/west.go rename to bindings/west.go index 14978d7..4bdc1e5 100644 --- a/go/bindings/west.go +++ b/bindings/west.go @@ -3,5 +3,5 @@ package bindings import ( - _ "github.com/rvolosatovs/west/go/bindings/west/test/http-test" + _ "github.com/rvolosatovs/west/bindings/west/test/http-test" ) diff --git a/go/bindings/west/test/http-test/empty.s b/bindings/west/test/http-test/empty.s similarity index 100% rename from go/bindings/west/test/http-test/empty.s rename to bindings/west/test/http-test/empty.s diff --git a/go/bindings/west/test/http-test/http-test.wit.go b/bindings/west/test/http-test/http-test.wit.go similarity index 95% rename from go/bindings/west/test/http-test/http-test.wit.go rename to bindings/west/test/http-test/http-test.wit.go index bd057c7..5f8f7b7 100644 --- a/go/bindings/west/test/http-test/http-test.wit.go +++ b/bindings/west/test/http-test/http-test.wit.go @@ -4,7 +4,7 @@ package httptest import ( - "github.com/rvolosatovs/west/go/bindings/wasi/http/types" + "github.com/rvolosatovs/west/bindings/wasi/http/types" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/bindings/west/test/imports/imports.wit.go b/bindings/west/test/imports/imports.wit.go similarity index 100% rename from go/bindings/west/test/imports/imports.wit.go rename to bindings/west/test/imports/imports.wit.go diff --git a/go/cmd/west-bindgen-go/main.go b/cmd/west-bindgen-go/main.go similarity index 99% rename from go/cmd/west-bindgen-go/main.go rename to cmd/west-bindgen-go/main.go index a2a7e4f..e569cfe 100644 --- a/go/cmd/west-bindgen-go/main.go +++ b/cmd/west-bindgen-go/main.go @@ -466,7 +466,7 @@ func generate(path string) error { }, { Name: &ast.Ident{Name: "west"}, - Path: &ast.BasicLit{Kind: token.STRING, Value: `"github.com/rvolosatovs/west/go"`}, + Path: &ast.BasicLit{Kind: token.STRING, Value: `"github.com/rvolosatovs/west"`}, }, } for path, name := range goImports { diff --git a/go/go.mod b/go.mod similarity index 57% rename from go/go.mod rename to go.mod index 6798b10..c01802a 100644 --- a/go/go.mod +++ b/go.mod @@ -1,14 +1,16 @@ -module github.com/rvolosatovs/west/go +module github.com/rvolosatovs/west go 1.23.0 -require golang.org/x/tools v0.24.0 +require ( + github.com/stretchr/testify v1.9.0 + github.com/ydnar/wasm-tools-go v0.1.5 + golang.org/x/tools v0.24.0 +) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.9.0 // indirect - github.com/ydnar/wasm-tools-go v0.1.5 // indirect golang.org/x/mod v0.20.0 // indirect golang.org/x/sync v0.8.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go/go.sum b/go.sum similarity index 93% rename from go/go.sum rename to go.sum index 49fa4f3..bba5fc0 100644 --- a/go/go.sum +++ b/go.sum @@ -12,6 +12,7 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go.work b/go.work index 5fe307d..f7d3d54 100644 --- a/go.work +++ b/go.work @@ -1,5 +1,5 @@ go 1.23.0 -use ./go +use ./. -replace github.com/rvolosatovs/west/go v0.0.1 => ./go +replace github.com/rvolosatovs/west v0.0.1 => ./. diff --git a/go.work.sum b/go.work.sum index 0d87c6a..321d589 100644 --- a/go.work.sum +++ b/go.work.sum @@ -8,3 +8,4 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/go/internal/tests/sync/sync.go b/go/internal/tests/sync/sync.go deleted file mode 100644 index 589a7b5..0000000 --- a/go/internal/tests/sync/sync.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:generate go run github.com/ydnar/wasm-tools-go/cmd/wit-bindgen-go@v0.1.5 generate -w guest -o bindings ../../../../tests/wit/sync -//go:generate go run ../../../cmd/west-bindgen-go - -package sync - -import ( - _ "github.com/rvolosatovs/west/go/internal/tests/sync/bindings/west-test/sync/sync" -) diff --git a/go/west_darwin_amd64.go b/go/west_darwin_amd64.go deleted file mode 100644 index 53b5f6d..0000000 --- a/go/west_darwin_amd64.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate cp ../target/release/libwest_sys.a ../lib/x86_64-darwin/libwest.a - -package west diff --git a/go/west_darwin_arm64.go b/go/west_darwin_arm64.go deleted file mode 100644 index b158cb7..0000000 --- a/go/west_darwin_arm64.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate cp ../target/release/libwest_sys.a ../lib/aarch64-darwin/libwest.a - -package west diff --git a/go/west_linux_amd64.go b/go/west_linux_amd64.go deleted file mode 100644 index 3d2030e..0000000 --- a/go/west_linux_amd64.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate cp ../target/release/libwest_sys.a ../lib/x86_64-linux/libwest.a - -package west diff --git a/go/west_linux_arm64.go b/go/west_linux_arm64.go deleted file mode 100644 index 62cf813..0000000 --- a/go/west_linux_arm64.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate cp ../target/release/libwest_sys.a ../lib/aarch64-linux/libwest.a - -package west diff --git a/go/west_windows_amd64.go b/go/west_windows_amd64.go deleted file mode 100644 index caafb82..0000000 --- a/go/west_windows_amd64.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate cp ../target/release/libwest_sys.a ../lib/x86_64-windows/libwest.a - -package west diff --git a/go/internal/tests/sync/bindings/.gitkeep b/tests/go/sync/bindings/.gitkeep similarity index 100% rename from go/internal/tests/sync/bindings/.gitkeep rename to tests/go/sync/bindings/.gitkeep diff --git a/tests/go/sync/bindings/west-test/sync/guest/guest.wit.go b/tests/go/sync/bindings/west-test/sync/guest/guest.wit.go new file mode 100644 index 0000000..eaa24d5 --- /dev/null +++ b/tests/go/sync/bindings/west-test/sync/guest/guest.wit.go @@ -0,0 +1,4 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package guest represents the world "west-test:sync/guest". +package guest diff --git a/tests/go/sync/bindings/west-test/sync/sync/abi.go b/tests/go/sync/bindings/west-test/sync/sync/abi.go new file mode 100644 index 0000000..5e646e4 --- /dev/null +++ b/tests/go/sync/bindings/west-test/sync/sync/abi.go @@ -0,0 +1,90 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package sync + +import ( + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// RecShape is used for storage in variant or result types. +type RecShape struct { + shape [unsafe.Sizeof(Rec{})]byte +} + +func lower_RecNested(v RecNested) (f0 *uint8, f1 uint32) { + f0, f1 = cm.LowerString(v.Foo) + return +} + +func lower_Rec(v Rec) (f0 *uint8, f1 uint32) { + f0, f1 = lower_RecNested(v.Nested) + return +} + +func lower_Var(v Var) (f0 uint32, f1 *uint8, f2 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 0: // var + v1, v2 := lower_Rec(*v.Var()) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } + return +} + +func lower_OptionString(v cm.Option[string]) (f0 uint32, f1 *uint8, f2 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1, v2 := cm.LowerString(*some) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } + return +} + +func lower_ResultString(v cm.Result[string, string, struct{}]) (f0 uint32, f1 *uint8, f2 uint32) { + if v.IsOK() { + v1, v2 := cm.LowerString(*v.OK()) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } else { + f0 = 1 + } + return +} + +func lower_Primitives(v Primitives) (f0 uint32, f1 uint32, f2 uint32, f3 uint64, f4 uint32, f5 uint32, f6 uint32, f7 uint64, f8 float32, f9 float64, f10 uint32, f11 uint32, f12 *uint8, f13 uint32) { + f0 = (uint32)(v.A) + f1 = (uint32)(v.B) + f2 = (uint32)(v.C) + f3 = (uint64)(v.D) + f4 = (uint32)(v.E) + f5 = (uint32)(v.F) + f6 = (uint32)(v.G) + f7 = (uint64)(v.H) + f8 = (float32)(v.I) + f9 = (float64)(v.J) + f10 = cm.BoolToU32(v.K) + f11 = (uint32)(v.L) + f12, f13 = cm.LowerString(v.M) + return +} + +func lower_TupleU8U16U32U64S8S16S32S64F32F64BoolCharString(v cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) (f0 uint32, f1 uint32, f2 uint32, f3 uint64, f4 uint32, f5 uint32, f6 uint32, f7 uint64, f8 float32, f9 float64, f10 uint32, f11 uint32, f12 *uint8, f13 uint32) { + f0 = (uint32)(v.F0) + f1 = (uint32)(v.F1) + f2 = (uint32)(v.F2) + f3 = (uint64)(v.F3) + f4 = (uint32)(v.F4) + f5 = (uint32)(v.F5) + f6 = (uint32)(v.F6) + f7 = (uint64)(v.F7) + f8 = (float32)(v.F8) + f9 = (float64)(v.F9) + f10 = cm.BoolToU32(v.F10) + f11 = (uint32)(v.F11) + f12, f13 = cm.LowerString(v.F12) + return +} diff --git a/tests/go/sync/bindings/west-test/sync/sync/empty.s b/tests/go/sync/bindings/west-test/sync/sync/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/sync/bindings/west-test/sync/sync/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/sync/bindings/west-test/sync/sync/sync.wit.go b/tests/go/sync/bindings/west-test/sync/sync/sync.wit.go new file mode 100644 index 0000000..3d00b21 --- /dev/null +++ b/tests/go/sync/bindings/west-test/sync/sync/sync.wit.go @@ -0,0 +1,700 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package sync represents the imported interface "west-test:sync/sync". +package sync + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// Abc represents the flags "west-test:sync/sync#abc". +// +// flags abc { +// a, +// b, +// c, +// } +type Abc uint8 + +const ( + AbcA Abc = 1 << iota + AbcB + AbcC +) + +// RecNested represents the record "west-test:sync/sync#rec-nested". +// +// record rec-nested { +// foo: string, +// } +type RecNested struct { + Foo string +} + +// Rec represents the record "west-test:sync/sync#rec". +// +// record rec { +// nested: rec-nested, +// } +type Rec struct { + Nested RecNested +} + +// Var represents the variant "west-test:sync/sync#var". +// +// variant var { +// var(rec), +// empty, +// } +type Var cm.Variant[uint8, Rec, Rec] + +// VarVar returns a [Var] of case "var". +func VarVar(data Rec) Var { + return cm.New[Var](0, data) +} + +// Var returns a non-nil *[Rec] if [Var] represents the variant case "var". +func (self *Var) Var() *Rec { + return cm.Case[Rec](self, 0) +} + +// VarEmpty returns a [Var] of case "empty". +func VarEmpty() Var { + var data struct{} + return cm.New[Var](1, data) +} + +// Empty returns true if [Var] represents the variant case "empty". +func (self *Var) Empty() bool { + return self.Tag() == 1 +} + +// Foobar represents the enum "west-test:sync/sync#foobar". +// +// enum foobar { +// foo, +// bar +// } +type Foobar uint8 + +const ( + FoobarFoo Foobar = iota + FoobarBar +) + +var stringsFoobar = [2]string{ + "foo", + "bar", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e Foobar) String() string { + return stringsFoobar[e] +} + +// Primitives represents the record "west-test:sync/sync#primitives". +// +// record primitives { +// a: u8, +// b: u16, +// c: u32, +// d: u64, +// e: s8, +// f: s16, +// g: s32, +// h: s64, +// i: f32, +// j: f64, +// k: bool, +// l: char, +// m: string, +// } +type Primitives struct { + A uint8 + B uint16 + C uint32 + D uint64 + E int8 + F int16 + G int32 + H int64 + I float32 + J float64 + K bool + L rune + M string +} + +// Res represents the imported resource "west-test:sync/sync#res". +// +// resource res +type Res cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "res". +// +// Drops a resource handle. +// +//go:nosplit +func (self Res) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ResResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport west-test:sync/sync [resource-drop]res +//go:noescape +func wasmimport_ResResourceDrop(self0 uint32) + +// NewRes represents the imported constructor for resource "res". +// +// constructor() +// +//go:nosplit +func NewRes() (result Res) { + result0 := wasmimport_NewRes() + result = cm.Reinterpret[Res]((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync [constructor]res +//go:noescape +func wasmimport_NewRes() (result0 uint32) + +// ResMakeList represents the imported static function "make-list". +// +// make-list: static func() -> list +// +//go:nosplit +func ResMakeList() (result cm.List[Res]) { + wasmimport_ResMakeList(&result) + return +} + +//go:wasmimport west-test:sync/sync [static]res.make-list +//go:noescape +func wasmimport_ResMakeList(result *cm.List[Res]) + +// Foo represents the imported method "foo". +// +// foo: func() -> string +// +//go:nosplit +func (self Res) Foo() (result string) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ResFoo((uint32)(self0), &result) + return +} + +//go:wasmimport west-test:sync/sync [method]res.foo +//go:noescape +func wasmimport_ResFoo(self0 uint32, result *string) + +// IdentityBool represents the imported function "identity-bool". +// +// identity-bool: func(arg: bool) -> bool +// +//go:nosplit +func IdentityBool(arg bool) (result bool) { + arg0 := cm.BoolToU32(arg) + result0 := wasmimport_IdentityBool((uint32)(arg0)) + result = cm.U32ToBool((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-bool +//go:noescape +func wasmimport_IdentityBool(arg0 uint32) (result0 uint32) + +// IdentityS8 represents the imported function "identity-s8". +// +// identity-s8: func(arg: s8) -> s8 +// +//go:nosplit +func IdentityS8(arg int8) (result int8) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityS8((uint32)(arg0)) + result = (int8)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-s8 +//go:noescape +func wasmimport_IdentityS8(arg0 uint32) (result0 uint32) + +// IdentityU8 represents the imported function "identity-u8". +// +// identity-u8: func(arg: u8) -> u8 +// +//go:nosplit +func IdentityU8(arg uint8) (result uint8) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityU8((uint32)(arg0)) + result = (uint8)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-u8 +//go:noescape +func wasmimport_IdentityU8(arg0 uint32) (result0 uint32) + +// IdentityS16 represents the imported function "identity-s16". +// +// identity-s16: func(arg: s16) -> s16 +// +//go:nosplit +func IdentityS16(arg int16) (result int16) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityS16((uint32)(arg0)) + result = (int16)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-s16 +//go:noescape +func wasmimport_IdentityS16(arg0 uint32) (result0 uint32) + +// IdentityU16 represents the imported function "identity-u16". +// +// identity-u16: func(arg: u16) -> u16 +// +//go:nosplit +func IdentityU16(arg uint16) (result uint16) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityU16((uint32)(arg0)) + result = (uint16)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-u16 +//go:noescape +func wasmimport_IdentityU16(arg0 uint32) (result0 uint32) + +// IdentityS32 represents the imported function "identity-s32". +// +// identity-s32: func(arg: s32) -> s32 +// +//go:nosplit +func IdentityS32(arg int32) (result int32) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityS32((uint32)(arg0)) + result = (int32)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-s32 +//go:noescape +func wasmimport_IdentityS32(arg0 uint32) (result0 uint32) + +// IdentityU32 represents the imported function "identity-u32". +// +// identity-u32: func(arg: u32) -> u32 +// +//go:nosplit +func IdentityU32(arg uint32) (result uint32) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityU32((uint32)(arg0)) + result = (uint32)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-u32 +//go:noescape +func wasmimport_IdentityU32(arg0 uint32) (result0 uint32) + +// IdentityS64 represents the imported function "identity-s64". +// +// identity-s64: func(arg: s64) -> s64 +// +//go:nosplit +func IdentityS64(arg int64) (result int64) { + arg0 := (uint64)(arg) + result0 := wasmimport_IdentityS64((uint64)(arg0)) + result = (int64)((uint64)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-s64 +//go:noescape +func wasmimport_IdentityS64(arg0 uint64) (result0 uint64) + +// IdentityU64 represents the imported function "identity-u64". +// +// identity-u64: func(arg: u64) -> u64 +// +//go:nosplit +func IdentityU64(arg uint64) (result uint64) { + arg0 := (uint64)(arg) + result0 := wasmimport_IdentityU64((uint64)(arg0)) + result = (uint64)((uint64)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-u64 +//go:noescape +func wasmimport_IdentityU64(arg0 uint64) (result0 uint64) + +// IdentityF32 represents the imported function "identity-f32". +// +// identity-f32: func(arg: f32) -> f32 +// +//go:nosplit +func IdentityF32(arg float32) (result float32) { + arg0 := (float32)(arg) + result0 := wasmimport_IdentityF32((float32)(arg0)) + result = (float32)((float32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-f32 +//go:noescape +func wasmimport_IdentityF32(arg0 float32) (result0 float32) + +// IdentityF64 represents the imported function "identity-f64". +// +// identity-f64: func(arg: f64) -> f64 +// +//go:nosplit +func IdentityF64(arg float64) (result float64) { + arg0 := (float64)(arg) + result0 := wasmimport_IdentityF64((float64)(arg0)) + result = (float64)((float64)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-f64 +//go:noescape +func wasmimport_IdentityF64(arg0 float64) (result0 float64) + +// IdentityChar represents the imported function "identity-char". +// +// identity-char: func(arg: char) -> char +// +//go:nosplit +func IdentityChar(arg rune) (result rune) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityChar((uint32)(arg0)) + result = (rune)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-char +//go:noescape +func wasmimport_IdentityChar(arg0 uint32) (result0 uint32) + +// IdentityString represents the imported function "identity-string". +// +// identity-string: func(arg: string) -> string +// +//go:nosplit +func IdentityString(arg string) (result string) { + arg0, arg1 := cm.LowerString(arg) + wasmimport_IdentityString((*uint8)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-string +//go:noescape +func wasmimport_IdentityString(arg0 *uint8, arg1 uint32, result *string) + +// IdentityFlags represents the imported function "identity-flags". +// +// identity-flags: func(arg: abc) -> abc +// +//go:nosplit +func IdentityFlags(arg Abc) (result Abc) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityFlags((uint32)(arg0)) + result = (Abc)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-flags +//go:noescape +func wasmimport_IdentityFlags(arg0 uint32) (result0 uint32) + +// IdentityEnum represents the imported function "identity-enum". +// +// identity-enum: func(arg: foobar) -> foobar +// +//go:nosplit +func IdentityEnum(arg Foobar) (result Foobar) { + arg0 := (uint32)(arg) + result0 := wasmimport_IdentityEnum((uint32)(arg0)) + result = (Foobar)((uint32)(result0)) + return +} + +//go:wasmimport west-test:sync/sync identity-enum +//go:noescape +func wasmimport_IdentityEnum(arg0 uint32) (result0 uint32) + +// IdentityVariant represents the imported function "identity-variant". +// +// identity-variant: func(arg: var) -> var +// +//go:nosplit +func IdentityVariant(arg Var) (result Var) { + arg0, arg1, arg2 := lower_Var(arg) + wasmimport_IdentityVariant((uint32)(arg0), (*uint8)(arg1), (uint32)(arg2), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-variant +//go:noescape +func wasmimport_IdentityVariant(arg0 uint32, arg1 *uint8, arg2 uint32, result *Var) + +// IdentityOptionString represents the imported function "identity-option-string". +// +// identity-option-string: func(arg: option) -> option +// +//go:nosplit +func IdentityOptionString(arg cm.Option[string]) (result cm.Option[string]) { + arg0, arg1, arg2 := lower_OptionString(arg) + wasmimport_IdentityOptionString((uint32)(arg0), (*uint8)(arg1), (uint32)(arg2), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-option-string +//go:noescape +func wasmimport_IdentityOptionString(arg0 uint32, arg1 *uint8, arg2 uint32, result *cm.Option[string]) + +// IdentityResultString represents the imported function "identity-result-string". +// +// identity-result-string: func(arg: result) -> result +// +//go:nosplit +func IdentityResultString(arg cm.Result[string, string, struct{}]) (result cm.Result[string, string, struct{}]) { + arg0, arg1, arg2 := lower_ResultString(arg) + wasmimport_IdentityResultString((uint32)(arg0), (*uint8)(arg1), (uint32)(arg2), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-result-string +//go:noescape +func wasmimport_IdentityResultString(arg0 uint32, arg1 *uint8, arg2 uint32, result *cm.Result[string, string, struct{}]) + +// IdentityRecordPrimitives represents the imported function "identity-record-primitives". +// +// identity-record-primitives: func(arg: primitives) -> primitives +// +//go:nosplit +func IdentityRecordPrimitives(arg Primitives) (result Primitives) { + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 := lower_Primitives(arg) + wasmimport_IdentityRecordPrimitives((uint32)(arg0), (uint32)(arg1), (uint32)(arg2), (uint64)(arg3), (uint32)(arg4), (uint32)(arg5), (uint32)(arg6), (uint64)(arg7), (float32)(arg8), (float64)(arg9), (uint32)(arg10), (uint32)(arg11), (*uint8)(arg12), (uint32)(arg13), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-record-primitives +//go:noescape +func wasmimport_IdentityRecordPrimitives(arg0 uint32, arg1 uint32, arg2 uint32, arg3 uint64, arg4 uint32, arg5 uint32, arg6 uint32, arg7 uint64, arg8 float32, arg9 float64, arg10 uint32, arg11 uint32, arg12 *uint8, arg13 uint32, result *Primitives) + +// IdentityRecordRec represents the imported function "identity-record-rec". +// +// identity-record-rec: func(arg: rec) -> rec +// +//go:nosplit +func IdentityRecordRec(arg Rec) (result Rec) { + arg0, arg1 := lower_Rec(arg) + wasmimport_IdentityRecordRec((*uint8)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-record-rec +//go:noescape +func wasmimport_IdentityRecordRec(arg0 *uint8, arg1 uint32, result *Rec) + +// IdentityTuple represents the imported function "identity-tuple". +// +// identity-tuple: func(arg: tuple) -> tuple +// +//go:nosplit +func IdentityTuple(arg cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) (result cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) { + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 := lower_TupleU8U16U32U64S8S16S32S64F32F64BoolCharString(arg) + wasmimport_IdentityTuple((uint32)(arg0), (uint32)(arg1), (uint32)(arg2), (uint64)(arg3), (uint32)(arg4), (uint32)(arg5), (uint32)(arg6), (uint64)(arg7), (float32)(arg8), (float64)(arg9), (uint32)(arg10), (uint32)(arg11), (*uint8)(arg12), (uint32)(arg13), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-tuple +//go:noescape +func wasmimport_IdentityTuple(arg0 uint32, arg1 uint32, arg2 uint32, arg3 uint64, arg4 uint32, arg5 uint32, arg6 uint32, arg7 uint64, arg8 float32, arg9 float64, arg10 uint32, arg11 uint32, arg12 *uint8, arg13 uint32, result *cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) + +// IdentityListBool represents the imported function "identity-list-bool". +// +// identity-list-bool: func(arg: list) -> list +// +//go:nosplit +func IdentityListBool(arg cm.List[bool]) (result cm.List[bool]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListBool((*bool)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-bool +//go:noescape +func wasmimport_IdentityListBool(arg0 *bool, arg1 uint32, result *cm.List[bool]) + +// IdentityListU16 represents the imported function "identity-list-u16". +// +// identity-list-u16: func(arg: list) -> list +// +//go:nosplit +func IdentityListU16(arg cm.List[uint16]) (result cm.List[uint16]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListU16((*uint16)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-u16 +//go:noescape +func wasmimport_IdentityListU16(arg0 *uint16, arg1 uint32, result *cm.List[uint16]) + +// IdentityListString represents the imported function "identity-list-string". +// +// identity-list-string: func(arg: list) -> list +// +//go:nosplit +func IdentityListString(arg cm.List[string]) (result cm.List[string]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListString((*string)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-string +//go:noescape +func wasmimport_IdentityListString(arg0 *string, arg1 uint32, result *cm.List[string]) + +// IdentityListEnum represents the imported function "identity-list-enum". +// +// identity-list-enum: func(arg: list) -> list +// +//go:nosplit +func IdentityListEnum(arg cm.List[Foobar]) (result cm.List[Foobar]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListEnum((*Foobar)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-enum +//go:noescape +func wasmimport_IdentityListEnum(arg0 *Foobar, arg1 uint32, result *cm.List[Foobar]) + +// IdentityListFlags represents the imported function "identity-list-flags". +// +// identity-list-flags: func(arg: list) -> list +// +//go:nosplit +func IdentityListFlags(arg cm.List[Abc]) (result cm.List[Abc]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListFlags((*Abc)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-flags +//go:noescape +func wasmimport_IdentityListFlags(arg0 *Abc, arg1 uint32, result *cm.List[Abc]) + +// IdentityListRecordPrimitives represents the imported function "identity-list-record-primitives". +// +// identity-list-record-primitives: func(arg: list) -> list +// +//go:nosplit +func IdentityListRecordPrimitives(arg cm.List[Primitives]) (result cm.List[Primitives]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListRecordPrimitives((*Primitives)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-record-primitives +//go:noescape +func wasmimport_IdentityListRecordPrimitives(arg0 *Primitives, arg1 uint32, result *cm.List[Primitives]) + +// IdentityListVariant represents the imported function "identity-list-variant". +// +// identity-list-variant: func(arg: list) -> list +// +//go:nosplit +func IdentityListVariant(arg cm.List[Var]) (result cm.List[Var]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListVariant((*Var)(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-variant +//go:noescape +func wasmimport_IdentityListVariant(arg0 *Var, arg1 uint32, result *cm.List[Var]) + +// IdentityListOptionString represents the imported function "identity-list-option-string". +// +// identity-list-option-string: func(arg: list>) -> list> +// +//go:nosplit +func IdentityListOptionString(arg cm.List[cm.Option[string]]) (result cm.List[cm.Option[string]]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListOptionString((*cm.Option[string])(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-option-string +//go:noescape +func wasmimport_IdentityListOptionString(arg0 *cm.Option[string], arg1 uint32, result *cm.List[cm.Option[string]]) + +// IdentityListResultString represents the imported function "identity-list-result-string". +// +// identity-list-result-string: func(arg: list>) -> list> +// +//go:nosplit +func IdentityListResultString(arg cm.List[cm.Result[string, string, struct{}]]) (result cm.List[cm.Result[string, string, struct{}]]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListResultString((*cm.Result[string, string, struct{}])(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-result-string +//go:noescape +func wasmimport_IdentityListResultString(arg0 *cm.Result[string, string, struct{}], arg1 uint32, result *cm.List[cm.Result[string, string, struct{}]]) + +// IdentityListListString represents the imported function "identity-list-list-string". +// +// identity-list-list-string: func(arg: list>) -> list> +// +//go:nosplit +func IdentityListListString(arg cm.List[cm.List[string]]) (result cm.List[cm.List[string]]) { + arg0, arg1 := cm.LowerList(arg) + wasmimport_IdentityListListString((*cm.List[string])(arg0), (uint32)(arg1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-list-list-string +//go:noescape +func wasmimport_IdentityListListString(arg0 *cm.List[string], arg1 uint32, result *cm.List[cm.List[string]]) + +// IdentityPrimitives represents the imported function "identity-primitives". +// +// identity-primitives: func(a: u8, b: u16, c: u32, d: u64, e: s8, f: s16, g: s32, +// h: s64, i: f32, j: f64, k: bool, l: char, m: string) -> tuple +// +//go:nosplit +func IdentityPrimitives(a uint8, b uint16, c uint32, d uint64, e int8, f int16, g int32, h int64, i float32, j float64, k bool, l rune, m string) (result cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) { + a0 := (uint32)(a) + b0 := (uint32)(b) + c0 := (uint32)(c) + d0 := (uint64)(d) + e0 := (uint32)(e) + f0 := (uint32)(f) + g0 := (uint32)(g) + h0 := (uint64)(h) + i0 := (float32)(i) + j0 := (float64)(j) + k0 := cm.BoolToU32(k) + l0 := (uint32)(l) + m0, m1 := cm.LowerString(m) + wasmimport_IdentityPrimitives((uint32)(a0), (uint32)(b0), (uint32)(c0), (uint64)(d0), (uint32)(e0), (uint32)(f0), (uint32)(g0), (uint64)(h0), (float32)(i0), (float64)(j0), (uint32)(k0), (uint32)(l0), (*uint8)(m0), (uint32)(m1), &result) + return +} + +//go:wasmimport west-test:sync/sync identity-primitives +//go:noescape +func wasmimport_IdentityPrimitives(a0 uint32, b0 uint32, c0 uint32, d0 uint64, e0 uint32, f0 uint32, g0 uint32, h0 uint64, i0 float32, j0 float64, k0 uint32, l0 uint32, m0 *uint8, m1 uint32, result *cm.Tuple13[uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, bool, rune, string]) diff --git a/tests/go/sync/sync.go b/tests/go/sync/sync.go new file mode 100644 index 0000000..7a9e95c --- /dev/null +++ b/tests/go/sync/sync.go @@ -0,0 +1,7 @@ +//go:generate go run github.com/ydnar/wasm-tools-go/cmd/wit-bindgen-go@v0.1.5 generate -w guest -o bindings ../../wit/sync + +package sync + +import ( + _ "github.com/rvolosatovs/west/tests/go/sync/bindings/west-test/sync/sync" +) diff --git a/go/internal/tests/sync/sync_test.go b/tests/go/sync/sync_test.go similarity index 98% rename from go/internal/tests/sync/sync_test.go rename to tests/go/sync/sync_test.go index e318b31..ab3716d 100644 --- a/go/internal/tests/sync/sync_test.go +++ b/tests/go/sync/sync_test.go @@ -1,5 +1,6 @@ +//go:generate go run ../../../cmd/west-bindgen-go //go:generate cargo build -p sync-test-component --target wasm32-wasip1 -//go:generate cp ../../../../target/wasm32-wasip1/debug/sync_test_component.wasm component.wasm +//go:generate cp ../../../target/wasm32-wasip1/debug/sync_test_component.wasm component.wasm package sync_test @@ -10,8 +11,8 @@ import ( "testing" "unsafe" - west "github.com/rvolosatovs/west/go" - "github.com/rvolosatovs/west/go/internal/tests/sync/bindings/west-test/sync/sync" + "github.com/rvolosatovs/west" + "github.com/rvolosatovs/west/tests/go/sync/bindings/west-test/sync/sync" "github.com/stretchr/testify/assert" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/internal/tests/wasi/bindings/.gitkeep b/tests/go/wasi/bindings/.gitkeep similarity index 100% rename from go/internal/tests/wasi/bindings/.gitkeep rename to tests/go/wasi/bindings/.gitkeep diff --git a/tests/go/wasi/bindings/wasi/cli/environment/empty.s b/tests/go/wasi/bindings/wasi/cli/environment/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/environment/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/environment/environment.wit.go b/tests/go/wasi/bindings/wasi/cli/environment/environment.wit.go new file mode 100644 index 0000000..a582bdf --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/environment/environment.wit.go @@ -0,0 +1,64 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package environment represents the imported interface "wasi:cli/environment@0.2.0". +package environment + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetEnvironment represents the imported function "get-environment". +// +// Get the POSIX-style environment variables. +// +// Each environment variable is provided as a pair of string variable names +// and string value. +// +// Morally, these are a value import, but until value imports are available +// in the component model, this import function should return the same +// values each time it is called. +// +// get-environment: func() -> list> +// +//go:nosplit +func GetEnvironment() (result cm.List[[2]string]) { + wasmimport_GetEnvironment(&result) + return +} + +//go:wasmimport wasi:cli/environment@0.2.0 get-environment +//go:noescape +func wasmimport_GetEnvironment(result *cm.List[[2]string]) + +// GetArguments represents the imported function "get-arguments". +// +// Get the POSIX-style arguments to the program. +// +// get-arguments: func() -> list +// +//go:nosplit +func GetArguments() (result cm.List[string]) { + wasmimport_GetArguments(&result) + return +} + +//go:wasmimport wasi:cli/environment@0.2.0 get-arguments +//go:noescape +func wasmimport_GetArguments(result *cm.List[string]) + +// InitialCWD represents the imported function "initial-cwd". +// +// Return a path that programs should use as their initial current working +// directory, interpreting `.` as shorthand for this. +// +// initial-cwd: func() -> option +// +//go:nosplit +func InitialCWD() (result cm.Option[string]) { + wasmimport_InitialCWD(&result) + return +} + +//go:wasmimport wasi:cli/environment@0.2.0 initial-cwd +//go:noescape +func wasmimport_InitialCWD(result *cm.Option[string]) diff --git a/tests/go/wasi/bindings/wasi/cli/exit/empty.s b/tests/go/wasi/bindings/wasi/cli/exit/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/exit/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/exit/exit.wit.go b/tests/go/wasi/bindings/wasi/cli/exit/exit.wit.go new file mode 100644 index 0000000..bf46d1b --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/exit/exit.wit.go @@ -0,0 +1,25 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package exit represents the imported interface "wasi:cli/exit@0.2.0". +package exit + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// Exit represents the imported function "exit". +// +// Exit the current instance and any linked instances. +// +// exit: func(status: result) +// +//go:nosplit +func Exit(status cm.BoolResult) { + status0 := cm.BoolToU32(status) + wasmimport_Exit((uint32)(status0)) + return +} + +//go:wasmimport wasi:cli/exit@0.2.0 exit +//go:noescape +func wasmimport_Exit(status0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/stderr/empty.s b/tests/go/wasi/bindings/wasi/cli/stderr/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stderr/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/stderr/stderr.wit.go b/tests/go/wasi/bindings/wasi/cli/stderr/stderr.wit.go new file mode 100644 index 0000000..cb64a5a --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stderr/stderr.wit.go @@ -0,0 +1,24 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package stderr represents the imported interface "wasi:cli/stderr@0.2.0". +package stderr + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetStderr represents the imported function "get-stderr". +// +// get-stderr: func() -> output-stream +// +//go:nosplit +func GetStderr() (result streams.OutputStream) { + result0 := wasmimport_GetStderr() + result = cm.Reinterpret[streams.OutputStream]((uint32)(result0)) + return +} + +//go:wasmimport wasi:cli/stderr@0.2.0 get-stderr +//go:noescape +func wasmimport_GetStderr() (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/stdin/empty.s b/tests/go/wasi/bindings/wasi/cli/stdin/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stdin/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/stdin/stdin.wit.go b/tests/go/wasi/bindings/wasi/cli/stdin/stdin.wit.go new file mode 100644 index 0000000..2823537 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stdin/stdin.wit.go @@ -0,0 +1,24 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package stdin represents the imported interface "wasi:cli/stdin@0.2.0". +package stdin + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetStdin represents the imported function "get-stdin". +// +// get-stdin: func() -> input-stream +// +//go:nosplit +func GetStdin() (result streams.InputStream) { + result0 := wasmimport_GetStdin() + result = cm.Reinterpret[streams.InputStream]((uint32)(result0)) + return +} + +//go:wasmimport wasi:cli/stdin@0.2.0 get-stdin +//go:noescape +func wasmimport_GetStdin() (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/stdout/empty.s b/tests/go/wasi/bindings/wasi/cli/stdout/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stdout/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/stdout/stdout.wit.go b/tests/go/wasi/bindings/wasi/cli/stdout/stdout.wit.go new file mode 100644 index 0000000..3d989c0 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/stdout/stdout.wit.go @@ -0,0 +1,24 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package stdout represents the imported interface "wasi:cli/stdout@0.2.0". +package stdout + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetStdout represents the imported function "get-stdout". +// +// get-stdout: func() -> output-stream +// +//go:nosplit +func GetStdout() (result streams.OutputStream) { + result0 := wasmimport_GetStdout() + result = cm.Reinterpret[streams.OutputStream]((uint32)(result0)) + return +} + +//go:wasmimport wasi:cli/stdout@0.2.0 get-stdout +//go:noescape +func wasmimport_GetStdout() (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-input/empty.s b/tests/go/wasi/bindings/wasi/cli/terminal-input/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-input/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-input/terminal-input.wit.go b/tests/go/wasi/bindings/wasi/cli/terminal-input/terminal-input.wit.go new file mode 100644 index 0000000..9dca7df --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-input/terminal-input.wit.go @@ -0,0 +1,36 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0". +// +// Terminal input. +// +// In the future, this may include functions for disabling echoing, +// disabling input buffering so that keyboard events are sent through +// immediately, querying supported features, and so on. +package terminalinput + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// TerminalInput represents the imported resource "wasi:cli/terminal-input@0.2.0#terminal-input". +// +// The input side of a terminal. +// +// resource terminal-input +type TerminalInput cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "terminal-input". +// +// Drops a resource handle. +// +//go:nosplit +func (self TerminalInput) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TerminalInputResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:cli/terminal-input@0.2.0 [resource-drop]terminal-input +//go:noescape +func wasmimport_TerminalInputResourceDrop(self0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-output/empty.s b/tests/go/wasi/bindings/wasi/cli/terminal-output/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-output/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-output/terminal-output.wit.go b/tests/go/wasi/bindings/wasi/cli/terminal-output/terminal-output.wit.go new file mode 100644 index 0000000..b6ff728 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-output/terminal-output.wit.go @@ -0,0 +1,36 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0". +// +// Terminal output. +// +// In the future, this may include functions for querying the terminal +// size, being notified of terminal size changes, querying supported +// features, and so on. +package terminaloutput + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// TerminalOutput represents the imported resource "wasi:cli/terminal-output@0.2.0#terminal-output". +// +// The output side of a terminal. +// +// resource terminal-output +type TerminalOutput cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "terminal-output". +// +// Drops a resource handle. +// +//go:nosplit +func (self TerminalOutput) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TerminalOutputResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:cli/terminal-output@0.2.0 [resource-drop]terminal-output +//go:noescape +func wasmimport_TerminalOutputResourceDrop(self0 uint32) diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stderr/empty.s b/tests/go/wasi/bindings/wasi/cli/terminal-stderr/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stderr/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go b/tests/go/wasi/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go new file mode 100644 index 0000000..fbcd3ac --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stderr/terminal-stderr.wit.go @@ -0,0 +1,29 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0". +// +// An interface providing an optional `terminal-output` for stderr as a +// link-time authority. +package terminalstderr + +import ( + terminaloutput "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/cli/terminal-output" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetTerminalStderr represents the imported function "get-terminal-stderr". +// +// If stderr is connected to a terminal, return a `terminal-output` handle +// allowing further interaction with it. +// +// get-terminal-stderr: func() -> option +// +//go:nosplit +func GetTerminalStderr() (result cm.Option[terminaloutput.TerminalOutput]) { + wasmimport_GetTerminalStderr(&result) + return +} + +//go:wasmimport wasi:cli/terminal-stderr@0.2.0 get-terminal-stderr +//go:noescape +func wasmimport_GetTerminalStderr(result *cm.Option[terminaloutput.TerminalOutput]) diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stdin/empty.s b/tests/go/wasi/bindings/wasi/cli/terminal-stdin/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stdin/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go b/tests/go/wasi/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go new file mode 100644 index 0000000..dd4fcbc --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stdin/terminal-stdin.wit.go @@ -0,0 +1,29 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0". +// +// An interface providing an optional `terminal-input` for stdin as a +// link-time authority. +package terminalstdin + +import ( + terminalinput "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/cli/terminal-input" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetTerminalStdin represents the imported function "get-terminal-stdin". +// +// If stdin is connected to a terminal, return a `terminal-input` handle +// allowing further interaction with it. +// +// get-terminal-stdin: func() -> option +// +//go:nosplit +func GetTerminalStdin() (result cm.Option[terminalinput.TerminalInput]) { + wasmimport_GetTerminalStdin(&result) + return +} + +//go:wasmimport wasi:cli/terminal-stdin@0.2.0 get-terminal-stdin +//go:noescape +func wasmimport_GetTerminalStdin(result *cm.Option[terminalinput.TerminalInput]) diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stdout/empty.s b/tests/go/wasi/bindings/wasi/cli/terminal-stdout/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stdout/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go b/tests/go/wasi/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go new file mode 100644 index 0000000..d8b46bc --- /dev/null +++ b/tests/go/wasi/bindings/wasi/cli/terminal-stdout/terminal-stdout.wit.go @@ -0,0 +1,29 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0". +// +// An interface providing an optional `terminal-output` for stdout as a +// link-time authority. +package terminalstdout + +import ( + terminaloutput "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/cli/terminal-output" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetTerminalStdout represents the imported function "get-terminal-stdout". +// +// If stdout is connected to a terminal, return a `terminal-output` handle +// allowing further interaction with it. +// +// get-terminal-stdout: func() -> option +// +//go:nosplit +func GetTerminalStdout() (result cm.Option[terminaloutput.TerminalOutput]) { + wasmimport_GetTerminalStdout(&result) + return +} + +//go:wasmimport wasi:cli/terminal-stdout@0.2.0 get-terminal-stdout +//go:noescape +func wasmimport_GetTerminalStdout(result *cm.Option[terminaloutput.TerminalOutput]) diff --git a/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/empty.s b/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go b/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go new file mode 100644 index 0000000..15e7ec8 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/clocks/monotonic-clock/monotonic-clock.wit.go @@ -0,0 +1,113 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package monotonicclock represents the imported interface "wasi:clocks/monotonic-clock@0.2.0". +// +// WASI Monotonic Clock is a clock API intended to let users measure elapsed +// time. +// +// It is intended to be portable at least between Unix-family platforms and +// Windows. +// +// A monotonic clock is a clock which has an unspecified initial value, and +// successive reads of the clock will produce non-decreasing values. +// +// It is intended for measuring elapsed time. +package monotonicclock + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/ydnar/wasm-tools-go/cm" +) + +// Instant represents the u64 "wasi:clocks/monotonic-clock@0.2.0#instant". +// +// An instant in time, in nanoseconds. An instant is relative to an +// unspecified initial value, and can only be compared to instances from +// the same monotonic-clock. +// +// type instant = u64 +type Instant uint64 + +// Duration represents the u64 "wasi:clocks/monotonic-clock@0.2.0#duration". +// +// A duration of time, in nanoseconds. +// +// type duration = u64 +type Duration uint64 + +// Now represents the imported function "now". +// +// Read the current value of the clock. +// +// The clock is monotonic, therefore calling this function repeatedly will +// produce a sequence of non-decreasing values. +// +// now: func() -> instant +// +//go:nosplit +func Now() (result Instant) { + result0 := wasmimport_Now() + result = (Instant)((uint64)(result0)) + return +} + +//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 now +//go:noescape +func wasmimport_Now() (result0 uint64) + +// Resolution represents the imported function "resolution". +// +// Query the resolution of the clock. Returns the duration of time +// corresponding to a clock tick. +// +// resolution: func() -> duration +// +//go:nosplit +func Resolution() (result Duration) { + result0 := wasmimport_Resolution() + result = (Duration)((uint64)(result0)) + return +} + +//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 resolution +//go:noescape +func wasmimport_Resolution() (result0 uint64) + +// SubscribeInstant represents the imported function "subscribe-instant". +// +// Create a `pollable` which will resolve once the specified instant +// occured. +// +// subscribe-instant: func(when: instant) -> pollable +// +//go:nosplit +func SubscribeInstant(when Instant) (result poll.Pollable) { + when0 := (uint64)(when) + result0 := wasmimport_SubscribeInstant((uint64)(when0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 subscribe-instant +//go:noescape +func wasmimport_SubscribeInstant(when0 uint64) (result0 uint32) + +// SubscribeDuration represents the imported function "subscribe-duration". +// +// Create a `pollable` which will resolve once the given duration has +// elapsed, starting at the time at which this function was called. +// occured. +// +// subscribe-duration: func(when: duration) -> pollable +// +//go:nosplit +func SubscribeDuration(when Duration) (result poll.Pollable) { + when0 := (uint64)(when) + result0 := wasmimport_SubscribeDuration((uint64)(when0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 subscribe-duration +//go:noescape +func wasmimport_SubscribeDuration(when0 uint64) (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/clocks/wall-clock/empty.s b/tests/go/wasi/bindings/wasi/clocks/wall-clock/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/clocks/wall-clock/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/clocks/wall-clock/wall-clock.wit.go b/tests/go/wasi/bindings/wasi/clocks/wall-clock/wall-clock.wit.go new file mode 100644 index 0000000..a59a313 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/clocks/wall-clock/wall-clock.wit.go @@ -0,0 +1,78 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package wallclock represents the imported interface "wasi:clocks/wall-clock@0.2.0". +// +// WASI Wall Clock is a clock API intended to let users query the current +// time. The name "wall" makes an analogy to a "clock on the wall", which +// is not necessarily monotonic as it may be reset. +// +// It is intended to be portable at least between Unix-family platforms and +// Windows. +// +// A wall clock is a clock which measures the date and time according to +// some external reference. +// +// External references may be reset, so this clock is not necessarily +// monotonic, making it unsuitable for measuring elapsed time. +// +// It is intended for reporting the current date and time for humans. +package wallclock + +// DateTime represents the record "wasi:clocks/wall-clock@0.2.0#datetime". +// +// A time and date in seconds plus nanoseconds. +// +// record datetime { +// seconds: u64, +// nanoseconds: u32, +// } +type DateTime struct { + Seconds uint64 + Nanoseconds uint32 +} + +// Now represents the imported function "now". +// +// Read the current value of the clock. +// +// This clock is not monotonic, therefore calling this function repeatedly +// will not necessarily produce a sequence of non-decreasing values. +// +// The returned timestamps represent the number of seconds since +// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], +// also known as [Unix Time]. +// +// The nanoseconds field of the output is always less than 1000000000. +// +// now: func() -> datetime +// +// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 +// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time +// +//go:nosplit +func Now() (result DateTime) { + wasmimport_Now(&result) + return +} + +//go:wasmimport wasi:clocks/wall-clock@0.2.0 now +//go:noescape +func wasmimport_Now(result *DateTime) + +// Resolution represents the imported function "resolution". +// +// Query the resolution of the clock. +// +// The nanoseconds field of the output is always less than 1000000000. +// +// resolution: func() -> datetime +// +//go:nosplit +func Resolution() (result DateTime) { + wasmimport_Resolution(&result) + return +} + +//go:wasmimport wasi:clocks/wall-clock@0.2.0 resolution +//go:noescape +func wasmimport_Resolution(result *DateTime) diff --git a/tests/go/wasi/bindings/wasi/filesystem/preopens/empty.s b/tests/go/wasi/bindings/wasi/filesystem/preopens/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/filesystem/preopens/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/filesystem/preopens/preopens.wit.go b/tests/go/wasi/bindings/wasi/filesystem/preopens/preopens.wit.go new file mode 100644 index 0000000..1a9149d --- /dev/null +++ b/tests/go/wasi/bindings/wasi/filesystem/preopens/preopens.wit.go @@ -0,0 +1,25 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package preopens represents the imported interface "wasi:filesystem/preopens@0.2.0". +package preopens + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/filesystem/types" + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetDirectories represents the imported function "get-directories". +// +// Return the set of preopened directories, and their path. +// +// get-directories: func() -> list> +// +//go:nosplit +func GetDirectories() (result cm.List[cm.Tuple[types.Descriptor, string]]) { + wasmimport_GetDirectories(&result) + return +} + +//go:wasmimport wasi:filesystem/preopens@0.2.0 get-directories +//go:noescape +func wasmimport_GetDirectories(result *cm.List[cm.Tuple[types.Descriptor, string]]) diff --git a/tests/go/wasi/bindings/wasi/filesystem/types/abi.go b/tests/go/wasi/bindings/wasi/filesystem/types/abi.go new file mode 100644 index 0000000..3edb7a5 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/filesystem/types/abi.go @@ -0,0 +1,51 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package types + +import ( + wallclock "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/clocks/wall-clock" + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// DateTimeShape is used for storage in variant or result types. +type DateTimeShape struct { + shape [unsafe.Sizeof(wallclock.DateTime{})]byte +} + +// MetadataHashValueShape is used for storage in variant or result types. +type MetadataHashValueShape struct { + shape [unsafe.Sizeof(MetadataHashValue{})]byte +} + +// TupleListU8BoolShape is used for storage in variant or result types. +type TupleListU8BoolShape struct { + shape [unsafe.Sizeof(cm.Tuple[cm.List[uint8], bool]{})]byte +} + +func lower_DateTime(v wallclock.DateTime) (f0 uint64, f1 uint32) { + f0 = (uint64)(v.Seconds) + f1 = (uint32)(v.Nanoseconds) + return +} + +func lower_NewTimestamp(v NewTimestamp) (f0 uint32, f1 uint64, f2 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 2: // timestamp + v1, v2 := lower_DateTime(*v.Timestamp()) + f1 = (uint64)(v1) + f2 = (uint32)(v2) + } + return +} + +// DescriptorStatShape is used for storage in variant or result types. +type DescriptorStatShape struct { + shape [unsafe.Sizeof(DescriptorStat{})]byte +} + +// OptionDirectoryEntryShape is used for storage in variant or result types. +type OptionDirectoryEntryShape struct { + shape [unsafe.Sizeof(cm.Option[DirectoryEntry]{})]byte +} diff --git a/tests/go/wasi/bindings/wasi/filesystem/types/empty.s b/tests/go/wasi/bindings/wasi/filesystem/types/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/filesystem/types/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/filesystem/types/types.wit.go b/tests/go/wasi/bindings/wasi/filesystem/types/types.wit.go new file mode 100644 index 0000000..5e9b357 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/filesystem/types/types.wit.go @@ -0,0 +1,1357 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package types represents the imported interface "wasi:filesystem/types@0.2.0". +// +// WASI filesystem is a filesystem API primarily intended to let users run WASI +// programs that access their files on their existing filesystems, without +// significant overhead. +// +// It is intended to be roughly portable between Unix-family platforms and +// Windows, though it does not hide many of the major differences. +// +// Paths are passed as interface-type `string`s, meaning they must consist of +// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain +// paths which are not accessible by this API. +// +// The directory separator in WASI is always the forward-slash (`/`). +// +// All paths in WASI are relative paths, and are interpreted relative to a +// `descriptor` referring to a base directory. If a `path` argument to any WASI +// function starts with `/`, or if any step of resolving a `path`, including +// `..` and symbolic link steps, reaches a directory outside of the base +// directory, or reaches a symlink to an absolute or rooted path in the +// underlying filesystem, the function fails with `error-code::not-permitted`. +// +// For more information about WASI path resolution and sandboxing, see +// [WASI filesystem path resolution]. +// +// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md +package types + +import ( + wallclock "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/clocks/wall-clock" + ioerror "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/error" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/ydnar/wasm-tools-go/cm" +) + +// FileSize represents the u64 "wasi:filesystem/types@0.2.0#filesize". +// +// File size or length of a region within a file. +// +// type filesize = u64 +type FileSize uint64 + +// DescriptorType represents the enum "wasi:filesystem/types@0.2.0#descriptor-type". +// +// The type of a filesystem object referenced by a descriptor. +// +// Note: This was called `filetype` in earlier versions of WASI. +// +// enum descriptor-type { +// unknown, +// block-device, +// character-device, +// directory, +// fifo, +// symbolic-link, +// regular-file, +// socket +// } +type DescriptorType uint8 + +const ( + // The type of the descriptor or file is unknown or is different from + // any of the other types specified. + DescriptorTypeUnknown DescriptorType = iota + + // The descriptor refers to a block device inode. + DescriptorTypeBlockDevice + + // The descriptor refers to a character device inode. + DescriptorTypeCharacterDevice + + // The descriptor refers to a directory inode. + DescriptorTypeDirectory + + // The descriptor refers to a named pipe. + DescriptorTypeFIFO + + // The file refers to a symbolic link inode. + DescriptorTypeSymbolicLink + + // The descriptor refers to a regular file inode. + DescriptorTypeRegularFile + + // The descriptor refers to a socket. + DescriptorTypeSocket +) + +var stringsDescriptorType = [8]string{ + "unknown", + "block-device", + "character-device", + "directory", + "fifo", + "symbolic-link", + "regular-file", + "socket", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e DescriptorType) String() string { + return stringsDescriptorType[e] +} + +// DescriptorFlags represents the flags "wasi:filesystem/types@0.2.0#descriptor-flags". +// +// Descriptor flags. +// +// Note: This was called `fdflags` in earlier versions of WASI. +// +// flags descriptor-flags { +// read, +// write, +// file-integrity-sync, +// data-integrity-sync, +// requested-write-sync, +// mutate-directory, +// } +type DescriptorFlags uint8 + +const ( + // Read mode: Data can be read. + DescriptorFlagsRead DescriptorFlags = 1 << iota + + // Write mode: Data can be written to. + DescriptorFlagsWrite + + // Request that writes be performed according to synchronized I/O file + // integrity completion. The data stored in the file and the file's + // metadata are synchronized. This is similar to `O_SYNC` in POSIX. + // + // The precise semantics of this operation have not yet been defined for + // WASI. At this time, it should be interpreted as a request, and not a + // requirement. + DescriptorFlagsFileIntegritySync + + // Request that writes be performed according to synchronized I/O data + // integrity completion. Only the data stored in the file is + // synchronized. This is similar to `O_DSYNC` in POSIX. + // + // The precise semantics of this operation have not yet been defined for + // WASI. At this time, it should be interpreted as a request, and not a + // requirement. + DescriptorFlagsDataIntegritySync + + // Requests that reads be performed at the same level of integrety + // requested for writes. This is similar to `O_RSYNC` in POSIX. + // + // The precise semantics of this operation have not yet been defined for + // WASI. At this time, it should be interpreted as a request, and not a + // requirement. + DescriptorFlagsRequestedWriteSync + + // Mutating directories mode: Directory contents may be mutated. + // + // When this flag is unset on a descriptor, operations using the + // descriptor which would create, rename, delete, modify the data or + // metadata of filesystem objects, or obtain another handle which + // would permit any of those, shall fail with `error-code::read-only` if + // they would otherwise succeed. + // + // This may only be set on directories. + DescriptorFlagsMutateDirectory +) + +// PathFlags represents the flags "wasi:filesystem/types@0.2.0#path-flags". +// +// Flags determining the method of how paths are resolved. +// +// flags path-flags { +// symlink-follow, +// } +type PathFlags uint8 + +const ( + // As long as the resolved path corresponds to a symbolic link, it is + // expanded. + PathFlagsSymlinkFollow PathFlags = 1 << iota +) + +// OpenFlags represents the flags "wasi:filesystem/types@0.2.0#open-flags". +// +// Open flags used by `open-at`. +// +// flags open-flags { +// create, +// directory, +// exclusive, +// truncate, +// } +type OpenFlags uint8 + +const ( + // Create file if it does not exist, similar to `O_CREAT` in POSIX. + OpenFlagsCreate OpenFlags = 1 << iota + + // Fail if not a directory, similar to `O_DIRECTORY` in POSIX. + OpenFlagsDirectory + + // Fail if file already exists, similar to `O_EXCL` in POSIX. + OpenFlagsExclusive + + // Truncate file to size 0, similar to `O_TRUNC` in POSIX. + OpenFlagsTruncate +) + +// LinkCount represents the u64 "wasi:filesystem/types@0.2.0#link-count". +// +// Number of hard links to an inode. +// +// type link-count = u64 +type LinkCount uint64 + +// DescriptorStat represents the record "wasi:filesystem/types@0.2.0#descriptor-stat". +// +// File attributes. +// +// Note: This was called `filestat` in earlier versions of WASI. +// +// record descriptor-stat { +// %type: descriptor-type, +// link-count: link-count, +// size: filesize, +// data-access-timestamp: option, +// data-modification-timestamp: option, +// status-change-timestamp: option, +// } +type DescriptorStat struct { + // File type. + Type DescriptorType + + // Number of hard links to the file. + LinkCount LinkCount + + // For regular files, the file size in bytes. For symbolic links, the + // length in bytes of the pathname contained in the symbolic link. + Size FileSize + + // Last data access timestamp. + // + // If the `option` is none, the platform doesn't maintain an access + // timestamp for this file. + DataAccessTimestamp cm.Option[wallclock.DateTime] + + // Last data modification timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // modification timestamp for this file. + DataModificationTimestamp cm.Option[wallclock.DateTime] + + // Last file status-change timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // status-change timestamp for this file. + StatusChangeTimestamp cm.Option[wallclock.DateTime] +} + +// NewTimestamp represents the variant "wasi:filesystem/types@0.2.0#new-timestamp". +// +// When setting a timestamp, this gives the value to set it to. +// +// variant new-timestamp { +// no-change, +// now, +// timestamp(datetime), +// } +type NewTimestamp cm.Variant[uint8, wallclock.DateTime, wallclock.DateTime] + +// NewTimestampNoChange returns a [NewTimestamp] of case "no-change". +// +// Leave the timestamp set to its previous value. +func NewTimestampNoChange() NewTimestamp { + var data struct{} + return cm.New[NewTimestamp](0, data) +} + +// NoChange returns true if [NewTimestamp] represents the variant case "no-change". +func (self *NewTimestamp) NoChange() bool { + return self.Tag() == 0 +} + +// NewTimestampNow returns a [NewTimestamp] of case "now". +// +// Set the timestamp to the current time of the system clock associated +// with the filesystem. +func NewTimestampNow() NewTimestamp { + var data struct{} + return cm.New[NewTimestamp](1, data) +} + +// Now returns true if [NewTimestamp] represents the variant case "now". +func (self *NewTimestamp) Now() bool { + return self.Tag() == 1 +} + +// NewTimestampTimestamp returns a [NewTimestamp] of case "timestamp". +// +// Set the timestamp to the given value. +func NewTimestampTimestamp(data wallclock.DateTime) NewTimestamp { + return cm.New[NewTimestamp](2, data) +} + +// Timestamp returns a non-nil *[wallclock.DateTime] if [NewTimestamp] represents the variant case "timestamp". +func (self *NewTimestamp) Timestamp() *wallclock.DateTime { + return cm.Case[wallclock.DateTime](self, 2) +} + +// DirectoryEntry represents the record "wasi:filesystem/types@0.2.0#directory-entry". +// +// A directory entry. +// +// record directory-entry { +// %type: descriptor-type, +// name: string, +// } +type DirectoryEntry struct { + // The type of the file referred to by this directory entry. + Type DescriptorType + + // The name of the object. + Name string +} + +// ErrorCode represents the enum "wasi:filesystem/types@0.2.0#error-code". +// +// Error codes returned by functions, similar to `errno` in POSIX. +// Not all of these error codes are returned by the functions provided by this +// API; some are used in higher-level library layers, and others are provided +// merely for alignment with POSIX. +// +// enum error-code { +// access, +// would-block, +// already, +// bad-descriptor, +// busy, +// deadlock, +// quota, +// exist, +// file-too-large, +// illegal-byte-sequence, +// in-progress, +// interrupted, +// invalid, +// io, +// is-directory, +// loop, +// too-many-links, +// message-size, +// name-too-long, +// no-device, +// no-entry, +// no-lock, +// insufficient-memory, +// insufficient-space, +// not-directory, +// not-empty, +// not-recoverable, +// unsupported, +// no-tty, +// no-such-device, +// overflow, +// not-permitted, +// pipe, +// read-only, +// invalid-seek, +// text-file-busy, +// cross-device +// } +type ErrorCode uint8 + +const ( + // Permission denied, similar to `EACCES` in POSIX. + ErrorCodeAccess ErrorCode = iota + + // Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` + // in POSIX. + ErrorCodeWouldBlock + + // Connection already in progress, similar to `EALREADY` in POSIX. + ErrorCodeAlready + + // Bad descriptor, similar to `EBADF` in POSIX. + ErrorCodeBadDescriptor + + // Device or resource busy, similar to `EBUSY` in POSIX. + ErrorCodeBusy + + // Resource deadlock would occur, similar to `EDEADLK` in POSIX. + ErrorCodeDeadlock + + // Storage quota exceeded, similar to `EDQUOT` in POSIX. + ErrorCodeQuota + + // File exists, similar to `EEXIST` in POSIX. + ErrorCodeExist + + // File too large, similar to `EFBIG` in POSIX. + ErrorCodeFileTooLarge + + // Illegal byte sequence, similar to `EILSEQ` in POSIX. + ErrorCodeIllegalByteSequence + + // Operation in progress, similar to `EINPROGRESS` in POSIX. + ErrorCodeInProgress + + // Interrupted function, similar to `EINTR` in POSIX. + ErrorCodeInterrupted + + // Invalid argument, similar to `EINVAL` in POSIX. + ErrorCodeInvalid + + // I/O error, similar to `EIO` in POSIX. + ErrorCodeIO + + // Is a directory, similar to `EISDIR` in POSIX. + ErrorCodeIsDirectory + + // Too many levels of symbolic links, similar to `ELOOP` in POSIX. + ErrorCodeLoop + + // Too many links, similar to `EMLINK` in POSIX. + ErrorCodeTooManyLinks + + // Message too large, similar to `EMSGSIZE` in POSIX. + ErrorCodeMessageSize + + // Filename too long, similar to `ENAMETOOLONG` in POSIX. + ErrorCodeNameTooLong + + // No such device, similar to `ENODEV` in POSIX. + ErrorCodeNoDevice + + // No such file or directory, similar to `ENOENT` in POSIX. + ErrorCodeNoEntry + + // No locks available, similar to `ENOLCK` in POSIX. + ErrorCodeNoLock + + // Not enough space, similar to `ENOMEM` in POSIX. + ErrorCodeInsufficientMemory + + // No space left on device, similar to `ENOSPC` in POSIX. + ErrorCodeInsufficientSpace + + // Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. + ErrorCodeNotDirectory + + // Directory not empty, similar to `ENOTEMPTY` in POSIX. + ErrorCodeNotEmpty + + // State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. + ErrorCodeNotRecoverable + + // Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. + ErrorCodeUnsupported + + // Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. + ErrorCodeNoTTY + + // No such device or address, similar to `ENXIO` in POSIX. + ErrorCodeNoSuchDevice + + // Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. + ErrorCodeOverflow + + // Operation not permitted, similar to `EPERM` in POSIX. + ErrorCodeNotPermitted + + // Broken pipe, similar to `EPIPE` in POSIX. + ErrorCodePipe + + // Read-only file system, similar to `EROFS` in POSIX. + ErrorCodeReadOnly + + // Invalid seek, similar to `ESPIPE` in POSIX. + ErrorCodeInvalidSeek + + // Text file busy, similar to `ETXTBSY` in POSIX. + ErrorCodeTextFileBusy + + // Cross-device link, similar to `EXDEV` in POSIX. + ErrorCodeCrossDevice +) + +var stringsErrorCode = [37]string{ + "access", + "would-block", + "already", + "bad-descriptor", + "busy", + "deadlock", + "quota", + "exist", + "file-too-large", + "illegal-byte-sequence", + "in-progress", + "interrupted", + "invalid", + "io", + "is-directory", + "loop", + "too-many-links", + "message-size", + "name-too-long", + "no-device", + "no-entry", + "no-lock", + "insufficient-memory", + "insufficient-space", + "not-directory", + "not-empty", + "not-recoverable", + "unsupported", + "no-tty", + "no-such-device", + "overflow", + "not-permitted", + "pipe", + "read-only", + "invalid-seek", + "text-file-busy", + "cross-device", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e ErrorCode) String() string { + return stringsErrorCode[e] +} + +// Advice represents the enum "wasi:filesystem/types@0.2.0#advice". +// +// File or memory access pattern advisory information. +// +// enum advice { +// normal, +// sequential, +// random, +// will-need, +// dont-need, +// no-reuse +// } +type Advice uint8 + +const ( + // The application has no advice to give on its behavior with respect + // to the specified data. + AdviceNormal Advice = iota + + // The application expects to access the specified data sequentially + // from lower offsets to higher offsets. + AdviceSequential + + // The application expects to access the specified data in a random + // order. + AdviceRandom + + // The application expects to access the specified data in the near + // future. + AdviceWillNeed + + // The application expects that it will not access the specified data + // in the near future. + AdviceDontNeed + + // The application expects to access the specified data once and then + // not reuse it thereafter. + AdviceNoReuse +) + +var stringsAdvice = [6]string{ + "normal", + "sequential", + "random", + "will-need", + "dont-need", + "no-reuse", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e Advice) String() string { + return stringsAdvice[e] +} + +// MetadataHashValue represents the record "wasi:filesystem/types@0.2.0#metadata-hash-value". +// +// A 128-bit hash value, split into parts because wasm doesn't have a +// 128-bit integer type. +// +// record metadata-hash-value { +// lower: u64, +// upper: u64, +// } +type MetadataHashValue struct { + // 64 bits of a 128-bit hash value. + Lower uint64 + + // Another 64 bits of a 128-bit hash value. + Upper uint64 +} + +// Descriptor represents the imported resource "wasi:filesystem/types@0.2.0#descriptor". +// +// A descriptor is a reference to a filesystem object, which may be a file, +// directory, named pipe, special file, or other object on which filesystem +// calls may be made. +// +// resource descriptor +type Descriptor cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "descriptor". +// +// Drops a resource handle. +// +//go:nosplit +func (self Descriptor) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [resource-drop]descriptor +//go:noescape +func wasmimport_DescriptorResourceDrop(self0 uint32) + +// Advise represents the imported method "advise". +// +// Provide file advisory information on a descriptor. +// +// This is similar to `posix_fadvise` in POSIX. +// +// advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) Advise(offset FileSize, length FileSize, advice Advice) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + offset0 := (uint64)(offset) + length0 := (uint64)(length) + advice0 := (uint32)(advice) + wasmimport_DescriptorAdvise((uint32)(self0), (uint64)(offset0), (uint64)(length0), (uint32)(advice0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.advise +//go:noescape +func wasmimport_DescriptorAdvise(self0 uint32, offset0 uint64, length0 uint64, advice0 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// AppendViaStream represents the imported method "append-via-stream". +// +// Return a stream for appending to a file, if available. +// +// May fail with an error-code describing why the file cannot be appended. +// +// Note: This allows using `write-stream`, which is similar to `write` with +// `O_APPEND` in in POSIX. +// +// append-via-stream: func() -> result +// +//go:nosplit +func (self Descriptor) AppendViaStream() (result cm.Result[streams.OutputStream, streams.OutputStream, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorAppendViaStream((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.append-via-stream +//go:noescape +func wasmimport_DescriptorAppendViaStream(self0 uint32, result *cm.Result[streams.OutputStream, streams.OutputStream, ErrorCode]) + +// CreateDirectoryAt represents the imported method "create-directory-at". +// +// Create a directory. +// +// Note: This is similar to `mkdirat` in POSIX. +// +// create-directory-at: func(path: string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) CreateDirectoryAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorCreateDirectoryAt((uint32)(self0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.create-directory-at +//go:noescape +func wasmimport_DescriptorCreateDirectoryAt(self0 uint32, path0 *uint8, path1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// GetFlags represents the imported method "get-flags". +// +// Get flags associated with a descriptor. +// +// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. +// +// Note: This returns the value that was the `fs_flags` value returned +// from `fdstat_get` in earlier versions of WASI. +// +// get-flags: func() -> result +// +//go:nosplit +func (self Descriptor) GetFlags() (result cm.Result[DescriptorFlags, DescriptorFlags, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorGetFlags((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.get-flags +//go:noescape +func wasmimport_DescriptorGetFlags(self0 uint32, result *cm.Result[DescriptorFlags, DescriptorFlags, ErrorCode]) + +// GetType represents the imported method "get-type". +// +// Get the dynamic type of a descriptor. +// +// Note: This returns the same value as the `type` field of the `fd-stat` +// returned by `stat`, `stat-at` and similar. +// +// Note: This returns similar flags to the `st_mode & S_IFMT` value provided +// by `fstat` in POSIX. +// +// Note: This returns the value that was the `fs_filetype` value returned +// from `fdstat_get` in earlier versions of WASI. +// +// get-type: func() -> result +// +//go:nosplit +func (self Descriptor) GetType() (result cm.Result[DescriptorType, DescriptorType, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorGetType((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.get-type +//go:noescape +func wasmimport_DescriptorGetType(self0 uint32, result *cm.Result[DescriptorType, DescriptorType, ErrorCode]) + +// IsSameObject represents the imported method "is-same-object". +// +// Test whether two descriptors refer to the same filesystem object. +// +// In POSIX, this corresponds to testing whether the two descriptors have the +// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. +// wasi-filesystem does not expose device and inode numbers, so this function +// may be used instead. +// +// is-same-object: func(other: borrow) -> bool +// +//go:nosplit +func (self Descriptor) IsSameObject(other Descriptor) (result bool) { + self0 := cm.Reinterpret[uint32](self) + other0 := cm.Reinterpret[uint32](other) + result0 := wasmimport_DescriptorIsSameObject((uint32)(self0), (uint32)(other0)) + result = cm.U32ToBool((uint32)(result0)) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.is-same-object +//go:noescape +func wasmimport_DescriptorIsSameObject(self0 uint32, other0 uint32) (result0 uint32) + +// LinkAt represents the imported method "link-at". +// +// Create a hard link. +// +// Note: This is similar to `linkat` in POSIX. +// +// link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, +// new-path: string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) LinkAt(oldPathFlags PathFlags, oldPath string, newDescriptor Descriptor, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + oldPathFlags0 := (uint32)(oldPathFlags) + oldPath0, oldPath1 := cm.LowerString(oldPath) + newDescriptor0 := cm.Reinterpret[uint32](newDescriptor) + newPath0, newPath1 := cm.LowerString(newPath) + wasmimport_DescriptorLinkAt((uint32)(self0), (uint32)(oldPathFlags0), (*uint8)(oldPath0), (uint32)(oldPath1), (uint32)(newDescriptor0), (*uint8)(newPath0), (uint32)(newPath1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.link-at +//go:noescape +func wasmimport_DescriptorLinkAt(self0 uint32, oldPathFlags0 uint32, oldPath0 *uint8, oldPath1 uint32, newDescriptor0 uint32, newPath0 *uint8, newPath1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// MetadataHash represents the imported method "metadata-hash". +// +// Return a hash of the metadata associated with a filesystem object referred +// to by a descriptor. +// +// This returns a hash of the last-modification timestamp and file size, and +// may also include the inode number, device number, birth timestamp, and +// other metadata fields that may change when the file is modified or +// replaced. It may also include a secret value chosen by the +// implementation and not otherwise exposed. +// +// Implementations are encourated to provide the following properties: +// +// - If the file is not modified or replaced, the computed hash value should +// usually not change. +// - If the object is modified or replaced, the computed hash value should +// usually change. +// - The inputs to the hash should not be easily computable from the +// computed hash. +// +// However, none of these is required. +// +// metadata-hash: func() -> result +// +//go:nosplit +func (self Descriptor) MetadataHash() (result cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorMetadataHash((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.metadata-hash +//go:noescape +func wasmimport_DescriptorMetadataHash(self0 uint32, result *cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode]) + +// MetadataHashAt represents the imported method "metadata-hash-at". +// +// Return a hash of the metadata associated with a filesystem object referred +// to by a directory descriptor and a relative path. +// +// This performs the same hash computation as `metadata-hash`. +// +// metadata-hash-at: func(path-flags: path-flags, path: string) -> result +// +//go:nosplit +func (self Descriptor) MetadataHashAt(pathFlags PathFlags, path string) (result cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + pathFlags0 := (uint32)(pathFlags) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorMetadataHashAt((uint32)(self0), (uint32)(pathFlags0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.metadata-hash-at +//go:noescape +func wasmimport_DescriptorMetadataHashAt(self0 uint32, pathFlags0 uint32, path0 *uint8, path1 uint32, result *cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode]) + +// OpenAt represents the imported method "open-at". +// +// Open a file or directory. +// +// The returned descriptor is not guaranteed to be the lowest-numbered +// descriptor not currently open/ it is randomized to prevent applications +// from depending on making assumptions about indexes, since this is +// error-prone in multi-threaded contexts. The returned descriptor is +// guaranteed to be less than 2**31. +// +// If `flags` contains `descriptor-flags::mutate-directory`, and the base +// descriptor doesn't have `descriptor-flags::mutate-directory` set, +// `open-at` fails with `error-code::read-only`. +// +// If `flags` contains `write` or `mutate-directory`, or `open-flags` +// contains `truncate` or `create`, and the base descriptor doesn't have +// `descriptor-flags::mutate-directory` set, `open-at` fails with +// `error-code::read-only`. +// +// Note: This is similar to `openat` in POSIX. +// +// open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: +// descriptor-flags) -> result +// +//go:nosplit +func (self Descriptor) OpenAt(pathFlags PathFlags, path string, openFlags OpenFlags, flags DescriptorFlags) (result cm.Result[Descriptor, Descriptor, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + pathFlags0 := (uint32)(pathFlags) + path0, path1 := cm.LowerString(path) + openFlags0 := (uint32)(openFlags) + flags0 := (uint32)(flags) + wasmimport_DescriptorOpenAt((uint32)(self0), (uint32)(pathFlags0), (*uint8)(path0), (uint32)(path1), (uint32)(openFlags0), (uint32)(flags0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.open-at +//go:noescape +func wasmimport_DescriptorOpenAt(self0 uint32, pathFlags0 uint32, path0 *uint8, path1 uint32, openFlags0 uint32, flags0 uint32, result *cm.Result[Descriptor, Descriptor, ErrorCode]) + +// Read represents the imported method "read". +// +// Read from a descriptor, without using and updating the descriptor's offset. +// +// This function returns a list of bytes containing the data that was +// read, along with a bool which, when true, indicates that the end of the +// file was reached. The returned list will contain up to `length` bytes; it +// may return fewer than requested, if the end of the file is reached or +// if the I/O operation is interrupted. +// +// In the future, this may change to return a `stream`. +// +// Note: This is similar to `pread` in POSIX. +// +// read: func(length: filesize, offset: filesize) -> result, bool>, +// error-code> +// +//go:nosplit +func (self Descriptor) Read(length FileSize, offset FileSize) (result cm.Result[TupleListU8BoolShape, cm.Tuple[cm.List[uint8], bool], ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + length0 := (uint64)(length) + offset0 := (uint64)(offset) + wasmimport_DescriptorRead((uint32)(self0), (uint64)(length0), (uint64)(offset0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.read +//go:noescape +func wasmimport_DescriptorRead(self0 uint32, length0 uint64, offset0 uint64, result *cm.Result[TupleListU8BoolShape, cm.Tuple[cm.List[uint8], bool], ErrorCode]) + +// ReadDirectory represents the imported method "read-directory". +// +// Read directory entries from a directory. +// +// On filesystems where directories contain entries referring to themselves +// and their parents, often named `.` and `..` respectively, these entries +// are omitted. +// +// This always returns a new stream which starts at the beginning of the +// directory. Multiple streams may be active on the same directory, and they +// do not interfere with each other. +// +// read-directory: func() -> result +// +//go:nosplit +func (self Descriptor) ReadDirectory() (result cm.Result[DirectoryEntryStream, DirectoryEntryStream, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorReadDirectory((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.read-directory +//go:noescape +func wasmimport_DescriptorReadDirectory(self0 uint32, result *cm.Result[DirectoryEntryStream, DirectoryEntryStream, ErrorCode]) + +// ReadViaStream represents the imported method "read-via-stream". +// +// Return a stream for reading from a file, if available. +// +// May fail with an error-code describing why the file cannot be read. +// +// Multiple read, write, and append streams may be active on the same open +// file and they do not interfere with each other. +// +// Note: This allows using `read-stream`, which is similar to `read` in POSIX. +// +// read-via-stream: func(offset: filesize) -> result +// +//go:nosplit +func (self Descriptor) ReadViaStream(offset FileSize) (result cm.Result[streams.InputStream, streams.InputStream, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + offset0 := (uint64)(offset) + wasmimport_DescriptorReadViaStream((uint32)(self0), (uint64)(offset0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.read-via-stream +//go:noescape +func wasmimport_DescriptorReadViaStream(self0 uint32, offset0 uint64, result *cm.Result[streams.InputStream, streams.InputStream, ErrorCode]) + +// ReadLinkAt represents the imported method "readlink-at". +// +// Read the contents of a symbolic link. +// +// If the contents contain an absolute or rooted path in the underlying +// filesystem, this function fails with `error-code::not-permitted`. +// +// Note: This is similar to `readlinkat` in POSIX. +// +// readlink-at: func(path: string) -> result +// +//go:nosplit +func (self Descriptor) ReadLinkAt(path string) (result cm.Result[string, string, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorReadLinkAt((uint32)(self0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.readlink-at +//go:noescape +func wasmimport_DescriptorReadLinkAt(self0 uint32, path0 *uint8, path1 uint32, result *cm.Result[string, string, ErrorCode]) + +// RemoveDirectoryAt represents the imported method "remove-directory-at". +// +// Remove a directory. +// +// Return `error-code::not-empty` if the directory is not empty. +// +// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. +// +// remove-directory-at: func(path: string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) RemoveDirectoryAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorRemoveDirectoryAt((uint32)(self0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.remove-directory-at +//go:noescape +func wasmimport_DescriptorRemoveDirectoryAt(self0 uint32, path0 *uint8, path1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// RenameAt represents the imported method "rename-at". +// +// Rename a filesystem object. +// +// Note: This is similar to `renameat` in POSIX. +// +// rename-at: func(old-path: string, new-descriptor: borrow, new-path: +// string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) RenameAt(oldPath string, newDescriptor Descriptor, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + oldPath0, oldPath1 := cm.LowerString(oldPath) + newDescriptor0 := cm.Reinterpret[uint32](newDescriptor) + newPath0, newPath1 := cm.LowerString(newPath) + wasmimport_DescriptorRenameAt((uint32)(self0), (*uint8)(oldPath0), (uint32)(oldPath1), (uint32)(newDescriptor0), (*uint8)(newPath0), (uint32)(newPath1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.rename-at +//go:noescape +func wasmimport_DescriptorRenameAt(self0 uint32, oldPath0 *uint8, oldPath1 uint32, newDescriptor0 uint32, newPath0 *uint8, newPath1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// SetSize represents the imported method "set-size". +// +// Adjust the size of an open file. If this increases the file's size, the +// extra bytes are filled with zeros. +// +// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. +// +// set-size: func(size: filesize) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) SetSize(size FileSize) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + size0 := (uint64)(size) + wasmimport_DescriptorSetSize((uint32)(self0), (uint64)(size0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.set-size +//go:noescape +func wasmimport_DescriptorSetSize(self0 uint32, size0 uint64, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// SetTimes represents the imported method "set-times". +// +// Adjust the timestamps of an open file or directory. +// +// Note: This is similar to `futimens` in POSIX. +// +// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. +// +// set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: +// new-timestamp) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) SetTimes(dataAccessTimestamp NewTimestamp, dataModificationTimestamp NewTimestamp) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + dataAccessTimestamp0, dataAccessTimestamp1, dataAccessTimestamp2 := lower_NewTimestamp(dataAccessTimestamp) + dataModificationTimestamp0, dataModificationTimestamp1, dataModificationTimestamp2 := lower_NewTimestamp(dataModificationTimestamp) + wasmimport_DescriptorSetTimes((uint32)(self0), (uint32)(dataAccessTimestamp0), (uint64)(dataAccessTimestamp1), (uint32)(dataAccessTimestamp2), (uint32)(dataModificationTimestamp0), (uint64)(dataModificationTimestamp1), (uint32)(dataModificationTimestamp2), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.set-times +//go:noescape +func wasmimport_DescriptorSetTimes(self0 uint32, dataAccessTimestamp0 uint32, dataAccessTimestamp1 uint64, dataAccessTimestamp2 uint32, dataModificationTimestamp0 uint32, dataModificationTimestamp1 uint64, dataModificationTimestamp2 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// SetTimesAt represents the imported method "set-times-at". +// +// Adjust the timestamps of a file or directory. +// +// Note: This is similar to `utimensat` in POSIX. +// +// Note: This was called `path_filestat_set_times` in earlier versions of +// WASI. +// +// set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: +// new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) SetTimesAt(pathFlags PathFlags, path string, dataAccessTimestamp NewTimestamp, dataModificationTimestamp NewTimestamp) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + pathFlags0 := (uint32)(pathFlags) + path0, path1 := cm.LowerString(path) + dataAccessTimestamp0, dataAccessTimestamp1, dataAccessTimestamp2 := lower_NewTimestamp(dataAccessTimestamp) + dataModificationTimestamp0, dataModificationTimestamp1, dataModificationTimestamp2 := lower_NewTimestamp(dataModificationTimestamp) + wasmimport_DescriptorSetTimesAt((uint32)(self0), (uint32)(pathFlags0), (*uint8)(path0), (uint32)(path1), (uint32)(dataAccessTimestamp0), (uint64)(dataAccessTimestamp1), (uint32)(dataAccessTimestamp2), (uint32)(dataModificationTimestamp0), (uint64)(dataModificationTimestamp1), (uint32)(dataModificationTimestamp2), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.set-times-at +//go:noescape +func wasmimport_DescriptorSetTimesAt(self0 uint32, pathFlags0 uint32, path0 *uint8, path1 uint32, dataAccessTimestamp0 uint32, dataAccessTimestamp1 uint64, dataAccessTimestamp2 uint32, dataModificationTimestamp0 uint32, dataModificationTimestamp1 uint64, dataModificationTimestamp2 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// Stat represents the imported method "stat". +// +// Return the attributes of an open file or directory. +// +// Note: This is similar to `fstat` in POSIX, except that it does not return +// device and inode information. For testing whether two descriptors refer to +// the same underlying filesystem object, use `is-same-object`. To obtain +// additional data that can be used do determine whether a file has been +// modified, use `metadata-hash`. +// +// Note: This was called `fd_filestat_get` in earlier versions of WASI. +// +// stat: func() -> result +// +//go:nosplit +func (self Descriptor) Stat() (result cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorStat((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.stat +//go:noescape +func wasmimport_DescriptorStat(self0 uint32, result *cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode]) + +// StatAt represents the imported method "stat-at". +// +// Return the attributes of a file or directory. +// +// Note: This is similar to `fstatat` in POSIX, except that it does not +// return device and inode information. See the `stat` description for a +// discussion of alternatives. +// +// Note: This was called `path_filestat_get` in earlier versions of WASI. +// +// stat-at: func(path-flags: path-flags, path: string) -> result +// +//go:nosplit +func (self Descriptor) StatAt(pathFlags PathFlags, path string) (result cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + pathFlags0 := (uint32)(pathFlags) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorStatAt((uint32)(self0), (uint32)(pathFlags0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.stat-at +//go:noescape +func wasmimport_DescriptorStatAt(self0 uint32, pathFlags0 uint32, path0 *uint8, path1 uint32, result *cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode]) + +// SymlinkAt represents the imported method "symlink-at". +// +// Create a symbolic link (also known as a "symlink"). +// +// If `old-path` starts with `/`, the function fails with +// `error-code::not-permitted`. +// +// Note: This is similar to `symlinkat` in POSIX. +// +// symlink-at: func(old-path: string, new-path: string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) SymlinkAt(oldPath string, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + oldPath0, oldPath1 := cm.LowerString(oldPath) + newPath0, newPath1 := cm.LowerString(newPath) + wasmimport_DescriptorSymlinkAt((uint32)(self0), (*uint8)(oldPath0), (uint32)(oldPath1), (*uint8)(newPath0), (uint32)(newPath1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.symlink-at +//go:noescape +func wasmimport_DescriptorSymlinkAt(self0 uint32, oldPath0 *uint8, oldPath1 uint32, newPath0 *uint8, newPath1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// Sync represents the imported method "sync". +// +// Synchronize the data and metadata of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fsync` in POSIX. +// +// sync: func() -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) Sync() (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorSync((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.sync +//go:noescape +func wasmimport_DescriptorSync(self0 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// SyncData represents the imported method "sync-data". +// +// Synchronize the data of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fdatasync` in POSIX. +// +// sync-data: func() -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) SyncData() (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DescriptorSyncData((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.sync-data +//go:noescape +func wasmimport_DescriptorSyncData(self0 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// UnlinkFileAt represents the imported method "unlink-file-at". +// +// Unlink a filesystem object that is not a directory. +// +// Return `error-code::is-directory` if the path refers to a directory. +// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. +// +// unlink-file-at: func(path: string) -> result<_, error-code> +// +//go:nosplit +func (self Descriptor) UnlinkFileAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + path0, path1 := cm.LowerString(path) + wasmimport_DescriptorUnlinkFileAt((uint32)(self0), (*uint8)(path0), (uint32)(path1), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.unlink-file-at +//go:noescape +func wasmimport_DescriptorUnlinkFileAt(self0 uint32, path0 *uint8, path1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// Write represents the imported method "write". +// +// Write to a descriptor, without using and updating the descriptor's offset. +// +// It is valid to write past the end of a file; the file is extended to the +// extent of the write, with bytes between the previous end and the start of +// the write set to zero. +// +// In the future, this may change to take a `stream`. +// +// Note: This is similar to `pwrite` in POSIX. +// +// write: func(buffer: list, offset: filesize) -> result +// +//go:nosplit +func (self Descriptor) Write(buffer cm.List[uint8], offset FileSize) (result cm.Result[uint64, FileSize, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + buffer0, buffer1 := cm.LowerList(buffer) + offset0 := (uint64)(offset) + wasmimport_DescriptorWrite((uint32)(self0), (*uint8)(buffer0), (uint32)(buffer1), (uint64)(offset0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.write +//go:noescape +func wasmimport_DescriptorWrite(self0 uint32, buffer0 *uint8, buffer1 uint32, offset0 uint64, result *cm.Result[uint64, FileSize, ErrorCode]) + +// WriteViaStream represents the imported method "write-via-stream". +// +// Return a stream for writing to a file, if available. +// +// May fail with an error-code describing why the file cannot be written. +// +// Note: This allows using `write-stream`, which is similar to `write` in +// POSIX. +// +// write-via-stream: func(offset: filesize) -> result +// +//go:nosplit +func (self Descriptor) WriteViaStream(offset FileSize) (result cm.Result[streams.OutputStream, streams.OutputStream, ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + offset0 := (uint64)(offset) + wasmimport_DescriptorWriteViaStream((uint32)(self0), (uint64)(offset0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.write-via-stream +//go:noescape +func wasmimport_DescriptorWriteViaStream(self0 uint32, offset0 uint64, result *cm.Result[streams.OutputStream, streams.OutputStream, ErrorCode]) + +// DirectoryEntryStream represents the imported resource "wasi:filesystem/types@0.2.0#directory-entry-stream". +// +// A stream of directory entries. +// +// resource directory-entry-stream +type DirectoryEntryStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "directory-entry-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self DirectoryEntryStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DirectoryEntryStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [resource-drop]directory-entry-stream +//go:noescape +func wasmimport_DirectoryEntryStreamResourceDrop(self0 uint32) + +// ReadDirectoryEntry represents the imported method "read-directory-entry". +// +// Read a single directory entry from a `directory-entry-stream`. +// +// read-directory-entry: func() -> result, error-code> +// +//go:nosplit +func (self DirectoryEntryStream) ReadDirectoryEntry() (result cm.Result[OptionDirectoryEntryShape, cm.Option[DirectoryEntry], ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_DirectoryEntryStreamReadDirectoryEntry((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 [method]directory-entry-stream.read-directory-entry +//go:noescape +func wasmimport_DirectoryEntryStreamReadDirectoryEntry(self0 uint32, result *cm.Result[OptionDirectoryEntryShape, cm.Option[DirectoryEntry], ErrorCode]) + +// FilesystemErrorCode represents the imported function "filesystem-error-code". +// +// Attempts to extract a filesystem-related `error-code` from the stream +// `error` provided. +// +// Stream operations which return `stream-error::last-operation-failed` +// have a payload with more information about the operation that failed. +// This payload can be passed through to this function to see if there's +// filesystem-related information about the error to return. +// +// Note that this function is fallible because not all stream-related +// errors are filesystem-related errors. +// +// filesystem-error-code: func(err: borrow) -> option +// +//go:nosplit +func FilesystemErrorCode(err ioerror.Error) (result cm.Option[ErrorCode]) { + err0 := cm.Reinterpret[uint32](err) + wasmimport_FilesystemErrorCode((uint32)(err0), &result) + return +} + +//go:wasmimport wasi:filesystem/types@0.2.0 filesystem-error-code +//go:noescape +func wasmimport_FilesystemErrorCode(err0 uint32, result *cm.Option[ErrorCode]) diff --git a/tests/go/wasi/bindings/wasi/http/incoming-handler/empty.s b/tests/go/wasi/bindings/wasi/http/incoming-handler/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/incoming-handler/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.exports.go b/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.exports.go new file mode 100644 index 0000000..5543ea4 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.exports.go @@ -0,0 +1,26 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package incominghandler + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/types" +) + +// Exports represents the caller-defined exports from "wasi:http/incoming-handler@0.2.0". +var Exports struct { + // Handle represents the caller-defined, exported function "handle". + // + // This function is invoked with an incoming HTTP Request, and a resource + // `response-outparam` which provides the capability to reply with an HTTP + // Response. The response is sent by calling the `response-outparam.set` + // method, which allows execution to continue after the response has been + // sent. This enables both streaming to the response body, and performing other + // work. + // + // The implementor of this function must write a response to the + // `response-outparam` before returning, or else the caller will respond + // with an error on its behalf. + // + // handle: func(request: incoming-request, response-out: response-outparam) + Handle func(request types.IncomingRequest, responseOut types.ResponseOutparam) +} diff --git a/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.wit.go b/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.wit.go new file mode 100644 index 0000000..0095107 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/incoming-handler/incoming-handler.wit.go @@ -0,0 +1,21 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package incominghandler represents the exported interface "wasi:http/incoming-handler@0.2.0". +// +// This interface defines a handler of incoming HTTP Requests. It should +// be exported by components which can respond to HTTP Requests. +package incominghandler + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/types" + "github.com/ydnar/wasm-tools-go/cm" +) + +//go:wasmexport wasi:http/incoming-handler@0.2.0#handle +//export wasi:http/incoming-handler@0.2.0#handle +func wasmexport_Handle(request0 uint32, responseOut0 uint32) { + request := cm.Reinterpret[types.IncomingRequest]((uint32)(request0)) + responseOut := cm.Reinterpret[types.ResponseOutparam]((uint32)(responseOut0)) + Exports.Handle(request, responseOut) + return +} diff --git a/tests/go/wasi/bindings/wasi/http/types/abi.go b/tests/go/wasi/bindings/wasi/http/types/abi.go new file mode 100644 index 0000000..b6f9587 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/types/abi.go @@ -0,0 +1,273 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package types + +import ( + monotonicclock "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/clocks/monotonic-clock" + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// OptionFieldSizePayloadShape is used for storage in variant or result types. +type OptionFieldSizePayloadShape struct { + shape [unsafe.Sizeof(cm.Option[FieldSizePayload]{})]byte +} + +func lower_OptionString(v cm.Option[string]) (f0 uint32, f1 *uint8, f2 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1, v2 := cm.LowerString(*some) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } + return +} + +func lower_Method(v Method) (f0 uint32, f1 *uint8, f2 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 9: // other + v1, v2 := cm.LowerString(*v.Other()) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } + return +} + +func lower_Scheme(v Scheme) (f0 uint32, f1 *uint8, f2 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 2: // other + v1, v2 := cm.LowerString(*v.Other()) + f1 = (*uint8)(v1) + f2 = (uint32)(v2) + } + return +} + +func lower_OptionScheme(v cm.Option[Scheme]) (f0 uint32, f1 uint32, f2 *uint8, f3 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1, v2, v3 := lower_Scheme(*some) + f1 = (uint32)(v1) + f2 = (*uint8)(v2) + f3 = (uint32)(v3) + } + return +} + +func lower_OptionDuration(v cm.Option[monotonicclock.Duration]) (f0 uint32, f1 uint64) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := (uint64)(*some) + f1 = (uint64)(v1) + } + return +} + +// ErrorCodeShape is used for storage in variant or result types. +type ErrorCodeShape struct { + shape [unsafe.Sizeof(ErrorCode{})]byte +} + +func lower_OptionU16(v cm.Option[uint16]) (f0 uint32, f1 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := (uint32)(*some) + f1 = (uint32)(v1) + } + return +} + +func lower_DNSErrorPayload(v DNSErrorPayload) (f0 uint32, f1 *uint8, f2 uint32, f3 uint32, f4 uint32) { + f0, f1, f2 = lower_OptionString(v.Rcode) + f3, f4 = lower_OptionU16(v.InfoCode) + return +} + +func lower_OptionU8(v cm.Option[uint8]) (f0 uint32, f1 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := (uint32)(*some) + f1 = (uint32)(v1) + } + return +} + +func lower_TLSAlertReceivedPayload(v TLSAlertReceivedPayload) (f0 uint32, f1 uint32, f2 uint32, f3 *uint8, f4 uint32) { + f0, f1 = lower_OptionU8(v.AlertID) + f2, f3, f4 = lower_OptionString(v.AlertMessage) + return +} + +func lower_OptionU64(v cm.Option[uint64]) (f0 uint32, f1 uint64) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := (uint64)(*some) + f1 = (uint64)(v1) + } + return +} + +func lower_OptionU32(v cm.Option[uint32]) (f0 uint32, f1 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := (uint32)(*some) + f1 = (uint32)(v1) + } + return +} + +func lower_FieldSizePayload(v FieldSizePayload) (f0 uint32, f1 *uint8, f2 uint32, f3 uint32, f4 uint32) { + f0, f1, f2 = lower_OptionString(v.FieldName) + f3, f4 = lower_OptionU32(v.FieldSize) + return +} + +func lower_OptionFieldSizePayload(v cm.Option[FieldSizePayload]) (f0 uint32, f1 uint32, f2 *uint8, f3 uint32, f4 uint32, f5 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1, v2, v3, v4, v5 := lower_FieldSizePayload(*some) + f1 = (uint32)(v1) + f2 = (*uint8)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + } + return +} + +func lower_ErrorCode(v ErrorCode) (f0 uint32, f1 uint32, f2 uint64, f3 uint32, f4 uint32, f5 uint32, f6 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 1: // DNS-error + v1, v2, v3, v4, v5 := lower_DNSErrorPayload(*v.DNSError()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 14: // TLS-alert-received + v1, v2, v3, v4, v5 := lower_TLSAlertReceivedPayload(*v.TLSAlertReceived()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + f3 = (uint32)(v3) + f4 = cm.PointerToU32(v4) + f5 = (uint32)(v5) + case 17: // HTTP-request-body-size + v1, v2 := lower_OptionU64(*v.HTTPRequestBodySize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 21: // HTTP-request-header-section-size + v1, v2 := lower_OptionU32(*v.HTTPRequestHeaderSectionSize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 22: // HTTP-request-header-size + v1, v2, v3, v4, v5, v6 := lower_OptionFieldSizePayload(*v.HTTPRequestHeaderSize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + f3 = cm.PointerToU32(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + f6 = (uint32)(v6) + case 23: // HTTP-request-trailer-section-size + v1, v2 := lower_OptionU32(*v.HTTPRequestTrailerSectionSize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 24: // HTTP-request-trailer-size + v1, v2, v3, v4, v5 := lower_FieldSizePayload(*v.HTTPRequestTrailerSize()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 26: // HTTP-response-header-section-size + v1, v2 := lower_OptionU32(*v.HTTPResponseHeaderSectionSize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 27: // HTTP-response-header-size + v1, v2, v3, v4, v5 := lower_FieldSizePayload(*v.HTTPResponseHeaderSize()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 28: // HTTP-response-body-size + v1, v2 := lower_OptionU64(*v.HTTPResponseBodySize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 29: // HTTP-response-trailer-section-size + v1, v2 := lower_OptionU32(*v.HTTPResponseTrailerSectionSize()) + f1 = (uint32)(v1) + f2 = (uint64)(v2) + case 30: // HTTP-response-trailer-size + v1, v2, v3, v4, v5 := lower_FieldSizePayload(*v.HTTPResponseTrailerSize()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 31: // HTTP-response-transfer-coding + v1, v2, v3 := lower_OptionString(*v.HTTPResponseTransferCoding()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + case 32: // HTTP-response-content-coding + v1, v2, v3 := lower_OptionString(*v.HTTPResponseContentCoding()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + case 38: // internal-error + v1, v2, v3 := lower_OptionString(*v.InternalError()) + f1 = (uint32)(v1) + f2 = cm.PointerToU64(v2) + f3 = (uint32)(v3) + } + return +} + +func lower_ResultOutgoingResponseErrorCode(v cm.Result[ErrorCodeShape, OutgoingResponse, ErrorCode]) (f0 uint32, f1 uint32, f2 uint32, f3 uint64, f4 uint32, f5 uint32, f6 uint32, f7 uint32) { + if v.IsOK() { + v1 := cm.Reinterpret[uint32](*v.OK()) + f1 = (uint32)(v1) + } else { + f0 = 1 + v1, v2, v3, v4, v5, v6, v7 := lower_ErrorCode(*v.Err()) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint64)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + f6 = (uint32)(v6) + f7 = (uint32)(v7) + } + return +} + +// ResultOptionTrailersErrorCodeShape is used for storage in variant or result types. +type ResultOptionTrailersErrorCodeShape struct { + shape [unsafe.Sizeof(cm.Result[ErrorCodeShape, cm.Option[Fields], ErrorCode]{})]byte +} + +func lower_OptionTrailers(v cm.Option[Fields]) (f0 uint32, f1 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1 := cm.Reinterpret[uint32](*some) + f1 = (uint32)(v1) + } + return +} + +// ResultIncomingResponseErrorCodeShape is used for storage in variant or result types. +type ResultIncomingResponseErrorCodeShape struct { + shape [unsafe.Sizeof(cm.Result[ErrorCodeShape, IncomingResponse, ErrorCode]{})]byte +} diff --git a/tests/go/wasi/bindings/wasi/http/types/empty.s b/tests/go/wasi/bindings/wasi/http/types/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/types/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/http/types/types.wit.go b/tests/go/wasi/bindings/wasi/http/types/types.wit.go new file mode 100644 index 0000000..5a7bbea --- /dev/null +++ b/tests/go/wasi/bindings/wasi/http/types/types.wit.go @@ -0,0 +1,2141 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package types represents the imported interface "wasi:http/types@0.2.0". +// +// This interface defines all of the types and methods for implementing +// HTTP Requests and Responses, both incoming and outgoing, as well as +// their headers, trailers, and bodies. +package types + +import ( + monotonicclock "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/clocks/monotonic-clock" + ioerror "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/error" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/ydnar/wasm-tools-go/cm" +) + +// Method represents the variant "wasi:http/types@0.2.0#method". +// +// This type corresponds to HTTP standard Methods. +// +// variant method { +// get, +// head, +// post, +// put, +// delete, +// connect, +// options, +// trace, +// patch, +// other(string), +// } +type Method cm.Variant[uint8, string, string] + +// MethodGet returns a [Method] of case "get". +func MethodGet() Method { + var data struct{} + return cm.New[Method](0, data) +} + +// Get returns true if [Method] represents the variant case "get". +func (self *Method) Get() bool { + return self.Tag() == 0 +} + +// MethodHead returns a [Method] of case "head". +func MethodHead() Method { + var data struct{} + return cm.New[Method](1, data) +} + +// Head returns true if [Method] represents the variant case "head". +func (self *Method) Head() bool { + return self.Tag() == 1 +} + +// MethodPost returns a [Method] of case "post". +func MethodPost() Method { + var data struct{} + return cm.New[Method](2, data) +} + +// Post returns true if [Method] represents the variant case "post". +func (self *Method) Post() bool { + return self.Tag() == 2 +} + +// MethodPut returns a [Method] of case "put". +func MethodPut() Method { + var data struct{} + return cm.New[Method](3, data) +} + +// Put returns true if [Method] represents the variant case "put". +func (self *Method) Put() bool { + return self.Tag() == 3 +} + +// MethodDelete returns a [Method] of case "delete". +func MethodDelete() Method { + var data struct{} + return cm.New[Method](4, data) +} + +// Delete returns true if [Method] represents the variant case "delete". +func (self *Method) Delete() bool { + return self.Tag() == 4 +} + +// MethodConnect returns a [Method] of case "connect". +func MethodConnect() Method { + var data struct{} + return cm.New[Method](5, data) +} + +// Connect returns true if [Method] represents the variant case "connect". +func (self *Method) Connect() bool { + return self.Tag() == 5 +} + +// MethodOptions returns a [Method] of case "options". +func MethodOptions() Method { + var data struct{} + return cm.New[Method](6, data) +} + +// Options returns true if [Method] represents the variant case "options". +func (self *Method) Options() bool { + return self.Tag() == 6 +} + +// MethodTrace returns a [Method] of case "trace". +func MethodTrace() Method { + var data struct{} + return cm.New[Method](7, data) +} + +// Trace returns true if [Method] represents the variant case "trace". +func (self *Method) Trace() bool { + return self.Tag() == 7 +} + +// MethodPatch returns a [Method] of case "patch". +func MethodPatch() Method { + var data struct{} + return cm.New[Method](8, data) +} + +// Patch returns true if [Method] represents the variant case "patch". +func (self *Method) Patch() bool { + return self.Tag() == 8 +} + +// MethodOther returns a [Method] of case "other". +func MethodOther(data string) Method { + return cm.New[Method](9, data) +} + +// Other returns a non-nil *[string] if [Method] represents the variant case "other". +func (self *Method) Other() *string { + return cm.Case[string](self, 9) +} + +// Scheme represents the variant "wasi:http/types@0.2.0#scheme". +// +// This type corresponds to HTTP standard Related Schemes. +// +// variant scheme { +// HTTP, +// HTTPS, +// other(string), +// } +type Scheme cm.Variant[uint8, string, string] + +// SchemeHTTP returns a [Scheme] of case "HTTP". +func SchemeHTTP() Scheme { + var data struct{} + return cm.New[Scheme](0, data) +} + +// HTTP returns true if [Scheme] represents the variant case "HTTP". +func (self *Scheme) HTTP() bool { + return self.Tag() == 0 +} + +// SchemeHTTPS returns a [Scheme] of case "HTTPS". +func SchemeHTTPS() Scheme { + var data struct{} + return cm.New[Scheme](1, data) +} + +// HTTPS returns true if [Scheme] represents the variant case "HTTPS". +func (self *Scheme) HTTPS() bool { + return self.Tag() == 1 +} + +// SchemeOther returns a [Scheme] of case "other". +func SchemeOther(data string) Scheme { + return cm.New[Scheme](2, data) +} + +// Other returns a non-nil *[string] if [Scheme] represents the variant case "other". +func (self *Scheme) Other() *string { + return cm.Case[string](self, 2) +} + +// DNSErrorPayload represents the record "wasi:http/types@0.2.0#DNS-error-payload". +// +// Defines the case payload type for `DNS-error` above: +// +// record DNS-error-payload { +// rcode: option, +// info-code: option, +// } +type DNSErrorPayload struct { + Rcode cm.Option[string] + InfoCode cm.Option[uint16] +} + +// TLSAlertReceivedPayload represents the record "wasi:http/types@0.2.0#TLS-alert-received-payload". +// +// Defines the case payload type for `TLS-alert-received` above: +// +// record TLS-alert-received-payload { +// alert-id: option, +// alert-message: option, +// } +type TLSAlertReceivedPayload struct { + AlertID cm.Option[uint8] + AlertMessage cm.Option[string] +} + +// FieldSizePayload represents the record "wasi:http/types@0.2.0#field-size-payload". +// +// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: +// +// record field-size-payload { +// field-name: option, +// field-size: option, +// } +type FieldSizePayload struct { + FieldName cm.Option[string] + FieldSize cm.Option[uint32] +} + +// ErrorCode represents the variant "wasi:http/types@0.2.0#error-code". +// +// These cases are inspired by the IANA HTTP Proxy Error Types: +// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types +// +// variant error-code { +// DNS-timeout, +// DNS-error(DNS-error-payload), +// destination-not-found, +// destination-unavailable, +// destination-IP-prohibited, +// destination-IP-unroutable, +// connection-refused, +// connection-terminated, +// connection-timeout, +// connection-read-timeout, +// connection-write-timeout, +// connection-limit-reached, +// TLS-protocol-error, +// TLS-certificate-error, +// TLS-alert-received(TLS-alert-received-payload), +// HTTP-request-denied, +// HTTP-request-length-required, +// HTTP-request-body-size(option), +// HTTP-request-method-invalid, +// HTTP-request-URI-invalid, +// HTTP-request-URI-too-long, +// HTTP-request-header-section-size(option), +// HTTP-request-header-size(option), +// HTTP-request-trailer-section-size(option), +// HTTP-request-trailer-size(field-size-payload), +// HTTP-response-incomplete, +// HTTP-response-header-section-size(option), +// HTTP-response-header-size(field-size-payload), +// HTTP-response-body-size(option), +// HTTP-response-trailer-section-size(option), +// HTTP-response-trailer-size(field-size-payload), +// HTTP-response-transfer-coding(option), +// HTTP-response-content-coding(option), +// HTTP-response-timeout, +// HTTP-upgrade-failed, +// HTTP-protocol-error, +// loop-detected, +// configuration-error, +// internal-error(option), +// } +type ErrorCode cm.Variant[uint8, OptionFieldSizePayloadShape, cm.Option[uint64]] + +// ErrorCodeDNSTimeout returns a [ErrorCode] of case "DNS-timeout". +func ErrorCodeDNSTimeout() ErrorCode { + var data struct{} + return cm.New[ErrorCode](0, data) +} + +// DNSTimeout returns true if [ErrorCode] represents the variant case "DNS-timeout". +func (self *ErrorCode) DNSTimeout() bool { + return self.Tag() == 0 +} + +// ErrorCodeDNSError returns a [ErrorCode] of case "DNS-error". +func ErrorCodeDNSError(data DNSErrorPayload) ErrorCode { + return cm.New[ErrorCode](1, data) +} + +// DNSError returns a non-nil *[DNSErrorPayload] if [ErrorCode] represents the variant case "DNS-error". +func (self *ErrorCode) DNSError() *DNSErrorPayload { + return cm.Case[DNSErrorPayload](self, 1) +} + +// ErrorCodeDestinationNotFound returns a [ErrorCode] of case "destination-not-found". +func ErrorCodeDestinationNotFound() ErrorCode { + var data struct{} + return cm.New[ErrorCode](2, data) +} + +// DestinationNotFound returns true if [ErrorCode] represents the variant case "destination-not-found". +func (self *ErrorCode) DestinationNotFound() bool { + return self.Tag() == 2 +} + +// ErrorCodeDestinationUnavailable returns a [ErrorCode] of case "destination-unavailable". +func ErrorCodeDestinationUnavailable() ErrorCode { + var data struct{} + return cm.New[ErrorCode](3, data) +} + +// DestinationUnavailable returns true if [ErrorCode] represents the variant case "destination-unavailable". +func (self *ErrorCode) DestinationUnavailable() bool { + return self.Tag() == 3 +} + +// ErrorCodeDestinationIPProhibited returns a [ErrorCode] of case "destination-IP-prohibited". +func ErrorCodeDestinationIPProhibited() ErrorCode { + var data struct{} + return cm.New[ErrorCode](4, data) +} + +// DestinationIPProhibited returns true if [ErrorCode] represents the variant case "destination-IP-prohibited". +func (self *ErrorCode) DestinationIPProhibited() bool { + return self.Tag() == 4 +} + +// ErrorCodeDestinationIPUnroutable returns a [ErrorCode] of case "destination-IP-unroutable". +func ErrorCodeDestinationIPUnroutable() ErrorCode { + var data struct{} + return cm.New[ErrorCode](5, data) +} + +// DestinationIPUnroutable returns true if [ErrorCode] represents the variant case "destination-IP-unroutable". +func (self *ErrorCode) DestinationIPUnroutable() bool { + return self.Tag() == 5 +} + +// ErrorCodeConnectionRefused returns a [ErrorCode] of case "connection-refused". +func ErrorCodeConnectionRefused() ErrorCode { + var data struct{} + return cm.New[ErrorCode](6, data) +} + +// ConnectionRefused returns true if [ErrorCode] represents the variant case "connection-refused". +func (self *ErrorCode) ConnectionRefused() bool { + return self.Tag() == 6 +} + +// ErrorCodeConnectionTerminated returns a [ErrorCode] of case "connection-terminated". +func ErrorCodeConnectionTerminated() ErrorCode { + var data struct{} + return cm.New[ErrorCode](7, data) +} + +// ConnectionTerminated returns true if [ErrorCode] represents the variant case "connection-terminated". +func (self *ErrorCode) ConnectionTerminated() bool { + return self.Tag() == 7 +} + +// ErrorCodeConnectionTimeout returns a [ErrorCode] of case "connection-timeout". +func ErrorCodeConnectionTimeout() ErrorCode { + var data struct{} + return cm.New[ErrorCode](8, data) +} + +// ConnectionTimeout returns true if [ErrorCode] represents the variant case "connection-timeout". +func (self *ErrorCode) ConnectionTimeout() bool { + return self.Tag() == 8 +} + +// ErrorCodeConnectionReadTimeout returns a [ErrorCode] of case "connection-read-timeout". +func ErrorCodeConnectionReadTimeout() ErrorCode { + var data struct{} + return cm.New[ErrorCode](9, data) +} + +// ConnectionReadTimeout returns true if [ErrorCode] represents the variant case "connection-read-timeout". +func (self *ErrorCode) ConnectionReadTimeout() bool { + return self.Tag() == 9 +} + +// ErrorCodeConnectionWriteTimeout returns a [ErrorCode] of case "connection-write-timeout". +func ErrorCodeConnectionWriteTimeout() ErrorCode { + var data struct{} + return cm.New[ErrorCode](10, data) +} + +// ConnectionWriteTimeout returns true if [ErrorCode] represents the variant case "connection-write-timeout". +func (self *ErrorCode) ConnectionWriteTimeout() bool { + return self.Tag() == 10 +} + +// ErrorCodeConnectionLimitReached returns a [ErrorCode] of case "connection-limit-reached". +func ErrorCodeConnectionLimitReached() ErrorCode { + var data struct{} + return cm.New[ErrorCode](11, data) +} + +// ConnectionLimitReached returns true if [ErrorCode] represents the variant case "connection-limit-reached". +func (self *ErrorCode) ConnectionLimitReached() bool { + return self.Tag() == 11 +} + +// ErrorCodeTLSProtocolError returns a [ErrorCode] of case "TLS-protocol-error". +func ErrorCodeTLSProtocolError() ErrorCode { + var data struct{} + return cm.New[ErrorCode](12, data) +} + +// TLSProtocolError returns true if [ErrorCode] represents the variant case "TLS-protocol-error". +func (self *ErrorCode) TLSProtocolError() bool { + return self.Tag() == 12 +} + +// ErrorCodeTLSCertificateError returns a [ErrorCode] of case "TLS-certificate-error". +func ErrorCodeTLSCertificateError() ErrorCode { + var data struct{} + return cm.New[ErrorCode](13, data) +} + +// TLSCertificateError returns true if [ErrorCode] represents the variant case "TLS-certificate-error". +func (self *ErrorCode) TLSCertificateError() bool { + return self.Tag() == 13 +} + +// ErrorCodeTLSAlertReceived returns a [ErrorCode] of case "TLS-alert-received". +func ErrorCodeTLSAlertReceived(data TLSAlertReceivedPayload) ErrorCode { + return cm.New[ErrorCode](14, data) +} + +// TLSAlertReceived returns a non-nil *[TLSAlertReceivedPayload] if [ErrorCode] represents the variant case "TLS-alert-received". +func (self *ErrorCode) TLSAlertReceived() *TLSAlertReceivedPayload { + return cm.Case[TLSAlertReceivedPayload](self, 14) +} + +// ErrorCodeHTTPRequestDenied returns a [ErrorCode] of case "HTTP-request-denied". +func ErrorCodeHTTPRequestDenied() ErrorCode { + var data struct{} + return cm.New[ErrorCode](15, data) +} + +// HTTPRequestDenied returns true if [ErrorCode] represents the variant case "HTTP-request-denied". +func (self *ErrorCode) HTTPRequestDenied() bool { + return self.Tag() == 15 +} + +// ErrorCodeHTTPRequestLengthRequired returns a [ErrorCode] of case "HTTP-request-length-required". +func ErrorCodeHTTPRequestLengthRequired() ErrorCode { + var data struct{} + return cm.New[ErrorCode](16, data) +} + +// HTTPRequestLengthRequired returns true if [ErrorCode] represents the variant case "HTTP-request-length-required". +func (self *ErrorCode) HTTPRequestLengthRequired() bool { + return self.Tag() == 16 +} + +// ErrorCodeHTTPRequestBodySize returns a [ErrorCode] of case "HTTP-request-body-size". +func ErrorCodeHTTPRequestBodySize(data cm.Option[uint64]) ErrorCode { + return cm.New[ErrorCode](17, data) +} + +// HTTPRequestBodySize returns a non-nil *[cm.Option[uint64]] if [ErrorCode] represents the variant case "HTTP-request-body-size". +func (self *ErrorCode) HTTPRequestBodySize() *cm.Option[uint64] { + return cm.Case[cm.Option[uint64]](self, 17) +} + +// ErrorCodeHTTPRequestMethodInvalid returns a [ErrorCode] of case "HTTP-request-method-invalid". +func ErrorCodeHTTPRequestMethodInvalid() ErrorCode { + var data struct{} + return cm.New[ErrorCode](18, data) +} + +// HTTPRequestMethodInvalid returns true if [ErrorCode] represents the variant case "HTTP-request-method-invalid". +func (self *ErrorCode) HTTPRequestMethodInvalid() bool { + return self.Tag() == 18 +} + +// ErrorCodeHTTPRequestURIInvalid returns a [ErrorCode] of case "HTTP-request-URI-invalid". +func ErrorCodeHTTPRequestURIInvalid() ErrorCode { + var data struct{} + return cm.New[ErrorCode](19, data) +} + +// HTTPRequestURIInvalid returns true if [ErrorCode] represents the variant case "HTTP-request-URI-invalid". +func (self *ErrorCode) HTTPRequestURIInvalid() bool { + return self.Tag() == 19 +} + +// ErrorCodeHTTPRequestURITooLong returns a [ErrorCode] of case "HTTP-request-URI-too-long". +func ErrorCodeHTTPRequestURITooLong() ErrorCode { + var data struct{} + return cm.New[ErrorCode](20, data) +} + +// HTTPRequestURITooLong returns true if [ErrorCode] represents the variant case "HTTP-request-URI-too-long". +func (self *ErrorCode) HTTPRequestURITooLong() bool { + return self.Tag() == 20 +} + +// ErrorCodeHTTPRequestHeaderSectionSize returns a [ErrorCode] of case "HTTP-request-header-section-size". +func ErrorCodeHTTPRequestHeaderSectionSize(data cm.Option[uint32]) ErrorCode { + return cm.New[ErrorCode](21, data) +} + +// HTTPRequestHeaderSectionSize returns a non-nil *[cm.Option[uint32]] if [ErrorCode] represents the variant case "HTTP-request-header-section-size". +func (self *ErrorCode) HTTPRequestHeaderSectionSize() *cm.Option[uint32] { + return cm.Case[cm.Option[uint32]](self, 21) +} + +// ErrorCodeHTTPRequestHeaderSize returns a [ErrorCode] of case "HTTP-request-header-size". +func ErrorCodeHTTPRequestHeaderSize(data cm.Option[FieldSizePayload]) ErrorCode { + return cm.New[ErrorCode](22, data) +} + +// HTTPRequestHeaderSize returns a non-nil *[cm.Option[FieldSizePayload]] if [ErrorCode] represents the variant case "HTTP-request-header-size". +func (self *ErrorCode) HTTPRequestHeaderSize() *cm.Option[FieldSizePayload] { + return cm.Case[cm.Option[FieldSizePayload]](self, 22) +} + +// ErrorCodeHTTPRequestTrailerSectionSize returns a [ErrorCode] of case "HTTP-request-trailer-section-size". +func ErrorCodeHTTPRequestTrailerSectionSize(data cm.Option[uint32]) ErrorCode { + return cm.New[ErrorCode](23, data) +} + +// HTTPRequestTrailerSectionSize returns a non-nil *[cm.Option[uint32]] if [ErrorCode] represents the variant case "HTTP-request-trailer-section-size". +func (self *ErrorCode) HTTPRequestTrailerSectionSize() *cm.Option[uint32] { + return cm.Case[cm.Option[uint32]](self, 23) +} + +// ErrorCodeHTTPRequestTrailerSize returns a [ErrorCode] of case "HTTP-request-trailer-size". +func ErrorCodeHTTPRequestTrailerSize(data FieldSizePayload) ErrorCode { + return cm.New[ErrorCode](24, data) +} + +// HTTPRequestTrailerSize returns a non-nil *[FieldSizePayload] if [ErrorCode] represents the variant case "HTTP-request-trailer-size". +func (self *ErrorCode) HTTPRequestTrailerSize() *FieldSizePayload { + return cm.Case[FieldSizePayload](self, 24) +} + +// ErrorCodeHTTPResponseIncomplete returns a [ErrorCode] of case "HTTP-response-incomplete". +func ErrorCodeHTTPResponseIncomplete() ErrorCode { + var data struct{} + return cm.New[ErrorCode](25, data) +} + +// HTTPResponseIncomplete returns true if [ErrorCode] represents the variant case "HTTP-response-incomplete". +func (self *ErrorCode) HTTPResponseIncomplete() bool { + return self.Tag() == 25 +} + +// ErrorCodeHTTPResponseHeaderSectionSize returns a [ErrorCode] of case "HTTP-response-header-section-size". +func ErrorCodeHTTPResponseHeaderSectionSize(data cm.Option[uint32]) ErrorCode { + return cm.New[ErrorCode](26, data) +} + +// HTTPResponseHeaderSectionSize returns a non-nil *[cm.Option[uint32]] if [ErrorCode] represents the variant case "HTTP-response-header-section-size". +func (self *ErrorCode) HTTPResponseHeaderSectionSize() *cm.Option[uint32] { + return cm.Case[cm.Option[uint32]](self, 26) +} + +// ErrorCodeHTTPResponseHeaderSize returns a [ErrorCode] of case "HTTP-response-header-size". +func ErrorCodeHTTPResponseHeaderSize(data FieldSizePayload) ErrorCode { + return cm.New[ErrorCode](27, data) +} + +// HTTPResponseHeaderSize returns a non-nil *[FieldSizePayload] if [ErrorCode] represents the variant case "HTTP-response-header-size". +func (self *ErrorCode) HTTPResponseHeaderSize() *FieldSizePayload { + return cm.Case[FieldSizePayload](self, 27) +} + +// ErrorCodeHTTPResponseBodySize returns a [ErrorCode] of case "HTTP-response-body-size". +func ErrorCodeHTTPResponseBodySize(data cm.Option[uint64]) ErrorCode { + return cm.New[ErrorCode](28, data) +} + +// HTTPResponseBodySize returns a non-nil *[cm.Option[uint64]] if [ErrorCode] represents the variant case "HTTP-response-body-size". +func (self *ErrorCode) HTTPResponseBodySize() *cm.Option[uint64] { + return cm.Case[cm.Option[uint64]](self, 28) +} + +// ErrorCodeHTTPResponseTrailerSectionSize returns a [ErrorCode] of case "HTTP-response-trailer-section-size". +func ErrorCodeHTTPResponseTrailerSectionSize(data cm.Option[uint32]) ErrorCode { + return cm.New[ErrorCode](29, data) +} + +// HTTPResponseTrailerSectionSize returns a non-nil *[cm.Option[uint32]] if [ErrorCode] represents the variant case "HTTP-response-trailer-section-size". +func (self *ErrorCode) HTTPResponseTrailerSectionSize() *cm.Option[uint32] { + return cm.Case[cm.Option[uint32]](self, 29) +} + +// ErrorCodeHTTPResponseTrailerSize returns a [ErrorCode] of case "HTTP-response-trailer-size". +func ErrorCodeHTTPResponseTrailerSize(data FieldSizePayload) ErrorCode { + return cm.New[ErrorCode](30, data) +} + +// HTTPResponseTrailerSize returns a non-nil *[FieldSizePayload] if [ErrorCode] represents the variant case "HTTP-response-trailer-size". +func (self *ErrorCode) HTTPResponseTrailerSize() *FieldSizePayload { + return cm.Case[FieldSizePayload](self, 30) +} + +// ErrorCodeHTTPResponseTransferCoding returns a [ErrorCode] of case "HTTP-response-transfer-coding". +func ErrorCodeHTTPResponseTransferCoding(data cm.Option[string]) ErrorCode { + return cm.New[ErrorCode](31, data) +} + +// HTTPResponseTransferCoding returns a non-nil *[cm.Option[string]] if [ErrorCode] represents the variant case "HTTP-response-transfer-coding". +func (self *ErrorCode) HTTPResponseTransferCoding() *cm.Option[string] { + return cm.Case[cm.Option[string]](self, 31) +} + +// ErrorCodeHTTPResponseContentCoding returns a [ErrorCode] of case "HTTP-response-content-coding". +func ErrorCodeHTTPResponseContentCoding(data cm.Option[string]) ErrorCode { + return cm.New[ErrorCode](32, data) +} + +// HTTPResponseContentCoding returns a non-nil *[cm.Option[string]] if [ErrorCode] represents the variant case "HTTP-response-content-coding". +func (self *ErrorCode) HTTPResponseContentCoding() *cm.Option[string] { + return cm.Case[cm.Option[string]](self, 32) +} + +// ErrorCodeHTTPResponseTimeout returns a [ErrorCode] of case "HTTP-response-timeout". +func ErrorCodeHTTPResponseTimeout() ErrorCode { + var data struct{} + return cm.New[ErrorCode](33, data) +} + +// HTTPResponseTimeout returns true if [ErrorCode] represents the variant case "HTTP-response-timeout". +func (self *ErrorCode) HTTPResponseTimeout() bool { + return self.Tag() == 33 +} + +// ErrorCodeHTTPUpgradeFailed returns a [ErrorCode] of case "HTTP-upgrade-failed". +func ErrorCodeHTTPUpgradeFailed() ErrorCode { + var data struct{} + return cm.New[ErrorCode](34, data) +} + +// HTTPUpgradeFailed returns true if [ErrorCode] represents the variant case "HTTP-upgrade-failed". +func (self *ErrorCode) HTTPUpgradeFailed() bool { + return self.Tag() == 34 +} + +// ErrorCodeHTTPProtocolError returns a [ErrorCode] of case "HTTP-protocol-error". +func ErrorCodeHTTPProtocolError() ErrorCode { + var data struct{} + return cm.New[ErrorCode](35, data) +} + +// HTTPProtocolError returns true if [ErrorCode] represents the variant case "HTTP-protocol-error". +func (self *ErrorCode) HTTPProtocolError() bool { + return self.Tag() == 35 +} + +// ErrorCodeLoopDetected returns a [ErrorCode] of case "loop-detected". +func ErrorCodeLoopDetected() ErrorCode { + var data struct{} + return cm.New[ErrorCode](36, data) +} + +// LoopDetected returns true if [ErrorCode] represents the variant case "loop-detected". +func (self *ErrorCode) LoopDetected() bool { + return self.Tag() == 36 +} + +// ErrorCodeConfigurationError returns a [ErrorCode] of case "configuration-error". +func ErrorCodeConfigurationError() ErrorCode { + var data struct{} + return cm.New[ErrorCode](37, data) +} + +// ConfigurationError returns true if [ErrorCode] represents the variant case "configuration-error". +func (self *ErrorCode) ConfigurationError() bool { + return self.Tag() == 37 +} + +// ErrorCodeInternalError returns a [ErrorCode] of case "internal-error". +// +// This is a catch-all error for anything that doesn't fit cleanly into a +// more specific case. It also includes an optional string for an +// unstructured description of the error. Users should not depend on the +// string for diagnosing errors, as it's not required to be consistent +// between implementations. +func ErrorCodeInternalError(data cm.Option[string]) ErrorCode { + return cm.New[ErrorCode](38, data) +} + +// InternalError returns a non-nil *[cm.Option[string]] if [ErrorCode] represents the variant case "internal-error". +func (self *ErrorCode) InternalError() *cm.Option[string] { + return cm.Case[cm.Option[string]](self, 38) +} + +// HeaderError represents the variant "wasi:http/types@0.2.0#header-error". +// +// This type enumerates the different kinds of errors that may occur when +// setting or appending to a `fields` resource. +// +// variant header-error { +// invalid-syntax, +// forbidden, +// immutable, +// } +type HeaderError uint8 + +const ( + // This error indicates that a `field-key` or `field-value` was + // syntactically invalid when used with an operation that sets headers in a + // `fields`. + HeaderErrorInvalidSyntax HeaderError = iota + + // This error indicates that a forbidden `field-key` was used when trying + // to set a header in a `fields`. + HeaderErrorForbidden + + // This error indicates that the operation on the `fields` was not + // permitted because the fields are immutable. + HeaderErrorImmutable +) + +var stringsHeaderError = [3]string{ + "invalid-syntax", + "forbidden", + "immutable", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e HeaderError) String() string { + return stringsHeaderError[e] +} + +// FieldKey represents the string "wasi:http/types@0.2.0#field-key". +// +// Field keys are always strings. +// +// type field-key = string +type FieldKey string + +// FieldValue represents the list "wasi:http/types@0.2.0#field-value". +// +// Field values should always be ASCII strings. However, in +// reality, HTTP implementations often have to interpret malformed values, +// so they are provided as a list of bytes. +// +// type field-value = list +type FieldValue cm.List[uint8] + +// Fields represents the imported resource "wasi:http/types@0.2.0#fields". +// +// This following block defines the `fields` resource which corresponds to +// HTTP standard Fields. Fields are a common representation used for both +// Headers and Trailers. +// +// A `fields` may be mutable or immutable. A `fields` created using the +// constructor, `from-list`, or `clone` will be mutable, but a `fields` +// resource given by other means (including, but not limited to, +// `incoming-request.headers`, `outgoing-request.headers`) might be be +// immutable. In an immutable fields, the `set`, `append`, and `delete` +// operations will fail with `header-error.immutable`. +// +// resource fields +type Fields cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "fields". +// +// Drops a resource handle. +// +//go:nosplit +func (self Fields) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FieldsResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]fields +//go:noescape +func wasmimport_FieldsResourceDrop(self0 uint32) + +// NewFields represents the imported constructor for resource "fields". +// +// Construct an empty HTTP Fields. +// +// The resulting `fields` is mutable. +// +// constructor() +// +//go:nosplit +func NewFields() (result Fields) { + result0 := wasmimport_NewFields() + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [constructor]fields +//go:noescape +func wasmimport_NewFields() (result0 uint32) + +// FieldsFromList represents the imported static function "from-list". +// +// Construct an HTTP Fields. +// +// The resulting `fields` is mutable. +// +// The list represents each key-value pair in the Fields. Keys +// which have multiple values are represented by multiple entries in this +// list with the same key. +// +// The tuple is a pair of the field key, represented as a string, and +// Value, represented as a list of bytes. In a valid Fields, all keys +// and values are valid UTF-8 strings. However, values are not always +// well-formed, so they are represented as a raw list of bytes. +// +// An error result will be returned if any header or value was +// syntactically invalid, or if a header was forbidden. +// +// from-list: static func(entries: list>) -> result +// +//go:nosplit +func FieldsFromList(entries cm.List[cm.Tuple[FieldKey, FieldValue]]) (result cm.Result[Fields, Fields, HeaderError]) { + entries0, entries1 := cm.LowerList(entries) + wasmimport_FieldsFromList((*cm.Tuple[FieldKey, FieldValue])(entries0), (uint32)(entries1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [static]fields.from-list +//go:noescape +func wasmimport_FieldsFromList(entries0 *cm.Tuple[FieldKey, FieldValue], entries1 uint32, result *cm.Result[Fields, Fields, HeaderError]) + +// Append represents the imported method "append". +// +// Append a value for a key. Does not change or delete any existing +// values for that key. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +// +// append: func(name: field-key, value: field-value) -> result<_, header-error> +// +//go:nosplit +func (self Fields) Append(name FieldKey, value FieldValue) (result cm.Result[HeaderError, struct{}, HeaderError]) { + self0 := cm.Reinterpret[uint32](self) + name0, name1 := cm.LowerString(name) + value0, value1 := cm.LowerList(value) + wasmimport_FieldsAppend((uint32)(self0), (*uint8)(name0), (uint32)(name1), (*uint8)(value0), (uint32)(value1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.append +//go:noescape +func wasmimport_FieldsAppend(self0 uint32, name0 *uint8, name1 uint32, value0 *uint8, value1 uint32, result *cm.Result[HeaderError, struct{}, HeaderError]) + +// Clone represents the imported method "clone". +// +// Make a deep copy of the Fields. Equivelant in behavior to calling the +// `fields` constructor on the return value of `entries`. The resulting +// `fields` is mutable. +// +// clone: func() -> fields +// +//go:nosplit +func (self Fields) Clone() (result Fields) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_FieldsClone((uint32)(self0)) + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.clone +//go:noescape +func wasmimport_FieldsClone(self0 uint32) (result0 uint32) + +// Delete represents the imported method "delete". +// +// Delete all values for a key. Does nothing if no values for the key +// exist. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +// +// delete: func(name: field-key) -> result<_, header-error> +// +//go:nosplit +func (self Fields) Delete(name FieldKey) (result cm.Result[HeaderError, struct{}, HeaderError]) { + self0 := cm.Reinterpret[uint32](self) + name0, name1 := cm.LowerString(name) + wasmimport_FieldsDelete((uint32)(self0), (*uint8)(name0), (uint32)(name1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.delete +//go:noescape +func wasmimport_FieldsDelete(self0 uint32, name0 *uint8, name1 uint32, result *cm.Result[HeaderError, struct{}, HeaderError]) + +// Entries represents the imported method "entries". +// +// Retrieve the full set of keys and values in the Fields. Like the +// constructor, the list represents each key-value pair. +// +// The outer list represents each key-value pair in the Fields. Keys +// which have multiple values are represented by multiple entries in this +// list with the same key. +// +// entries: func() -> list> +// +//go:nosplit +func (self Fields) Entries() (result cm.List[cm.Tuple[FieldKey, FieldValue]]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FieldsEntries((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.entries +//go:noescape +func wasmimport_FieldsEntries(self0 uint32, result *cm.List[cm.Tuple[FieldKey, FieldValue]]) + +// Get represents the imported method "get". +// +// Get all of the values corresponding to a key. If the key is not present +// in this `fields`, an empty list is returned. However, if the key is +// present but empty, this is represented by a list with one or more +// empty field-values present. +// +// get: func(name: field-key) -> list +// +//go:nosplit +func (self Fields) Get(name FieldKey) (result cm.List[FieldValue]) { + self0 := cm.Reinterpret[uint32](self) + name0, name1 := cm.LowerString(name) + wasmimport_FieldsGet((uint32)(self0), (*uint8)(name0), (uint32)(name1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.get +//go:noescape +func wasmimport_FieldsGet(self0 uint32, name0 *uint8, name1 uint32, result *cm.List[FieldValue]) + +// Has represents the imported method "has". +// +// Returns `true` when the key is present in this `fields`. If the key is +// syntactically invalid, `false` is returned. +// +// has: func(name: field-key) -> bool +// +//go:nosplit +func (self Fields) Has(name FieldKey) (result bool) { + self0 := cm.Reinterpret[uint32](self) + name0, name1 := cm.LowerString(name) + result0 := wasmimport_FieldsHas((uint32)(self0), (*uint8)(name0), (uint32)(name1)) + result = cm.U32ToBool((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.has +//go:noescape +func wasmimport_FieldsHas(self0 uint32, name0 *uint8, name1 uint32) (result0 uint32) + +// Set represents the imported method "set". +// +// Set all of the values for a key. Clears any existing values for that +// key, if they have been set. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +// +// set: func(name: field-key, value: list) -> result<_, header-error> +// +//go:nosplit +func (self Fields) Set(name FieldKey, value cm.List[FieldValue]) (result cm.Result[HeaderError, struct{}, HeaderError]) { + self0 := cm.Reinterpret[uint32](self) + name0, name1 := cm.LowerString(name) + value0, value1 := cm.LowerList(value) + wasmimport_FieldsSet((uint32)(self0), (*uint8)(name0), (uint32)(name1), (*FieldValue)(value0), (uint32)(value1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]fields.set +//go:noescape +func wasmimport_FieldsSet(self0 uint32, name0 *uint8, name1 uint32, value0 *FieldValue, value1 uint32, result *cm.Result[HeaderError, struct{}, HeaderError]) + +// IncomingRequest represents the imported resource "wasi:http/types@0.2.0#incoming-request". +// +// Represents an incoming HTTP Request. +// +// resource incoming-request +type IncomingRequest cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "incoming-request". +// +// Drops a resource handle. +// +//go:nosplit +func (self IncomingRequest) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-request +//go:noescape +func wasmimport_IncomingRequestResourceDrop(self0 uint32) + +// Authority represents the imported method "authority". +// +// Returns the authority from the request, if it was present. +// +// authority: func() -> option +// +//go:nosplit +func (self IncomingRequest) Authority() (result cm.Option[string]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestAuthority((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.authority +//go:noescape +func wasmimport_IncomingRequestAuthority(self0 uint32, result *cm.Option[string]) + +// Consume represents the imported method "consume". +// +// Gives the `incoming-body` associated with this request. Will only +// return success at most once, and subsequent calls will return error. +// +// consume: func() -> result +// +//go:nosplit +func (self IncomingRequest) Consume() (result cm.Result[IncomingBody, IncomingBody, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestConsume((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.consume +//go:noescape +func wasmimport_IncomingRequestConsume(self0 uint32, result *cm.Result[IncomingBody, IncomingBody, struct{}]) + +// Headers represents the imported method "headers". +// +// Get the `headers` associated with the request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// The `headers` returned are a child resource: it must be dropped before +// the parent `incoming-request` is dropped. Dropping this +// `incoming-request` before all children are dropped will trap. +// +// headers: func() -> headers +// +//go:nosplit +func (self IncomingRequest) Headers() (result Fields) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_IncomingRequestHeaders((uint32)(self0)) + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.headers +//go:noescape +func wasmimport_IncomingRequestHeaders(self0 uint32) (result0 uint32) + +// Method represents the imported method "method". +// +// Returns the method of the incoming request. +// +// method: func() -> method +// +//go:nosplit +func (self IncomingRequest) Method() (result Method) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestMethod((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.method +//go:noescape +func wasmimport_IncomingRequestMethod(self0 uint32, result *Method) + +// PathWithQuery represents the imported method "path-with-query". +// +// Returns the path with query parameters from the request, as a string. +// +// path-with-query: func() -> option +// +//go:nosplit +func (self IncomingRequest) PathWithQuery() (result cm.Option[string]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestPathWithQuery((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.path-with-query +//go:noescape +func wasmimport_IncomingRequestPathWithQuery(self0 uint32, result *cm.Option[string]) + +// Scheme represents the imported method "scheme". +// +// Returns the protocol scheme from the request. +// +// scheme: func() -> option +// +//go:nosplit +func (self IncomingRequest) Scheme() (result cm.Option[Scheme]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingRequestScheme((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.scheme +//go:noescape +func wasmimport_IncomingRequestScheme(self0 uint32, result *cm.Option[Scheme]) + +// OutgoingRequest represents the imported resource "wasi:http/types@0.2.0#outgoing-request". +// +// Represents an outgoing HTTP Request. +// +// resource outgoing-request +type OutgoingRequest cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "outgoing-request". +// +// Drops a resource handle. +// +//go:nosplit +func (self OutgoingRequest) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-request +//go:noescape +func wasmimport_OutgoingRequestResourceDrop(self0 uint32) + +// NewOutgoingRequest represents the imported constructor for resource "outgoing-request". +// +// Construct a new `outgoing-request` with a default `method` of `GET`, and +// `none` values for `path-with-query`, `scheme`, and `authority`. +// +// * `headers` is the HTTP Headers for the Request. +// +// It is possible to construct, or manipulate with the accessor functions +// below, an `outgoing-request` with an invalid combination of `scheme` +// and `authority`, or `headers` which are not permitted to be sent. +// It is the obligation of the `outgoing-handler.handle` implementation +// to reject invalid constructions of `outgoing-request`. +// +// constructor(headers: headers) +// +//go:nosplit +func NewOutgoingRequest(headers Fields) (result OutgoingRequest) { + headers0 := cm.Reinterpret[uint32](headers) + result0 := wasmimport_NewOutgoingRequest((uint32)(headers0)) + result = cm.Reinterpret[OutgoingRequest]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [constructor]outgoing-request +//go:noescape +func wasmimport_NewOutgoingRequest(headers0 uint32) (result0 uint32) + +// Authority represents the imported method "authority". +// +// Get the HTTP Authority for the Request. A value of `none` may be used +// with Related Schemes which do not require an Authority. The HTTP and +// HTTPS schemes always require an authority. +// +// authority: func() -> option +// +//go:nosplit +func (self OutgoingRequest) Authority() (result cm.Option[string]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestAuthority((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.authority +//go:noescape +func wasmimport_OutgoingRequestAuthority(self0 uint32, result *cm.Option[string]) + +// Body represents the imported method "body". +// +// Returns the resource corresponding to the outgoing Body for this +// Request. +// +// Returns success on the first call: the `outgoing-body` resource for +// this `outgoing-request` can be retrieved at most once. Subsequent +// calls will return error. +// +// body: func() -> result +// +//go:nosplit +func (self OutgoingRequest) Body() (result cm.Result[OutgoingBody, OutgoingBody, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestBody((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.body +//go:noescape +func wasmimport_OutgoingRequestBody(self0 uint32, result *cm.Result[OutgoingBody, OutgoingBody, struct{}]) + +// Headers represents the imported method "headers". +// +// Get the headers associated with the Request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `outgoing-request` is dropped, or its ownership is transfered to +// another component by e.g. `outgoing-handler.handle`. +// +// headers: func() -> headers +// +//go:nosplit +func (self OutgoingRequest) Headers() (result Fields) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_OutgoingRequestHeaders((uint32)(self0)) + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.headers +//go:noescape +func wasmimport_OutgoingRequestHeaders(self0 uint32) (result0 uint32) + +// Method represents the imported method "method". +// +// Get the Method for the Request. +// +// method: func() -> method +// +//go:nosplit +func (self OutgoingRequest) Method() (result Method) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestMethod((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.method +//go:noescape +func wasmimport_OutgoingRequestMethod(self0 uint32, result *Method) + +// PathWithQuery represents the imported method "path-with-query". +// +// Get the combination of the HTTP Path and Query for the Request. +// When `none`, this represents an empty Path and empty Query. +// +// path-with-query: func() -> option +// +//go:nosplit +func (self OutgoingRequest) PathWithQuery() (result cm.Option[string]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestPathWithQuery((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.path-with-query +//go:noescape +func wasmimport_OutgoingRequestPathWithQuery(self0 uint32, result *cm.Option[string]) + +// Scheme represents the imported method "scheme". +// +// Get the HTTP Related Scheme for the Request. When `none`, the +// implementation may choose an appropriate default scheme. +// +// scheme: func() -> option +// +//go:nosplit +func (self OutgoingRequest) Scheme() (result cm.Option[Scheme]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingRequestScheme((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.scheme +//go:noescape +func wasmimport_OutgoingRequestScheme(self0 uint32, result *cm.Option[Scheme]) + +// SetAuthority represents the imported method "set-authority". +// +// Set the HTTP Authority for the Request. A value of `none` may be used +// with Related Schemes which do not require an Authority. The HTTP and +// HTTPS schemes always require an authority. Fails if the string given is +// not a syntactically valid uri authority. +// +// set-authority: func(authority: option) -> result +// +//go:nosplit +func (self OutgoingRequest) SetAuthority(authority cm.Option[string]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + authority0, authority1, authority2 := lower_OptionString(authority) + result0 := wasmimport_OutgoingRequestSetAuthority((uint32)(self0), (uint32)(authority0), (*uint8)(authority1), (uint32)(authority2)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.set-authority +//go:noescape +func wasmimport_OutgoingRequestSetAuthority(self0 uint32, authority0 uint32, authority1 *uint8, authority2 uint32) (result0 uint32) + +// SetMethod represents the imported method "set-method". +// +// Set the Method for the Request. Fails if the string present in a +// `method.other` argument is not a syntactically valid method. +// +// set-method: func(method: method) -> result +// +//go:nosplit +func (self OutgoingRequest) SetMethod(method Method) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + method0, method1, method2 := lower_Method(method) + result0 := wasmimport_OutgoingRequestSetMethod((uint32)(self0), (uint32)(method0), (*uint8)(method1), (uint32)(method2)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.set-method +//go:noescape +func wasmimport_OutgoingRequestSetMethod(self0 uint32, method0 uint32, method1 *uint8, method2 uint32) (result0 uint32) + +// SetPathWithQuery represents the imported method "set-path-with-query". +// +// Set the combination of the HTTP Path and Query for the Request. +// When `none`, this represents an empty Path and empty Query. Fails is the +// string given is not a syntactically valid path and query uri component. +// +// set-path-with-query: func(path-with-query: option) -> result +// +//go:nosplit +func (self OutgoingRequest) SetPathWithQuery(pathWithQuery cm.Option[string]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + pathWithQuery0, pathWithQuery1, pathWithQuery2 := lower_OptionString(pathWithQuery) + result0 := wasmimport_OutgoingRequestSetPathWithQuery((uint32)(self0), (uint32)(pathWithQuery0), (*uint8)(pathWithQuery1), (uint32)(pathWithQuery2)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.set-path-with-query +//go:noescape +func wasmimport_OutgoingRequestSetPathWithQuery(self0 uint32, pathWithQuery0 uint32, pathWithQuery1 *uint8, pathWithQuery2 uint32) (result0 uint32) + +// SetScheme represents the imported method "set-scheme". +// +// Set the HTTP Related Scheme for the Request. When `none`, the +// implementation may choose an appropriate default scheme. Fails if the +// string given is not a syntactically valid uri scheme. +// +// set-scheme: func(scheme: option) -> result +// +//go:nosplit +func (self OutgoingRequest) SetScheme(scheme cm.Option[Scheme]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + scheme0, scheme1, scheme2, scheme3 := lower_OptionScheme(scheme) + result0 := wasmimport_OutgoingRequestSetScheme((uint32)(self0), (uint32)(scheme0), (uint32)(scheme1), (*uint8)(scheme2), (uint32)(scheme3)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.set-scheme +//go:noescape +func wasmimport_OutgoingRequestSetScheme(self0 uint32, scheme0 uint32, scheme1 uint32, scheme2 *uint8, scheme3 uint32) (result0 uint32) + +// RequestOptions represents the imported resource "wasi:http/types@0.2.0#request-options". +// +// Parameters for making an HTTP Request. Each of these parameters is +// currently an optional timeout applicable to the transport layer of the +// HTTP protocol. +// +// These timeouts are separate from any the user may use to bound a +// blocking call to `wasi:io/poll.poll`. +// +// resource request-options +type RequestOptions cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "request-options". +// +// Drops a resource handle. +// +//go:nosplit +func (self RequestOptions) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_RequestOptionsResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]request-options +//go:noescape +func wasmimport_RequestOptionsResourceDrop(self0 uint32) + +// NewRequestOptions represents the imported constructor for resource "request-options". +// +// Construct a default `request-options` value. +// +// constructor() +// +//go:nosplit +func NewRequestOptions() (result RequestOptions) { + result0 := wasmimport_NewRequestOptions() + result = cm.Reinterpret[RequestOptions]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [constructor]request-options +//go:noescape +func wasmimport_NewRequestOptions() (result0 uint32) + +// BetweenBytesTimeout represents the imported method "between-bytes-timeout". +// +// The timeout for receiving subsequent chunks of bytes in the Response +// body stream. +// +// between-bytes-timeout: func() -> option +// +//go:nosplit +func (self RequestOptions) BetweenBytesTimeout() (result cm.Option[monotonicclock.Duration]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_RequestOptionsBetweenBytesTimeout((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.between-bytes-timeout +//go:noescape +func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *cm.Option[monotonicclock.Duration]) + +// ConnectTimeout represents the imported method "connect-timeout". +// +// The timeout for the initial connect to the HTTP Server. +// +// connect-timeout: func() -> option +// +//go:nosplit +func (self RequestOptions) ConnectTimeout() (result cm.Option[monotonicclock.Duration]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_RequestOptionsConnectTimeout((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.connect-timeout +//go:noescape +func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *cm.Option[monotonicclock.Duration]) + +// FirstByteTimeout represents the imported method "first-byte-timeout". +// +// The timeout for receiving the first byte of the Response body. +// +// first-byte-timeout: func() -> option +// +//go:nosplit +func (self RequestOptions) FirstByteTimeout() (result cm.Option[monotonicclock.Duration]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_RequestOptionsFirstByteTimeout((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.first-byte-timeout +//go:noescape +func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *cm.Option[monotonicclock.Duration]) + +// SetBetweenBytesTimeout represents the imported method "set-between-bytes-timeout". +// +// Set the timeout for receiving subsequent chunks of bytes in the Response +// body stream. An error return value indicates that this timeout is not +// supported. +// +// set-between-bytes-timeout: func(duration: option) -> result +// +//go:nosplit +func (self RequestOptions) SetBetweenBytesTimeout(duration cm.Option[monotonicclock.Duration]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + duration0, duration1 := lower_OptionDuration(duration) + result0 := wasmimport_RequestOptionsSetBetweenBytesTimeout((uint32)(self0), (uint32)(duration0), (uint64)(duration1)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.set-between-bytes-timeout +//go:noescape +func wasmimport_RequestOptionsSetBetweenBytesTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) + +// SetConnectTimeout represents the imported method "set-connect-timeout". +// +// Set the timeout for the initial connect to the HTTP Server. An error +// return value indicates that this timeout is not supported. +// +// set-connect-timeout: func(duration: option) -> result +// +//go:nosplit +func (self RequestOptions) SetConnectTimeout(duration cm.Option[monotonicclock.Duration]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + duration0, duration1 := lower_OptionDuration(duration) + result0 := wasmimport_RequestOptionsSetConnectTimeout((uint32)(self0), (uint32)(duration0), (uint64)(duration1)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.set-connect-timeout +//go:noescape +func wasmimport_RequestOptionsSetConnectTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) + +// SetFirstByteTimeout represents the imported method "set-first-byte-timeout". +// +// Set the timeout for receiving the first byte of the Response body. An +// error return value indicates that this timeout is not supported. +// +// set-first-byte-timeout: func(duration: option) -> result +// +//go:nosplit +func (self RequestOptions) SetFirstByteTimeout(duration cm.Option[monotonicclock.Duration]) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + duration0, duration1 := lower_OptionDuration(duration) + result0 := wasmimport_RequestOptionsSetFirstByteTimeout((uint32)(self0), (uint32)(duration0), (uint64)(duration1)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]request-options.set-first-byte-timeout +//go:noescape +func wasmimport_RequestOptionsSetFirstByteTimeout(self0 uint32, duration0 uint32, duration1 uint64) (result0 uint32) + +// ResponseOutparam represents the imported resource "wasi:http/types@0.2.0#response-outparam". +// +// Represents the ability to send an HTTP Response. +// +// This resource is used by the `wasi:http/incoming-handler` interface to +// allow a Response to be sent corresponding to the Request provided as the +// other argument to `incoming-handler.handle`. +// +// resource response-outparam +type ResponseOutparam cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "response-outparam". +// +// Drops a resource handle. +// +//go:nosplit +func (self ResponseOutparam) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ResponseOutparamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]response-outparam +//go:noescape +func wasmimport_ResponseOutparamResourceDrop(self0 uint32) + +// ResponseOutparamSet represents the imported static function "set". +// +// Set the value of the `response-outparam` to either send a response, +// or indicate an error. +// +// This method consumes the `response-outparam` to ensure that it is +// called at most once. If it is never called, the implementation +// will respond with an error. +// +// The user may provide an `error` to `response` to allow the +// implementation determine how to respond with an HTTP error response. +// +// set: static func(param: response-outparam, response: result) +// +//go:nosplit +func ResponseOutparamSet(param ResponseOutparam, response cm.Result[ErrorCodeShape, OutgoingResponse, ErrorCode]) { + param0 := cm.Reinterpret[uint32](param) + response0, response1, response2, response3, response4, response5, response6, response7 := lower_ResultOutgoingResponseErrorCode(response) + wasmimport_ResponseOutparamSet((uint32)(param0), (uint32)(response0), (uint32)(response1), (uint32)(response2), (uint64)(response3), (uint32)(response4), (uint32)(response5), (uint32)(response6), (uint32)(response7)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [static]response-outparam.set +//go:noescape +func wasmimport_ResponseOutparamSet(param0 uint32, response0 uint32, response1 uint32, response2 uint32, response3 uint64, response4 uint32, response5 uint32, response6 uint32, response7 uint32) + +// StatusCode represents the u16 "wasi:http/types@0.2.0#status-code". +// +// This type corresponds to the HTTP standard Status Code. +// +// type status-code = u16 +type StatusCode uint16 + +// IncomingResponse represents the imported resource "wasi:http/types@0.2.0#incoming-response". +// +// Represents an incoming HTTP Response. +// +// resource incoming-response +type IncomingResponse cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "incoming-response". +// +// Drops a resource handle. +// +//go:nosplit +func (self IncomingResponse) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingResponseResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-response +//go:noescape +func wasmimport_IncomingResponseResourceDrop(self0 uint32) + +// Consume represents the imported method "consume". +// +// Returns the incoming body. May be called at most once. Returns error +// if called additional times. +// +// consume: func() -> result +// +//go:nosplit +func (self IncomingResponse) Consume() (result cm.Result[IncomingBody, IncomingBody, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingResponseConsume((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-response.consume +//go:noescape +func wasmimport_IncomingResponseConsume(self0 uint32, result *cm.Result[IncomingBody, IncomingBody, struct{}]) + +// Headers represents the imported method "headers". +// +// Returns the headers from the incoming response. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `incoming-response` is dropped. +// +// headers: func() -> headers +// +//go:nosplit +func (self IncomingResponse) Headers() (result Fields) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_IncomingResponseHeaders((uint32)(self0)) + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-response.headers +//go:noescape +func wasmimport_IncomingResponseHeaders(self0 uint32) (result0 uint32) + +// Status represents the imported method "status". +// +// Returns the status code from the incoming response. +// +// status: func() -> status-code +// +//go:nosplit +func (self IncomingResponse) Status() (result StatusCode) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_IncomingResponseStatus((uint32)(self0)) + result = (StatusCode)((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-response.status +//go:noescape +func wasmimport_IncomingResponseStatus(self0 uint32) (result0 uint32) + +// IncomingBody represents the imported resource "wasi:http/types@0.2.0#incoming-body". +// +// Represents an incoming HTTP Request or Response's Body. +// +// A body has both its contents - a stream of bytes - and a (possibly +// empty) set of trailers, indicating that the full contents of the +// body have been received. This resource represents the contents as +// an `input-stream` and the delivery of trailers as a `future-trailers`, +// and ensures that the user of this interface may only be consuming either +// the body contents or waiting on trailers at any given time. +// +// resource incoming-body +type IncomingBody cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "incoming-body". +// +// Drops a resource handle. +// +//go:nosplit +func (self IncomingBody) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingBodyResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-body +//go:noescape +func wasmimport_IncomingBodyResourceDrop(self0 uint32) + +// IncomingBodyFinish represents the imported static function "finish". +// +// Takes ownership of `incoming-body`, and returns a `future-trailers`. +// This function will trap if the `input-stream` child is still alive. +// +// finish: static func(this: incoming-body) -> future-trailers +// +//go:nosplit +func IncomingBodyFinish(this IncomingBody) (result FutureTrailers) { + this0 := cm.Reinterpret[uint32](this) + result0 := wasmimport_IncomingBodyFinish((uint32)(this0)) + result = cm.Reinterpret[FutureTrailers]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [static]incoming-body.finish +//go:noescape +func wasmimport_IncomingBodyFinish(this0 uint32) (result0 uint32) + +// Stream represents the imported method "stream". +// +// Returns the contents of the body, as a stream of bytes. +// +// Returns success on first call: the stream representing the contents +// can be retrieved at most once. Subsequent calls will return error. +// +// The returned `input-stream` resource is a child: it must be dropped +// before the parent `incoming-body` is dropped, or consumed by +// `incoming-body.finish`. +// +// This invariant ensures that the implementation can determine whether +// the user is consuming the contents of the body, waiting on the +// `future-trailers` to be ready, or neither. This allows for network +// backpressure is to be applied when the user is consuming the body, +// and for that backpressure to not inhibit delivery of the trailers if +// the user does not read the entire body. +// +// %stream: func() -> result +// +//go:nosplit +func (self IncomingBody) Stream() (result cm.Result[streams.InputStream, streams.InputStream, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingBodyStream((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]incoming-body.stream +//go:noescape +func wasmimport_IncomingBodyStream(self0 uint32, result *cm.Result[streams.InputStream, streams.InputStream, struct{}]) + +// FutureTrailers represents the imported resource "wasi:http/types@0.2.0#future-trailers". +// +// Represents a future which may eventaully return trailers, or an error. +// +// In the case that the incoming HTTP Request or Response did not have any +// trailers, this future will resolve to the empty set of trailers once the +// complete Request or Response body has been received. +// +// resource future-trailers +type FutureTrailers cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "future-trailers". +// +// Drops a resource handle. +// +//go:nosplit +func (self FutureTrailers) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FutureTrailersResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]future-trailers +//go:noescape +func wasmimport_FutureTrailersResourceDrop(self0 uint32) + +// Get represents the imported method "get". +// +// Returns the contents of the trailers, or an error which occured, +// once the future is ready. +// +// The outer `option` represents future readiness. Users can wait on this +// `option` to become `some` using the `subscribe` method. +// +// The outer `result` is used to retrieve the trailers or error at most +// once. It will be success on the first call in which the outer option +// is `some`, and error on subsequent calls. +// +// The inner `result` represents that either the HTTP Request or Response +// body, as well as any trailers, were received successfully, or that an +// error occured receiving them. The optional `trailers` indicates whether +// or not trailers were present in the body. +// +// When some `trailers` are returned by this method, the `trailers` +// resource is immutable, and a child. Use of the `set`, `append`, or +// `delete` methods will return an error, and the resource must be +// dropped before the parent `future-trailers` is dropped. +// +// get: func() -> option, error-code>>> +// +//go:nosplit +func (self FutureTrailers) Get() (result cm.Option[cm.Result[cm.Result[ErrorCodeShape, cm.Option[Fields], ErrorCode], cm.Result[ErrorCodeShape, cm.Option[Fields], ErrorCode], struct{}]]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FutureTrailersGet((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]future-trailers.get +//go:noescape +func wasmimport_FutureTrailersGet(self0 uint32, result *cm.Option[cm.Result[cm.Result[ErrorCodeShape, cm.Option[Fields], ErrorCode], cm.Result[ErrorCodeShape, cm.Option[Fields], ErrorCode], struct{}]]) + +// Subscribe represents the imported method "subscribe". +// +// Returns a pollable which becomes ready when either the trailers have +// been received, or an error has occured. When this pollable is ready, +// the `get` method will return `some`. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self FutureTrailers) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_FutureTrailersSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]future-trailers.subscribe +//go:noescape +func wasmimport_FutureTrailersSubscribe(self0 uint32) (result0 uint32) + +// OutgoingResponse represents the imported resource "wasi:http/types@0.2.0#outgoing-response". +// +// Represents an outgoing HTTP Response. +// +// resource outgoing-response +type OutgoingResponse cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "outgoing-response". +// +// Drops a resource handle. +// +//go:nosplit +func (self OutgoingResponse) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingResponseResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-response +//go:noescape +func wasmimport_OutgoingResponseResourceDrop(self0 uint32) + +// NewOutgoingResponse represents the imported constructor for resource "outgoing-response". +// +// Construct an `outgoing-response`, with a default `status-code` of `200`. +// If a different `status-code` is needed, it must be set via the +// `set-status-code` method. +// +// * `headers` is the HTTP Headers for the Response. +// +// constructor(headers: headers) +// +//go:nosplit +func NewOutgoingResponse(headers Fields) (result OutgoingResponse) { + headers0 := cm.Reinterpret[uint32](headers) + result0 := wasmimport_NewOutgoingResponse((uint32)(headers0)) + result = cm.Reinterpret[OutgoingResponse]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [constructor]outgoing-response +//go:noescape +func wasmimport_NewOutgoingResponse(headers0 uint32) (result0 uint32) + +// Body represents the imported method "body". +// +// Returns the resource corresponding to the outgoing Body for this Response. +// +// Returns success on the first call: the `outgoing-body` resource for +// this `outgoing-response` can be retrieved at most once. Subsequent +// calls will return error. +// +// body: func() -> result +// +//go:nosplit +func (self OutgoingResponse) Body() (result cm.Result[OutgoingBody, OutgoingBody, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingResponseBody((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.body +//go:noescape +func wasmimport_OutgoingResponseBody(self0 uint32, result *cm.Result[OutgoingBody, OutgoingBody, struct{}]) + +// Headers represents the imported method "headers". +// +// Get the headers associated with the Request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `outgoing-request` is dropped, or its ownership is transfered to +// another component by e.g. `outgoing-handler.handle`. +// +// headers: func() -> headers +// +//go:nosplit +func (self OutgoingResponse) Headers() (result Fields) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_OutgoingResponseHeaders((uint32)(self0)) + result = cm.Reinterpret[Fields]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.headers +//go:noescape +func wasmimport_OutgoingResponseHeaders(self0 uint32) (result0 uint32) + +// SetStatusCode represents the imported method "set-status-code". +// +// Set the HTTP Status Code for the Response. Fails if the status-code +// given is not a valid http status code. +// +// set-status-code: func(status-code: status-code) -> result +// +//go:nosplit +func (self OutgoingResponse) SetStatusCode(statusCode StatusCode) (result cm.BoolResult) { + self0 := cm.Reinterpret[uint32](self) + statusCode0 := (uint32)(statusCode) + result0 := wasmimport_OutgoingResponseSetStatusCode((uint32)(self0), (uint32)(statusCode0)) + result = (cm.BoolResult)(cm.U32ToBool((uint32)(result0))) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.set-status-code +//go:noescape +func wasmimport_OutgoingResponseSetStatusCode(self0 uint32, statusCode0 uint32) (result0 uint32) + +// StatusCode represents the imported method "status-code". +// +// Get the HTTP Status Code for the Response. +// +// status-code: func() -> status-code +// +//go:nosplit +func (self OutgoingResponse) StatusCode() (result StatusCode) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_OutgoingResponseStatusCode((uint32)(self0)) + result = (StatusCode)((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.status-code +//go:noescape +func wasmimport_OutgoingResponseStatusCode(self0 uint32) (result0 uint32) + +// OutgoingBody represents the imported resource "wasi:http/types@0.2.0#outgoing-body". +// +// Represents an outgoing HTTP Request or Response's Body. +// +// A body has both its contents - a stream of bytes - and a (possibly +// empty) set of trailers, inducating the full contents of the body +// have been sent. This resource represents the contents as an +// `output-stream` child resource, and the completion of the body (with +// optional trailers) with a static function that consumes the +// `outgoing-body` resource, and ensures that the user of this interface +// may not write to the body contents after the body has been finished. +// +// If the user code drops this resource, as opposed to calling the static +// method `finish`, the implementation should treat the body as incomplete, +// and that an error has occured. The implementation should propogate this +// error to the HTTP protocol by whatever means it has available, +// including: corrupting the body on the wire, aborting the associated +// Request, or sending a late status code for the Response. +// +// resource outgoing-body +type OutgoingBody cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "outgoing-body". +// +// Drops a resource handle. +// +//go:nosplit +func (self OutgoingBody) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingBodyResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-body +//go:noescape +func wasmimport_OutgoingBodyResourceDrop(self0 uint32) + +// OutgoingBodyFinish represents the imported static function "finish". +// +// Finalize an outgoing body, optionally providing trailers. This must be +// called to signal that the response is complete. If the `outgoing-body` +// is dropped without calling `outgoing-body.finalize`, the implementation +// should treat the body as corrupted. +// +// Fails if the body's `outgoing-request` or `outgoing-response` was +// constructed with a Content-Length header, and the contents written +// to the body (via `write`) does not match the value given in the +// Content-Length. +// +// finish: static func(this: outgoing-body, trailers: option) -> result<_, +// error-code> +// +//go:nosplit +func OutgoingBodyFinish(this OutgoingBody, trailers cm.Option[Fields]) (result cm.Result[ErrorCode, struct{}, ErrorCode]) { + this0 := cm.Reinterpret[uint32](this) + trailers0, trailers1 := lower_OptionTrailers(trailers) + wasmimport_OutgoingBodyFinish((uint32)(this0), (uint32)(trailers0), (uint32)(trailers1), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [static]outgoing-body.finish +//go:noescape +func wasmimport_OutgoingBodyFinish(this0 uint32, trailers0 uint32, trailers1 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode]) + +// Write represents the imported method "write". +// +// Returns a stream for writing the body contents. +// +// The returned `output-stream` is a child resource: it must be dropped +// before the parent `outgoing-body` resource is dropped (or finished), +// otherwise the `outgoing-body` drop or `finish` will trap. +// +// Returns success on the first call: the `output-stream` resource for +// this `outgoing-body` may be retrieved at most once. Subsequent calls +// will return error. +// +// write: func() -> result +// +//go:nosplit +func (self OutgoingBody) Write() (result cm.Result[streams.OutputStream, streams.OutputStream, struct{}]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingBodyWrite((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-body.write +//go:noescape +func wasmimport_OutgoingBodyWrite(self0 uint32, result *cm.Result[streams.OutputStream, streams.OutputStream, struct{}]) + +// FutureIncomingResponse represents the imported resource "wasi:http/types@0.2.0#future-incoming-response". +// +// Represents a future which may eventaully return an incoming HTTP +// Response, or an error. +// +// This resource is returned by the `wasi:http/outgoing-handler` interface to +// provide the HTTP Response corresponding to the sent Request. +// +// resource future-incoming-response +type FutureIncomingResponse cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "future-incoming-response". +// +// Drops a resource handle. +// +//go:nosplit +func (self FutureIncomingResponse) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FutureIncomingResponseResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [resource-drop]future-incoming-response +//go:noescape +func wasmimport_FutureIncomingResponseResourceDrop(self0 uint32) + +// Get represents the imported method "get". +// +// Returns the incoming HTTP Response, or an error, once one is ready. +// +// The outer `option` represents future readiness. Users can wait on this +// `option` to become `some` using the `subscribe` method. +// +// The outer `result` is used to retrieve the response or error at most +// once. It will be success on the first call in which the outer option +// is `some`, and error on subsequent calls. +// +// The inner `result` represents that either the incoming HTTP Response +// status and headers have recieved successfully, or that an error +// occured. Errors may also occur while consuming the response body, +// but those will be reported by the `incoming-body` and its +// `output-stream` child. +// +// get: func() -> option>> +// +//go:nosplit +func (self FutureIncomingResponse) Get() (result cm.Option[cm.Result[cm.Result[ErrorCodeShape, IncomingResponse, ErrorCode], cm.Result[ErrorCodeShape, IncomingResponse, ErrorCode], struct{}]]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_FutureIncomingResponseGet((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]future-incoming-response.get +//go:noescape +func wasmimport_FutureIncomingResponseGet(self0 uint32, result *cm.Option[cm.Result[cm.Result[ErrorCodeShape, IncomingResponse, ErrorCode], cm.Result[ErrorCodeShape, IncomingResponse, ErrorCode], struct{}]]) + +// Subscribe represents the imported method "subscribe". +// +// Returns a pollable which becomes ready when either the Response has +// been received, or an error has occured. When this pollable is ready, +// the `get` method will return `some`. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self FutureIncomingResponse) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_FutureIncomingResponseSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:http/types@0.2.0 [method]future-incoming-response.subscribe +//go:noescape +func wasmimport_FutureIncomingResponseSubscribe(self0 uint32) (result0 uint32) + +// HTTPErrorCode represents the imported function "http-error-code". +// +// Attempts to extract a http-related `error` from the wasi:io `error` +// provided. +// +// Stream operations which return +// `wasi:io/stream/stream-error::last-operation-failed` have a payload of +// type `wasi:io/error/error` with more information about the operation +// that failed. This payload can be passed through to this function to see +// if there's http-related information about the error to return. +// +// Note that this function is fallible because not all io-errors are +// http-related errors. +// +// http-error-code: func(err: borrow) -> option +// +//go:nosplit +func HTTPErrorCode(err ioerror.Error) (result cm.Option[ErrorCode]) { + err0 := cm.Reinterpret[uint32](err) + wasmimport_HTTPErrorCode((uint32)(err0), &result) + return +} + +//go:wasmimport wasi:http/types@0.2.0 http-error-code +//go:noescape +func wasmimport_HTTPErrorCode(err0 uint32, result *cm.Option[ErrorCode]) diff --git a/tests/go/wasi/bindings/wasi/io/error/empty.s b/tests/go/wasi/bindings/wasi/io/error/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/error/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/io/error/error.wit.go b/tests/go/wasi/bindings/wasi/io/error/error.wit.go new file mode 100644 index 0000000..96d18cf --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/error/error.wit.go @@ -0,0 +1,71 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package ioerror represents the imported interface "wasi:io/error@0.2.0". +package ioerror + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// Error represents the imported resource "wasi:io/error@0.2.0#error". +// +// A resource which represents some error information. +// +// The only method provided by this resource is `to-debug-string`, +// which provides some human-readable information about the error. +// +// In the `wasi:io` package, this resource is returned through the +// `wasi:io/streams/stream-error` type. +// +// To provide more specific error information, other interfaces may +// provide functions to further "downcast" this error into more specific +// error information. For example, `error`s returned in streams derived +// from filesystem types to be described using the filesystem's own +// error-code type, using the function +// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter +// `borrow` and returns +// `option`. +// +// The set of functions which can "downcast" an `error` into a more +// concrete type is open. +// +// resource error +type Error cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "error". +// +// Drops a resource handle. +// +//go:nosplit +func (self Error) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ErrorResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:io/error@0.2.0 [resource-drop]error +//go:noescape +func wasmimport_ErrorResourceDrop(self0 uint32) + +// ToDebugString represents the imported method "to-debug-string". +// +// Returns a string that is suitable to assist humans in debugging +// this error. +// +// WARNING: The returned string should not be consumed mechanically! +// It may change across platforms, hosts, or other implementation +// details. Parsing this string is a major platform-compatibility +// hazard. +// +// to-debug-string: func() -> string +// +//go:nosplit +func (self Error) ToDebugString() (result string) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ErrorToDebugString((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:io/error@0.2.0 [method]error.to-debug-string +//go:noescape +func wasmimport_ErrorToDebugString(self0 uint32, result *string) diff --git a/tests/go/wasi/bindings/wasi/io/poll/empty.s b/tests/go/wasi/bindings/wasi/io/poll/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/poll/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/io/poll/poll.wit.go b/tests/go/wasi/bindings/wasi/io/poll/poll.wit.go new file mode 100644 index 0000000..ba22e54 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/poll/poll.wit.go @@ -0,0 +1,108 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package poll represents the imported interface "wasi:io/poll@0.2.0". +// +// A poll API intended to let users wait for I/O events on multiple handles +// at once. +package poll + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// Pollable represents the imported resource "wasi:io/poll@0.2.0#pollable". +// +// `pollable` represents a single I/O event which may be ready, or not. +// +// resource pollable +type Pollable cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "pollable". +// +// Drops a resource handle. +// +//go:nosplit +func (self Pollable) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_PollableResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:io/poll@0.2.0 [resource-drop]pollable +//go:noescape +func wasmimport_PollableResourceDrop(self0 uint32) + +// Block represents the imported method "block". +// +// `block` returns immediately if the pollable is ready, and otherwise +// blocks until ready. +// +// This function is equivalent to calling `poll.poll` on a list +// containing only this pollable. +// +// block: func() +// +//go:nosplit +func (self Pollable) Block() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_PollableBlock((uint32)(self0)) + return +} + +//go:wasmimport wasi:io/poll@0.2.0 [method]pollable.block +//go:noescape +func wasmimport_PollableBlock(self0 uint32) + +// Ready represents the imported method "ready". +// +// Return the readiness of a pollable. This function never blocks. +// +// Returns `true` when the pollable is ready, and `false` otherwise. +// +// ready: func() -> bool +// +//go:nosplit +func (self Pollable) Ready() (result bool) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_PollableReady((uint32)(self0)) + result = cm.U32ToBool((uint32)(result0)) + return +} + +//go:wasmimport wasi:io/poll@0.2.0 [method]pollable.ready +//go:noescape +func wasmimport_PollableReady(self0 uint32) (result0 uint32) + +// Poll represents the imported function "poll". +// +// Poll for completion on a set of pollables. +// +// This function takes a list of pollables, which identify I/O sources of +// interest, and waits until one or more of the events is ready for I/O. +// +// The result `list` contains one or more indices of handles in the +// argument list that is ready for I/O. +// +// If the list contains more elements than can be indexed with a `u32` +// value, this function traps. +// +// A timeout can be implemented by adding a pollable from the +// wasi-clocks API to the list. +// +// This function does not return a `result`; polling in itself does not +// do any I/O so it doesn't fail. If any of the I/O sources identified by +// the pollables has an error, it is indicated by marking the source as +// being reaedy for I/O. +// +// poll: func(in: list>) -> list +// +//go:nosplit +func Poll(in cm.List[Pollable]) (result cm.List[uint32]) { + in0, in1 := cm.LowerList(in) + wasmimport_Poll((*Pollable)(in0), (uint32)(in1), &result) + return +} + +//go:wasmimport wasi:io/poll@0.2.0 poll +//go:noescape +func wasmimport_Poll(in0 *Pollable, in1 uint32, result *cm.List[uint32]) diff --git a/tests/go/wasi/bindings/wasi/io/streams/abi.go b/tests/go/wasi/bindings/wasi/io/streams/abi.go new file mode 100644 index 0000000..5f15002 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/streams/abi.go @@ -0,0 +1,12 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package streams + +import ( + "unsafe" +) + +// StreamErrorShape is used for storage in variant or result types. +type StreamErrorShape struct { + shape [unsafe.Sizeof(StreamError{})]byte +} diff --git a/tests/go/wasi/bindings/wasi/io/streams/empty.s b/tests/go/wasi/bindings/wasi/io/streams/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/streams/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/io/streams/streams.wit.go b/tests/go/wasi/bindings/wasi/io/streams/streams.wit.go new file mode 100644 index 0000000..a9f30a7 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/io/streams/streams.wit.go @@ -0,0 +1,519 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package streams represents the imported interface "wasi:io/streams@0.2.0". +// +// WASI I/O is an I/O abstraction API which is currently focused on providing +// stream types. +// +// In the future, the component model is expected to add built-in stream types; +// when it does, they are expected to subsume this API. +package streams + +import ( + ioerror "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/error" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/ydnar/wasm-tools-go/cm" +) + +// StreamError represents the imported variant "wasi:io/streams@0.2.0#stream-error". +// +// An error for input-stream and output-stream operations. +// +// variant stream-error { +// last-operation-failed(error), +// closed, +// } +type StreamError cm.Variant[uint8, ioerror.Error, ioerror.Error] + +// StreamErrorLastOperationFailed returns a [StreamError] of case "last-operation-failed". +// +// The last operation (a write or flush) failed before completion. +// +// More information is available in the `error` payload. +func StreamErrorLastOperationFailed(data ioerror.Error) StreamError { + return cm.New[StreamError](0, data) +} + +// LastOperationFailed returns a non-nil *[ioerror.Error] if [StreamError] represents the variant case "last-operation-failed". +func (self *StreamError) LastOperationFailed() *ioerror.Error { + return cm.Case[ioerror.Error](self, 0) +} + +// StreamErrorClosed returns a [StreamError] of case "closed". +// +// The stream is closed: no more input will be accepted by the +// stream. A closed output-stream will return this error on all +// future operations. +func StreamErrorClosed() StreamError { + var data struct{} + return cm.New[StreamError](1, data) +} + +// Closed returns true if [StreamError] represents the variant case "closed". +func (self *StreamError) Closed() bool { + return self.Tag() == 1 +} + +// InputStream represents the imported resource "wasi:io/streams@0.2.0#input-stream". +// +// An input bytestream. +// +// `input-stream`s are *non-blocking* to the extent practical on underlying +// platforms. I/O operations always return promptly; if fewer bytes are +// promptly available than requested, they return the number of bytes promptly +// available, which could even be zero. To wait for data to be available, +// use the `subscribe` function to obtain a `pollable` which can be polled +// for using `wasi:io/poll`. +// +// resource input-stream +type InputStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "input-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self InputStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_InputStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [resource-drop]input-stream +//go:noescape +func wasmimport_InputStreamResourceDrop(self0 uint32) + +// BlockingRead represents the imported method "blocking-read". +// +// Read bytes from a stream, after blocking until at least one byte can +// be read. Except for blocking, behavior is identical to `read`. +// +// blocking-read: func(len: u64) -> result, stream-error> +// +//go:nosplit +func (self InputStream) BlockingRead(len_ uint64) (result cm.Result[cm.List[uint8], cm.List[uint8], StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_InputStreamBlockingRead((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.blocking-read +//go:noescape +func wasmimport_InputStreamBlockingRead(self0 uint32, len0 uint64, result *cm.Result[cm.List[uint8], cm.List[uint8], StreamError]) + +// BlockingSkip represents the imported method "blocking-skip". +// +// Skip bytes from a stream, after blocking until at least one byte +// can be skipped. Except for blocking behavior, identical to `skip`. +// +// blocking-skip: func(len: u64) -> result +// +//go:nosplit +func (self InputStream) BlockingSkip(len_ uint64) (result cm.Result[uint64, uint64, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_InputStreamBlockingSkip((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.blocking-skip +//go:noescape +func wasmimport_InputStreamBlockingSkip(self0 uint32, len0 uint64, result *cm.Result[uint64, uint64, StreamError]) + +// Read represents the imported method "read". +// +// Perform a non-blocking read from the stream. +// +// When the source of a `read` is binary data, the bytes from the source +// are returned verbatim. When the source of a `read` is known to the +// implementation to be text, bytes containing the UTF-8 encoding of the +// text are returned. +// +// This function returns a list of bytes containing the read data, +// when successful. The returned list will contain up to `len` bytes; +// it may return fewer than requested, but not more. The list is +// empty when no bytes are available for reading at this time. The +// pollable given by `subscribe` will be ready when more bytes are +// available. +// +// This function fails with a `stream-error` when the operation +// encounters an error, giving `last-operation-failed`, or when the +// stream is closed, giving `closed`. +// +// When the caller gives a `len` of 0, it represents a request to +// read 0 bytes. If the stream is still open, this call should +// succeed and return an empty list, or otherwise fail with `closed`. +// +// The `len` parameter is a `u64`, which could represent a list of u8 which +// is not possible to allocate in wasm32, or not desirable to allocate as +// as a return value by the callee. The callee may return a list of bytes +// less than `len` in size while more bytes are available for reading. +// +// read: func(len: u64) -> result, stream-error> +// +//go:nosplit +func (self InputStream) Read(len_ uint64) (result cm.Result[cm.List[uint8], cm.List[uint8], StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_InputStreamRead((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.read +//go:noescape +func wasmimport_InputStreamRead(self0 uint32, len0 uint64, result *cm.Result[cm.List[uint8], cm.List[uint8], StreamError]) + +// Skip represents the imported method "skip". +// +// Skip bytes from a stream. Returns number of bytes skipped. +// +// Behaves identical to `read`, except instead of returning a list +// of bytes, returns the number of bytes consumed from the stream. +// +// skip: func(len: u64) -> result +// +//go:nosplit +func (self InputStream) Skip(len_ uint64) (result cm.Result[uint64, uint64, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_InputStreamSkip((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.skip +//go:noescape +func wasmimport_InputStreamSkip(self0 uint32, len0 uint64, result *cm.Result[uint64, uint64, StreamError]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once either the specified stream +// has bytes available to read or the other end of the stream has been +// closed. +// The created `pollable` is a child resource of the `input-stream`. +// Implementations may trap if the `input-stream` is dropped before +// all derived `pollable`s created with this function are dropped. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self InputStream) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_InputStreamSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.subscribe +//go:noescape +func wasmimport_InputStreamSubscribe(self0 uint32) (result0 uint32) + +// OutputStream represents the imported resource "wasi:io/streams@0.2.0#output-stream". +// +// An output bytestream. +// +// `output-stream`s are *non-blocking* to the extent practical on +// underlying platforms. Except where specified otherwise, I/O operations also +// always return promptly, after the number of bytes that can be written +// promptly, which could even be zero. To wait for the stream to be ready to +// accept data, the `subscribe` function to obtain a `pollable` which can be +// polled for using `wasi:io/poll`. +// +// resource output-stream +type OutputStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "output-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self OutputStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutputStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [resource-drop]output-stream +//go:noescape +func wasmimport_OutputStreamResourceDrop(self0 uint32) + +// BlockingFlush represents the imported method "blocking-flush". +// +// Request to flush buffered output, and block until flush completes +// and stream is ready for writing again. +// +// blocking-flush: func() -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) BlockingFlush() (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutputStreamBlockingFlush((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.blocking-flush +//go:noescape +func wasmimport_OutputStreamBlockingFlush(self0 uint32, result *cm.Result[StreamError, struct{}, StreamError]) + +// BlockingSplice represents the imported method "blocking-splice". +// +// Read from one stream and write to another, with blocking. +// +// This is similar to `splice`, except that it blocks until the +// `output-stream` is ready for writing, and the `input-stream` +// is ready for reading, before performing the `splice`. +// +// blocking-splice: func(src: borrow, len: u64) -> result +// +//go:nosplit +func (self OutputStream) BlockingSplice(src InputStream, len_ uint64) (result cm.Result[uint64, uint64, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + src0 := cm.Reinterpret[uint32](src) + len0 := (uint64)(len_) + wasmimport_OutputStreamBlockingSplice((uint32)(self0), (uint32)(src0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.blocking-splice +//go:noescape +func wasmimport_OutputStreamBlockingSplice(self0 uint32, src0 uint32, len0 uint64, result *cm.Result[uint64, uint64, StreamError]) + +// BlockingWriteAndFlush represents the imported method "blocking-write-and-flush". +// +// Perform a write of up to 4096 bytes, and then flush the stream. Block +// until all of these operations are complete, or an error occurs. +// +// This is a convenience wrapper around the use of `check-write`, +// `subscribe`, `write`, and `flush`, and is implemented with the +// following pseudo-code: +// +// let pollable = this.subscribe(); +// while !contents.is_empty() { +// // Wait for the stream to become writable +// pollable.block(); +// let Ok(n) = this.check-write(); // eliding error handling +// let len = min(n, contents.len()); +// let (chunk, rest) = contents.split_at(len); +// this.write(chunk ); // eliding error handling +// contents = rest; +// } +// this.flush(); +// // Wait for completion of `flush` +// pollable.block(); +// // Check for any errors that arose during `flush` +// let _ = this.check-write(); // eliding error handling +// +// blocking-write-and-flush: func(contents: list) -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) BlockingWriteAndFlush(contents cm.List[uint8]) (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + contents0, contents1 := cm.LowerList(contents) + wasmimport_OutputStreamBlockingWriteAndFlush((uint32)(self0), (*uint8)(contents0), (uint32)(contents1), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.blocking-write-and-flush +//go:noescape +func wasmimport_OutputStreamBlockingWriteAndFlush(self0 uint32, contents0 *uint8, contents1 uint32, result *cm.Result[StreamError, struct{}, StreamError]) + +// BlockingWriteZeroesAndFlush represents the imported method "blocking-write-zeroes-and-flush". +// +// Perform a write of up to 4096 zeroes, and then flush the stream. +// Block until all of these operations are complete, or an error +// occurs. +// +// This is a convenience wrapper around the use of `check-write`, +// `subscribe`, `write-zeroes`, and `flush`, and is implemented with +// the following pseudo-code: +// +// let pollable = this.subscribe(); +// while num_zeroes != 0 { +// // Wait for the stream to become writable +// pollable.block(); +// let Ok(n) = this.check-write(); // eliding error handling +// let len = min(n, num_zeroes); +// this.write-zeroes(len); // eliding error handling +// num_zeroes -= len; +// } +// this.flush(); +// // Wait for completion of `flush` +// pollable.block(); +// // Check for any errors that arose during `flush` +// let _ = this.check-write(); // eliding error handling +// +// blocking-write-zeroes-and-flush: func(len: u64) -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) BlockingWriteZeroesAndFlush(len_ uint64) (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_OutputStreamBlockingWriteZeroesAndFlush((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.blocking-write-zeroes-and-flush +//go:noescape +func wasmimport_OutputStreamBlockingWriteZeroesAndFlush(self0 uint32, len0 uint64, result *cm.Result[StreamError, struct{}, StreamError]) + +// CheckWrite represents the imported method "check-write". +// +// Check readiness for writing. This function never blocks. +// +// Returns the number of bytes permitted for the next call to `write`, +// or an error. Calling `write` with more bytes than this function has +// permitted will trap. +// +// When this function returns 0 bytes, the `subscribe` pollable will +// become ready when this function will report at least 1 byte, or an +// error. +// +// check-write: func() -> result +// +//go:nosplit +func (self OutputStream) CheckWrite() (result cm.Result[uint64, uint64, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutputStreamCheckWrite((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.check-write +//go:noescape +func wasmimport_OutputStreamCheckWrite(self0 uint32, result *cm.Result[uint64, uint64, StreamError]) + +// Flush represents the imported method "flush". +// +// Request to flush buffered output. This function never blocks. +// +// This tells the output-stream that the caller intends any buffered +// output to be flushed. the output which is expected to be flushed +// is all that has been passed to `write` prior to this call. +// +// Upon calling this function, the `output-stream` will not accept any +// writes (`check-write` will return `ok(0)`) until the flush has +// completed. The `subscribe` pollable will become ready when the +// flush has completed and the stream can accept more writes. +// +// flush: func() -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) Flush() (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutputStreamFlush((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.flush +//go:noescape +func wasmimport_OutputStreamFlush(self0 uint32, result *cm.Result[StreamError, struct{}, StreamError]) + +// Splice represents the imported method "splice". +// +// Read from one stream and write to another. +// +// The behavior of splice is equivelant to: +// 1. calling `check-write` on the `output-stream` +// 2. calling `read` on the `input-stream` with the smaller of the +// `check-write` permitted length and the `len` provided to `splice` +// 3. calling `write` on the `output-stream` with that read data. +// +// Any error reported by the call to `check-write`, `read`, or +// `write` ends the splice and reports that error. +// +// This function returns the number of bytes transferred; it may be less +// than `len`. +// +// splice: func(src: borrow, len: u64) -> result +// +//go:nosplit +func (self OutputStream) Splice(src InputStream, len_ uint64) (result cm.Result[uint64, uint64, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + src0 := cm.Reinterpret[uint32](src) + len0 := (uint64)(len_) + wasmimport_OutputStreamSplice((uint32)(self0), (uint32)(src0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.splice +//go:noescape +func wasmimport_OutputStreamSplice(self0 uint32, src0 uint32, len0 uint64, result *cm.Result[uint64, uint64, StreamError]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once the output-stream +// is ready for more writing, or an error has occured. When this +// pollable is ready, `check-write` will return `ok(n)` with n>0, or an +// error. +// +// If the stream is closed, this pollable is always ready immediately. +// +// The created `pollable` is a child resource of the `output-stream`. +// Implementations may trap if the `output-stream` is dropped before +// all derived `pollable`s created with this function are dropped. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self OutputStream) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_OutputStreamSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.subscribe +//go:noescape +func wasmimport_OutputStreamSubscribe(self0 uint32) (result0 uint32) + +// Write represents the imported method "write". +// +// Perform a write. This function never blocks. +// +// When the destination of a `write` is binary data, the bytes from +// `contents` are written verbatim. When the destination of a `write` is +// known to the implementation to be text, the bytes of `contents` are +// transcoded from UTF-8 into the encoding of the destination and then +// written. +// +// Precondition: check-write gave permit of Ok(n) and contents has a +// length of less than or equal to n. Otherwise, this function will trap. +// +// returns Err(closed) without writing if the stream has closed since +// the last call to check-write provided a permit. +// +// write: func(contents: list) -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) Write(contents cm.List[uint8]) (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + contents0, contents1 := cm.LowerList(contents) + wasmimport_OutputStreamWrite((uint32)(self0), (*uint8)(contents0), (uint32)(contents1), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.write +//go:noescape +func wasmimport_OutputStreamWrite(self0 uint32, contents0 *uint8, contents1 uint32, result *cm.Result[StreamError, struct{}, StreamError]) + +// WriteZeroes represents the imported method "write-zeroes". +// +// Write zeroes to a stream. +// +// This should be used precisely like `write` with the exact same +// preconditions (must use check-write first), but instead of +// passing a list of bytes, you simply pass the number of zero-bytes +// that should be written. +// +// write-zeroes: func(len: u64) -> result<_, stream-error> +// +//go:nosplit +func (self OutputStream) WriteZeroes(len_ uint64) (result cm.Result[StreamError, struct{}, StreamError]) { + self0 := cm.Reinterpret[uint32](self) + len0 := (uint64)(len_) + wasmimport_OutputStreamWriteZeroes((uint32)(self0), (uint64)(len0), &result) + return +} + +//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.write-zeroes +//go:noescape +func wasmimport_OutputStreamWriteZeroes(self0 uint32, len0 uint64, result *cm.Result[StreamError, struct{}, StreamError]) diff --git a/tests/go/wasi/bindings/wasi/random/insecure-seed/empty.s b/tests/go/wasi/bindings/wasi/random/insecure-seed/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/insecure-seed/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/random/insecure-seed/insecure-seed.wit.go b/tests/go/wasi/bindings/wasi/random/insecure-seed/insecure-seed.wit.go new file mode 100644 index 0000000..3b8f33c --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/insecure-seed/insecure-seed.wit.go @@ -0,0 +1,41 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package insecureseed represents the imported interface "wasi:random/insecure-seed@0.2.0". +// +// The insecure-seed interface for seeding hash-map DoS resistance. +// +// It is intended to be portable at least between Unix-family platforms and +// Windows. +package insecureseed + +// InsecureSeed represents the imported function "insecure-seed". +// +// Return a 128-bit value that may contain a pseudo-random value. +// +// The returned value is not required to be computed from a CSPRNG, and may +// even be entirely deterministic. Host implementations are encouraged to +// provide pseudo-random values to any program exposed to +// attacker-controlled content, to enable DoS protection built into many +// languages' hash-map implementations. +// +// This function is intended to only be called once, by a source language +// to initialize Denial Of Service (DoS) protection in its hash-map +// implementation. +// +// # Expected future evolution +// +// This will likely be changed to a value import, to prevent it from being +// called multiple times and potentially used for purposes other than DoS +// protection. +// +// insecure-seed: func() -> tuple +// +//go:nosplit +func InsecureSeed() (result [2]uint64) { + wasmimport_InsecureSeed(&result) + return +} + +//go:wasmimport wasi:random/insecure-seed@0.2.0 insecure-seed +//go:noescape +func wasmimport_InsecureSeed(result *[2]uint64) diff --git a/tests/go/wasi/bindings/wasi/random/insecure/empty.s b/tests/go/wasi/bindings/wasi/random/insecure/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/insecure/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/random/insecure/insecure.wit.go b/tests/go/wasi/bindings/wasi/random/insecure/insecure.wit.go new file mode 100644 index 0000000..4f813bf --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/insecure/insecure.wit.go @@ -0,0 +1,57 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package insecure represents the imported interface "wasi:random/insecure@0.2.0". +// +// The insecure interface for insecure pseudo-random numbers. +// +// It is intended to be portable at least between Unix-family platforms and +// Windows. +package insecure + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetInsecureRandomBytes represents the imported function "get-insecure-random-bytes". +// +// Return `len` insecure pseudo-random bytes. +// +// This function is not cryptographically secure. Do not use it for +// anything related to security. +// +// There are no requirements on the values of the returned bytes, however +// implementations are encouraged to return evenly distributed values with +// a long period. +// +// get-insecure-random-bytes: func(len: u64) -> list +// +//go:nosplit +func GetInsecureRandomBytes(len_ uint64) (result cm.List[uint8]) { + len0 := (uint64)(len_) + wasmimport_GetInsecureRandomBytes((uint64)(len0), &result) + return +} + +//go:wasmimport wasi:random/insecure@0.2.0 get-insecure-random-bytes +//go:noescape +func wasmimport_GetInsecureRandomBytes(len0 uint64, result *cm.List[uint8]) + +// GetInsecureRandomU64 represents the imported function "get-insecure-random-u64". +// +// Return an insecure pseudo-random `u64` value. +// +// This function returns the same type of pseudo-random data as +// `get-insecure-random-bytes`, represented as a `u64`. +// +// get-insecure-random-u64: func() -> u64 +// +//go:nosplit +func GetInsecureRandomU64() (result uint64) { + result0 := wasmimport_GetInsecureRandomU64() + result = (uint64)((uint64)(result0)) + return +} + +//go:wasmimport wasi:random/insecure@0.2.0 get-insecure-random-u64 +//go:noescape +func wasmimport_GetInsecureRandomU64() (result0 uint64) diff --git a/tests/go/wasi/bindings/wasi/random/random/empty.s b/tests/go/wasi/bindings/wasi/random/random/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/random/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/random/random/random.wit.go b/tests/go/wasi/bindings/wasi/random/random/random.wit.go new file mode 100644 index 0000000..04b2319 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/random/random/random.wit.go @@ -0,0 +1,61 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package random represents the imported interface "wasi:random/random@0.2.0". +// +// WASI Random is a random data API. +// +// It is intended to be portable at least between Unix-family platforms and +// Windows. +package random + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// GetRandomBytes represents the imported function "get-random-bytes". +// +// Return `len` cryptographically-secure random or pseudo-random bytes. +// +// This function must produce data at least as cryptographically secure and +// fast as an adequately seeded cryptographically-secure pseudo-random +// number generator (CSPRNG). It must not block, from the perspective of +// the calling program, under any circumstances, including on the first +// request and on requests for numbers of bytes. The returned data must +// always be unpredictable. +// +// This function must always return fresh data. Deterministic environments +// must omit this function, rather than implementing it with deterministic +// data. +// +// get-random-bytes: func(len: u64) -> list +// +//go:nosplit +func GetRandomBytes(len_ uint64) (result cm.List[uint8]) { + len0 := (uint64)(len_) + wasmimport_GetRandomBytes((uint64)(len0), &result) + return +} + +//go:wasmimport wasi:random/random@0.2.0 get-random-bytes +//go:noescape +func wasmimport_GetRandomBytes(len0 uint64, result *cm.List[uint8]) + +// GetRandomU64 represents the imported function "get-random-u64". +// +// Return a cryptographically-secure random or pseudo-random `u64` value. +// +// This function returns the same type of data as `get-random-bytes`, +// represented as a `u64`. +// +// get-random-u64: func() -> u64 +// +//go:nosplit +func GetRandomU64() (result uint64) { + result0 := wasmimport_GetRandomU64() + result = (uint64)((uint64)(result0)) + return +} + +//go:wasmimport wasi:random/random@0.2.0 get-random-u64 +//go:noescape +func wasmimport_GetRandomU64() (result0 uint64) diff --git a/tests/go/wasi/bindings/wasi/sockets/instance-network/empty.s b/tests/go/wasi/bindings/wasi/sockets/instance-network/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/instance-network/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/instance-network/instance-network.wit.go b/tests/go/wasi/bindings/wasi/sockets/instance-network/instance-network.wit.go new file mode 100644 index 0000000..d7d2abf --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/instance-network/instance-network.wit.go @@ -0,0 +1,28 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package instancenetwork represents the imported interface "wasi:sockets/instance-network@0.2.0". +// +// This interface provides a value-export of the default network handle.. +package instancenetwork + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" +) + +// InstanceNetwork represents the imported function "instance-network". +// +// Get a handle to the default network. +// +// instance-network: func() -> network +// +//go:nosplit +func InstanceNetwork() (result network.Network) { + result0 := wasmimport_InstanceNetwork() + result = cm.Reinterpret[network.Network]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/instance-network@0.2.0 instance-network +//go:noescape +func wasmimport_InstanceNetwork() (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/abi.go b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/abi.go new file mode 100644 index 0000000..b1f7c7d --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/abi.go @@ -0,0 +1,14 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package ipnamelookup + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// OptionIPAddressShape is used for storage in variant or result types. +type OptionIPAddressShape struct { + shape [unsafe.Sizeof(cm.Option[network.IPAddress]{})]byte +} diff --git a/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/empty.s b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go new file mode 100644 index 0000000..e0b167d --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/ip-name-lookup/ip-name-lookup.wit.go @@ -0,0 +1,121 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package ipnamelookup represents the imported interface "wasi:sockets/ip-name-lookup@0.2.0". +package ipnamelookup + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" +) + +// ResolveAddressStream represents the imported resource "wasi:sockets/ip-name-lookup@0.2.0#resolve-address-stream". +// +// resource resolve-address-stream +type ResolveAddressStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "resolve-address-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self ResolveAddressStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ResolveAddressStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/ip-name-lookup@0.2.0 [resource-drop]resolve-address-stream +//go:noescape +func wasmimport_ResolveAddressStreamResourceDrop(self0 uint32) + +// ResolveNextAddress represents the imported method "resolve-next-address". +// +// Returns the next address from the resolver. +// +// This function should be called multiple times. On each call, it will +// return the next address in connection order preference. If all +// addresses have been exhausted, this function returns `none`. +// +// This function never returns IPv4-mapped IPv6 addresses. +// +// # Typical errors +// - `name-unresolvable`: Name does not exist or has no suitable associated +// IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) +// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. +// (EAI_AGAIN) +// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. +// (EAI_FAIL) +// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) +// +// resolve-next-address: func() -> result, error-code> +// +//go:nosplit +func (self ResolveAddressStream) ResolveNextAddress() (result cm.Result[OptionIPAddressShape, cm.Option[network.IPAddress], network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_ResolveAddressStreamResolveNextAddress((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/ip-name-lookup@0.2.0 [method]resolve-address-stream.resolve-next-address +//go:noescape +func wasmimport_ResolveAddressStreamResolveNextAddress(self0 uint32, result *cm.Result[OptionIPAddressShape, cm.Option[network.IPAddress], network.ErrorCode]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once the stream is ready for I/O. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self ResolveAddressStream) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_ResolveAddressStreamSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/ip-name-lookup@0.2.0 [method]resolve-address-stream.subscribe +//go:noescape +func wasmimport_ResolveAddressStreamSubscribe(self0 uint32) (result0 uint32) + +// ResolveAddresses represents the imported function "resolve-addresses". +// +// Resolve an internet host name to a list of IP addresses. +// +// Unicode domain names are automatically converted to ASCII using IDNA encoding. +// If the input is an IP address string, the address is parsed and returned +// as-is without making any external requests. +// +// See the wasi-socket proposal README.md for a comparison with getaddrinfo. +// +// This function never blocks. It either immediately fails or immediately +// returns successfully with a `resolve-address-stream` that can be used +// to (asynchronously) fetch the results. +// +// # Typical errors +// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. +// +// # References: +// - +// - +// - +// - +// +// resolve-addresses: func(network: borrow, name: string) -> result +// +//go:nosplit +func ResolveAddresses(network_ network.Network, name string) (result cm.Result[ResolveAddressStream, ResolveAddressStream, network.ErrorCode]) { + network0 := cm.Reinterpret[uint32](network_) + name0, name1 := cm.LowerString(name) + wasmimport_ResolveAddresses((uint32)(network0), (*uint8)(name0), (uint32)(name1), &result) + return +} + +//go:wasmimport wasi:sockets/ip-name-lookup@0.2.0 resolve-addresses +//go:noescape +func wasmimport_ResolveAddresses(network0 uint32, name0 *uint8, name1 uint32, result *cm.Result[ResolveAddressStream, ResolveAddressStream, network.ErrorCode]) diff --git a/tests/go/wasi/bindings/wasi/sockets/network/abi.go b/tests/go/wasi/bindings/wasi/sockets/network/abi.go new file mode 100644 index 0000000..54820be --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/network/abi.go @@ -0,0 +1,12 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package network + +import ( + "unsafe" +) + +// IPv6SocketAddressShape is used for storage in variant or result types. +type IPv6SocketAddressShape struct { + shape [unsafe.Sizeof(IPv6SocketAddress{})]byte +} diff --git a/tests/go/wasi/bindings/wasi/sockets/network/empty.s b/tests/go/wasi/bindings/wasi/sockets/network/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/network/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/network/network.wit.go b/tests/go/wasi/bindings/wasi/sockets/network/network.wit.go new file mode 100644 index 0000000..4597e24 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/network/network.wit.go @@ -0,0 +1,315 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package network represents the imported interface "wasi:sockets/network@0.2.0". +package network + +import ( + "github.com/ydnar/wasm-tools-go/cm" +) + +// Network represents the imported resource "wasi:sockets/network@0.2.0#network". +// +// An opaque resource that represents access to (a subset of) the network. +// This enables context-based security for networking. +// There is no need for this to map 1:1 to a physical network interface. +// +// resource network +type Network cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "network". +// +// Drops a resource handle. +// +//go:nosplit +func (self Network) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_NetworkResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/network@0.2.0 [resource-drop]network +//go:noescape +func wasmimport_NetworkResourceDrop(self0 uint32) + +// ErrorCode represents the enum "wasi:sockets/network@0.2.0#error-code". +// +// Error codes. +// +// In theory, every API can return any error code. +// In practice, API's typically only return the errors documented per API +// combined with a couple of errors that are always possible: +// - `unknown` +// - `access-denied` +// - `not-supported` +// - `out-of-memory` +// - `concurrency-conflict` +// +// See each individual API for what the POSIX equivalents are. They sometimes differ +// per API. +// +// enum error-code { +// unknown, +// access-denied, +// not-supported, +// invalid-argument, +// out-of-memory, +// timeout, +// concurrency-conflict, +// not-in-progress, +// would-block, +// invalid-state, +// new-socket-limit, +// address-not-bindable, +// address-in-use, +// remote-unreachable, +// connection-refused, +// connection-reset, +// connection-aborted, +// datagram-too-large, +// name-unresolvable, +// temporary-resolver-failure, +// permanent-resolver-failure +// } +type ErrorCode uint8 + +const ( + // Unknown error + ErrorCodeUnknown ErrorCode = iota + + // Access denied. + // + // POSIX equivalent: EACCES, EPERM + ErrorCodeAccessDenied + + // The operation is not supported. + // + // POSIX equivalent: EOPNOTSUPP + ErrorCodeNotSupported + + // One of the arguments is invalid. + // + // POSIX equivalent: EINVAL + ErrorCodeInvalidArgument + + // Not enough memory to complete the operation. + // + // POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY + ErrorCodeOutOfMemory + + // The operation timed out before it could finish completely. + ErrorCodeTimeout + + // This operation is incompatible with another asynchronous operation that is already + // in progress. + // + // POSIX equivalent: EALREADY + ErrorCodeConcurrencyConflict + + // Trying to finish an asynchronous operation that: + // - has not been started yet, or: + // - was already finished by a previous `finish-*` call. + // + // Note: this is scheduled to be removed when `future`s are natively supported. + ErrorCodeNotInProgress + + // The operation has been aborted because it could not be completed immediately. + // + // Note: this is scheduled to be removed when `future`s are natively supported. + ErrorCodeWouldBlock + + // The operation is not valid in the socket's current state. + ErrorCodeInvalidState + + // A new socket resource could not be created because of a system limit. + ErrorCodeNewSocketLimit + + // A bind operation failed because the provided address is not an address that the + // `network` can bind to. + ErrorCodeAddressNotBindable + + // A bind operation failed because the provided address is already in use or because + // there are no ephemeral ports available. + ErrorCodeAddressInUse + + // The remote address is not reachable + ErrorCodeRemoteUnreachable + + // The TCP connection was forcefully rejected + ErrorCodeConnectionRefused + + // The TCP connection was reset. + ErrorCodeConnectionReset + + // A TCP connection was aborted. + ErrorCodeConnectionAborted + + // The size of a datagram sent to a UDP socket exceeded the maximum + // supported size. + ErrorCodeDatagramTooLarge + + // Name does not exist or has no suitable associated IP addresses. + ErrorCodeNameUnresolvable + + // A temporary failure in name resolution occurred. + ErrorCodeTemporaryResolverFailure + + // A permanent failure in name resolution occurred. + ErrorCodePermanentResolverFailure +) + +var stringsErrorCode = [21]string{ + "unknown", + "access-denied", + "not-supported", + "invalid-argument", + "out-of-memory", + "timeout", + "concurrency-conflict", + "not-in-progress", + "would-block", + "invalid-state", + "new-socket-limit", + "address-not-bindable", + "address-in-use", + "remote-unreachable", + "connection-refused", + "connection-reset", + "connection-aborted", + "datagram-too-large", + "name-unresolvable", + "temporary-resolver-failure", + "permanent-resolver-failure", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e ErrorCode) String() string { + return stringsErrorCode[e] +} + +// IPAddressFamily represents the enum "wasi:sockets/network@0.2.0#ip-address-family". +// +// enum ip-address-family { +// ipv4, +// ipv6 +// } +type IPAddressFamily uint8 + +const ( + // Similar to `AF_INET` in POSIX. + IPAddressFamilyIPv4 IPAddressFamily = iota + + // Similar to `AF_INET6` in POSIX. + IPAddressFamilyIPv6 +) + +var stringsIPAddressFamily = [2]string{ + "ipv4", + "ipv6", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e IPAddressFamily) String() string { + return stringsIPAddressFamily[e] +} + +// IPv4Address represents the tuple "wasi:sockets/network@0.2.0#ipv4-address". +// +// type ipv4-address = tuple +type IPv4Address [4]uint8 + +// IPv6Address represents the tuple "wasi:sockets/network@0.2.0#ipv6-address". +// +// type ipv6-address = tuple +type IPv6Address [8]uint16 + +// IPAddress represents the variant "wasi:sockets/network@0.2.0#ip-address". +// +// variant ip-address { +// ipv4(ipv4-address), +// ipv6(ipv6-address), +// } +type IPAddress cm.Variant[uint8, IPv6Address, IPv6Address] + +// IPAddressIPv4 returns a [IPAddress] of case "ipv4". +func IPAddressIPv4(data IPv4Address) IPAddress { + return cm.New[IPAddress](0, data) +} + +// IPv4 returns a non-nil *[IPv4Address] if [IPAddress] represents the variant case "ipv4". +func (self *IPAddress) IPv4() *IPv4Address { + return cm.Case[IPv4Address](self, 0) +} + +// IPAddressIPv6 returns a [IPAddress] of case "ipv6". +func IPAddressIPv6(data IPv6Address) IPAddress { + return cm.New[IPAddress](1, data) +} + +// IPv6 returns a non-nil *[IPv6Address] if [IPAddress] represents the variant case "ipv6". +func (self *IPAddress) IPv6() *IPv6Address { + return cm.Case[IPv6Address](self, 1) +} + +// IPv4SocketAddress represents the record "wasi:sockets/network@0.2.0#ipv4-socket-address". +// +// record ipv4-socket-address { +// port: u16, +// address: ipv4-address, +// } +type IPv4SocketAddress struct { + // sin_port + Port uint16 + + // sin_addr + Address IPv4Address +} + +// IPv6SocketAddress represents the record "wasi:sockets/network@0.2.0#ipv6-socket-address". +// +// record ipv6-socket-address { +// port: u16, +// flow-info: u32, +// address: ipv6-address, +// scope-id: u32, +// } +type IPv6SocketAddress struct { + // sin6_port + Port uint16 + + // sin6_flowinfo + FlowInfo uint32 + + // sin6_addr + Address IPv6Address + + // sin6_scope_id + ScopeID uint32 +} + +// IPSocketAddress represents the variant "wasi:sockets/network@0.2.0#ip-socket-address". +// +// variant ip-socket-address { +// ipv4(ipv4-socket-address), +// ipv6(ipv6-socket-address), +// } +type IPSocketAddress cm.Variant[uint8, IPv6SocketAddressShape, IPv6SocketAddress] + +// IPSocketAddressIPv4 returns a [IPSocketAddress] of case "ipv4". +func IPSocketAddressIPv4(data IPv4SocketAddress) IPSocketAddress { + return cm.New[IPSocketAddress](0, data) +} + +// IPv4 returns a non-nil *[IPv4SocketAddress] if [IPSocketAddress] represents the variant case "ipv4". +func (self *IPSocketAddress) IPv4() *IPv4SocketAddress { + return cm.Case[IPv4SocketAddress](self, 0) +} + +// IPSocketAddressIPv6 returns a [IPSocketAddress] of case "ipv6". +func IPSocketAddressIPv6(data IPv6SocketAddress) IPSocketAddress { + return cm.New[IPSocketAddress](1, data) +} + +// IPv6 returns a non-nil *[IPv6SocketAddress] if [IPSocketAddress] represents the variant case "ipv6". +func (self *IPSocketAddress) IPv6() *IPv6SocketAddress { + return cm.Case[IPv6SocketAddress](self, 1) +} diff --git a/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/empty.s b/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go b/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go new file mode 100644 index 0000000..e53a343 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/tcp-create-socket/tcp-create-socket.wit.go @@ -0,0 +1,52 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package tcpcreatesocket represents the imported interface "wasi:sockets/tcp-create-socket@0.2.0". +package tcpcreatesocket + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/tcp" + "github.com/ydnar/wasm-tools-go/cm" +) + +// CreateTCPSocket represents the imported function "create-tcp-socket". +// +// Create a new TCP socket. +// +// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. +// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. +// +// This function does not require a network capability handle. This is considered +// to be safe because +// at time of creation, the socket is not bound to any `network` yet. Up to the moment +// `bind`/`connect` +// is called, the socket is effectively an in-memory configuration object, unable +// to communicate with the outside world. +// +// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous +// operations. +// +// # Typical errors +// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) +// - `new-socket-limit`: The new socket resource could not be created because of +// a system limit. (EMFILE, ENFILE) +// +// # References +// - +// - +// - +// - +// +// create-tcp-socket: func(address-family: ip-address-family) -> result +// +//go:nosplit +func CreateTCPSocket(addressFamily network.IPAddressFamily) (result cm.Result[tcp.TCPSocket, tcp.TCPSocket, network.ErrorCode]) { + addressFamily0 := (uint32)(addressFamily) + wasmimport_CreateTCPSocket((uint32)(addressFamily0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp-create-socket@0.2.0 create-tcp-socket +//go:noescape +func wasmimport_CreateTCPSocket(addressFamily0 uint32, result *cm.Result[tcp.TCPSocket, tcp.TCPSocket, network.ErrorCode]) diff --git a/tests/go/wasi/bindings/wasi/sockets/tcp/abi.go b/tests/go/wasi/bindings/wasi/sockets/tcp/abi.go new file mode 100644 index 0000000..efc8727 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/tcp/abi.go @@ -0,0 +1,86 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package tcp + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// TupleTCPSocketInputStreamOutputStreamShape is used for storage in variant or result types. +type TupleTCPSocketInputStreamOutputStreamShape struct { + shape [unsafe.Sizeof(cm.Tuple3[TCPSocket, streams.InputStream, streams.OutputStream]{})]byte +} + +// TupleInputStreamOutputStreamShape is used for storage in variant or result types. +type TupleInputStreamOutputStreamShape struct { + shape [unsafe.Sizeof(cm.Tuple[streams.InputStream, streams.OutputStream]{})]byte +} + +// IPSocketAddressShape is used for storage in variant or result types. +type IPSocketAddressShape struct { + shape [unsafe.Sizeof(network.IPSocketAddress{})]byte +} + +func lower_IPv4Address(v network.IPv4Address) (f0 uint32, f1 uint32, f2 uint32, f3 uint32) { + f0 = (uint32)(v[0]) + f1 = (uint32)(v[1]) + f2 = (uint32)(v[2]) + f3 = (uint32)(v[3]) + return +} + +func lower_IPv4SocketAddress(v network.IPv4SocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32) { + f0 = (uint32)(v.Port) + f1, f2, f3, f4 = lower_IPv4Address(v.Address) + return +} + +func lower_IPv6Address(v network.IPv6Address) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32) { + f0 = (uint32)(v[0]) + f1 = (uint32)(v[1]) + f2 = (uint32)(v[2]) + f3 = (uint32)(v[3]) + f4 = (uint32)(v[4]) + f5 = (uint32)(v[5]) + f6 = (uint32)(v[6]) + f7 = (uint32)(v[7]) + return +} + +func lower_IPv6SocketAddress(v network.IPv6SocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32, f8 uint32, f9 uint32, f10 uint32) { + f0 = (uint32)(v.Port) + f1 = (uint32)(v.FlowInfo) + f2, f3, f4, f5, f6, f7, f8, f9 = lower_IPv6Address(v.Address) + f10 = (uint32)(v.ScopeID) + return +} + +func lower_IPSocketAddress(v network.IPSocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32, f8 uint32, f9 uint32, f10 uint32, f11 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 0: // ipv4 + v1, v2, v3, v4, v5 := lower_IPv4SocketAddress(*v.IPv4()) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 1: // ipv6 + v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 := lower_IPv6SocketAddress(*v.IPv6()) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + f6 = (uint32)(v6) + f7 = (uint32)(v7) + f8 = (uint32)(v8) + f9 = (uint32)(v9) + f10 = (uint32)(v10) + f11 = (uint32)(v11) + } + return +} diff --git a/tests/go/wasi/bindings/wasi/sockets/tcp/empty.s b/tests/go/wasi/bindings/wasi/sockets/tcp/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/tcp/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/tcp/tcp.wit.go b/tests/go/wasi/bindings/wasi/sockets/tcp/tcp.wit.go new file mode 100644 index 0000000..e17ae40 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/tcp/tcp.wit.go @@ -0,0 +1,848 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package tcp represents the imported interface "wasi:sockets/tcp@0.2.0". +package tcp + +import ( + monotonicclock "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/clocks/monotonic-clock" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/streams" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" +) + +// ShutdownType represents the enum "wasi:sockets/tcp@0.2.0#shutdown-type". +// +// enum shutdown-type { +// receive, +// send, +// both +// } +type ShutdownType uint8 + +const ( + // Similar to `SHUT_RD` in POSIX. + ShutdownTypeReceive ShutdownType = iota + + // Similar to `SHUT_WR` in POSIX. + ShutdownTypeSend + + // Similar to `SHUT_RDWR` in POSIX. + ShutdownTypeBoth +) + +var stringsShutdownType = [3]string{ + "receive", + "send", + "both", +} + +// String implements [fmt.Stringer], returning the enum case name of e. +func (e ShutdownType) String() string { + return stringsShutdownType[e] +} + +// TCPSocket represents the imported resource "wasi:sockets/tcp@0.2.0#tcp-socket". +// +// A TCP socket resource. +// +// The socket can be in one of the following states: +// - `unbound` +// - `bind-in-progress` +// - `bound` (See note below) +// - `listen-in-progress` +// - `listening` +// - `connect-in-progress` +// - `connected` +// - `closed` +// See +// for a more information. +// +// Note: Except where explicitly mentioned, whenever this documentation uses +// the term "bound" without backticks it actually means: in the `bound` state *or +// higher*. +// (i.e. `bound`, `listen-in-progress`, `listening`, `connect-in-progress` or `connected`) +// +// In addition to the general error codes documented on the +// `network::error-code` type, TCP socket methods may always return +// `error(invalid-state)` when in the `closed` state. +// +// resource tcp-socket +type TCPSocket cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "tcp-socket". +// +// Drops a resource handle. +// +//go:nosplit +func (self TCPSocket) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [resource-drop]tcp-socket +//go:noescape +func wasmimport_TCPSocketResourceDrop(self0 uint32) + +// Accept represents the imported method "accept". +// +// Accept a new client socket. +// +// The returned socket is bound and in the `connected` state. The following properties +// are inherited from the listener socket: +// - `address-family` +// - `keep-alive-enabled` +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// - `hop-limit` +// - `receive-buffer-size` +// - `send-buffer-size` +// +// On success, this function returns the newly accepted client socket along with +// a pair of streams that can be used to read & write to the connection. +// +// # Typical errors +// - `invalid-state`: Socket is not in the `listening` state. (EINVAL) +// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN) +// - `connection-aborted`: An incoming connection was pending, but was terminated +// by the client before this listener could accept it. (ECONNABORTED) +// - `new-socket-limit`: The new socket resource could not be created because of +// a system limit. (EMFILE, ENFILE) +// +// # References +// - +// - +// - +// - +// +// accept: func() -> result, error-code> +// +//go:nosplit +func (self TCPSocket) Accept() (result cm.Result[TupleTCPSocketInputStreamOutputStreamShape, cm.Tuple3[TCPSocket, streams.InputStream, streams.OutputStream], network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketAccept((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.accept +//go:noescape +func wasmimport_TCPSocketAccept(self0 uint32, result *cm.Result[TupleTCPSocketInputStreamOutputStreamShape, cm.Tuple3[TCPSocket, streams.InputStream, streams.OutputStream], network.ErrorCode]) + +// AddressFamily represents the imported method "address-family". +// +// Whether this is a IPv4 or IPv6 socket. +// +// Equivalent to the SO_DOMAIN socket option. +// +// address-family: func() -> ip-address-family +// +//go:nosplit +func (self TCPSocket) AddressFamily() (result network.IPAddressFamily) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_TCPSocketAddressFamily((uint32)(self0)) + result = (network.IPAddressFamily)((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.address-family +//go:noescape +func wasmimport_TCPSocketAddressFamily(self0 uint32) (result0 uint32) + +// FinishBind represents the imported method "finish-bind". +// +// finish-bind: func() -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) FinishBind() (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketFinishBind((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.finish-bind +//go:noescape +func wasmimport_TCPSocketFinishBind(self0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// FinishConnect represents the imported method "finish-connect". +// +// finish-connect: func() -> result, error-code> +// +//go:nosplit +func (self TCPSocket) FinishConnect() (result cm.Result[TupleInputStreamOutputStreamShape, cm.Tuple[streams.InputStream, streams.OutputStream], network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketFinishConnect((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.finish-connect +//go:noescape +func wasmimport_TCPSocketFinishConnect(self0 uint32, result *cm.Result[TupleInputStreamOutputStreamShape, cm.Tuple[streams.InputStream, streams.OutputStream], network.ErrorCode]) + +// FinishListen represents the imported method "finish-listen". +// +// finish-listen: func() -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) FinishListen() (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketFinishListen((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.finish-listen +//go:noescape +func wasmimport_TCPSocketFinishListen(self0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// HopLimit represents the imported method "hop-limit". +// +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +// +// hop-limit: func() -> result +// +//go:nosplit +func (self TCPSocket) HopLimit() (result cm.Result[uint8, uint8, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketHopLimit((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.hop-limit +//go:noescape +func wasmimport_TCPSocketHopLimit(self0 uint32, result *cm.Result[uint8, uint8, network.ErrorCode]) + +// IsListening represents the imported method "is-listening". +// +// Whether the socket is in the `listening` state. +// +// Equivalent to the SO_ACCEPTCONN socket option. +// +// is-listening: func() -> bool +// +//go:nosplit +func (self TCPSocket) IsListening() (result bool) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_TCPSocketIsListening((uint32)(self0)) + result = cm.U32ToBool((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.is-listening +//go:noescape +func wasmimport_TCPSocketIsListening(self0 uint32) (result0 uint32) + +// KeepAliveCount represents the imported method "keep-alive-count". +// +// The maximum amount of keepalive packets TCP should send before aborting the connection. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// I.e. after setting a value, reading the same setting back may return a different +// value. +// +// Equivalent to the TCP_KEEPCNT socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +// +// keep-alive-count: func() -> result +// +//go:nosplit +func (self TCPSocket) KeepAliveCount() (result cm.Result[uint32, uint32, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketKeepAliveCount((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.keep-alive-count +//go:noescape +func wasmimport_TCPSocketKeepAliveCount(self0 uint32, result *cm.Result[uint32, uint32, network.ErrorCode]) + +// KeepAliveEnabled represents the imported method "keep-alive-enabled". +// +// Enables or disables keepalive. +// +// The keepalive behavior can be adjusted using: +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// These properties can be configured while `keep-alive-enabled` is false, but only +// come into effect when `keep-alive-enabled` is true. +// +// Equivalent to the SO_KEEPALIVE socket option. +// +// keep-alive-enabled: func() -> result +// +//go:nosplit +func (self TCPSocket) KeepAliveEnabled() (result cm.Result[bool, bool, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketKeepAliveEnabled((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.keep-alive-enabled +//go:noescape +func wasmimport_TCPSocketKeepAliveEnabled(self0 uint32, result *cm.Result[bool, bool, network.ErrorCode]) + +// KeepAliveIdleTime represents the imported method "keep-alive-idle-time". +// +// Amount of time the connection has to be idle before TCP starts sending keepalive +// packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// I.e. after setting a value, reading the same setting back may return a different +// value. +// +// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +// +// keep-alive-idle-time: func() -> result +// +//go:nosplit +func (self TCPSocket) KeepAliveIdleTime() (result cm.Result[uint64, monotonicclock.Duration, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketKeepAliveIdleTime((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.keep-alive-idle-time +//go:noescape +func wasmimport_TCPSocketKeepAliveIdleTime(self0 uint32, result *cm.Result[uint64, monotonicclock.Duration, network.ErrorCode]) + +// KeepAliveInterval represents the imported method "keep-alive-interval". +// +// The time between keepalive packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// I.e. after setting a value, reading the same setting back may return a different +// value. +// +// Equivalent to the TCP_KEEPINTVL socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +// +// keep-alive-interval: func() -> result +// +//go:nosplit +func (self TCPSocket) KeepAliveInterval() (result cm.Result[uint64, monotonicclock.Duration, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketKeepAliveInterval((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.keep-alive-interval +//go:noescape +func wasmimport_TCPSocketKeepAliveInterval(self0 uint32, result *cm.Result[uint64, monotonicclock.Duration, network.ErrorCode]) + +// LocalAddress represents the imported method "local-address". +// +// Get the bound local address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `local-address` to return `invalid-state` when the +// socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +// +// local-address: func() -> result +// +//go:nosplit +func (self TCPSocket) LocalAddress() (result cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketLocalAddress((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.local-address +//go:noescape +func wasmimport_TCPSocketLocalAddress(self0 uint32, result *cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) + +// ReceiveBufferSize represents the imported method "receive-buffer-size". +// +// The kernel buffer space reserved for sends/receives on this socket. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// I.e. after setting a value, reading the same setting back may return a different +// value. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +// +// receive-buffer-size: func() -> result +// +//go:nosplit +func (self TCPSocket) ReceiveBufferSize() (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketReceiveBufferSize((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.receive-buffer-size +//go:noescape +func wasmimport_TCPSocketReceiveBufferSize(self0 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// RemoteAddress represents the imported method "remote-address". +// +// Get the remote address. +// +// # Typical errors +// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +// +// remote-address: func() -> result +// +//go:nosplit +func (self TCPSocket) RemoteAddress() (result cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketRemoteAddress((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.remote-address +//go:noescape +func wasmimport_TCPSocketRemoteAddress(self0 uint32, result *cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) + +// SendBufferSize represents the imported method "send-buffer-size". +// +// send-buffer-size: func() -> result +// +//go:nosplit +func (self TCPSocket) SendBufferSize() (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketSendBufferSize((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.send-buffer-size +//go:noescape +func wasmimport_TCPSocketSendBufferSize(self0 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// SetHopLimit represents the imported method "set-hop-limit". +// +// set-hop-limit: func(value: u8) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetHopLimit(value uint8) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint32)(value) + wasmimport_TCPSocketSetHopLimit((uint32)(self0), (uint32)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-hop-limit +//go:noescape +func wasmimport_TCPSocketSetHopLimit(self0 uint32, value0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetKeepAliveCount represents the imported method "set-keep-alive-count". +// +// set-keep-alive-count: func(value: u32) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetKeepAliveCount(value uint32) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint32)(value) + wasmimport_TCPSocketSetKeepAliveCount((uint32)(self0), (uint32)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-keep-alive-count +//go:noescape +func wasmimport_TCPSocketSetKeepAliveCount(self0 uint32, value0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetKeepAliveEnabled represents the imported method "set-keep-alive-enabled". +// +// set-keep-alive-enabled: func(value: bool) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetKeepAliveEnabled(value bool) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := cm.BoolToU32(value) + wasmimport_TCPSocketSetKeepAliveEnabled((uint32)(self0), (uint32)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-keep-alive-enabled +//go:noescape +func wasmimport_TCPSocketSetKeepAliveEnabled(self0 uint32, value0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetKeepAliveIdleTime represents the imported method "set-keep-alive-idle-time". +// +// set-keep-alive-idle-time: func(value: duration) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetKeepAliveIdleTime(value monotonicclock.Duration) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_TCPSocketSetKeepAliveIdleTime((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-keep-alive-idle-time +//go:noescape +func wasmimport_TCPSocketSetKeepAliveIdleTime(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetKeepAliveInterval represents the imported method "set-keep-alive-interval". +// +// set-keep-alive-interval: func(value: duration) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetKeepAliveInterval(value monotonicclock.Duration) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_TCPSocketSetKeepAliveInterval((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-keep-alive-interval +//go:noescape +func wasmimport_TCPSocketSetKeepAliveInterval(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetListenBacklogSize represents the imported method "set-listen-backlog-size". +// +// Hints the desired listen queue size. Implementations are free to ignore this. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// +// # Typical errors +// - `not-supported`: (set) The platform does not support changing the backlog +// size after the initial listen. +// - `invalid-argument`: (set) The provided value was 0. +// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` +// state. +// +// set-listen-backlog-size: func(value: u64) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetListenBacklogSize(value uint64) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_TCPSocketSetListenBacklogSize((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-listen-backlog-size +//go:noescape +func wasmimport_TCPSocketSetListenBacklogSize(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetReceiveBufferSize represents the imported method "set-receive-buffer-size". +// +// set-receive-buffer-size: func(value: u64) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetReceiveBufferSize(value uint64) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_TCPSocketSetReceiveBufferSize((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-receive-buffer-size +//go:noescape +func wasmimport_TCPSocketSetReceiveBufferSize(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetSendBufferSize represents the imported method "set-send-buffer-size". +// +// set-send-buffer-size: func(value: u64) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) SetSendBufferSize(value uint64) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_TCPSocketSetSendBufferSize((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.set-send-buffer-size +//go:noescape +func wasmimport_TCPSocketSetSendBufferSize(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// Shutdown represents the imported method "shutdown". +// +// Initiate a graceful shutdown. +// +// - `receive`: The socket is not expecting to receive any data from +// the peer. The `input-stream` associated with this socket will be +// closed. Any data still in the receive queue at time of calling +// this method will be discarded. +// - `send`: The socket has no more data to send to the peer. The `output-stream` +// associated with this socket will be closed and a FIN packet will be sent. +// - `both`: Same effect as `receive` & `send` combined. +// +// This function is idempotent. Shutting a down a direction more than once +// has no effect and returns `ok`. +// +// The shutdown function does not close (drop) the socket. +// +// # Typical errors +// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) +// +// # References +// - +// - +// - +// - +// +// shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) Shutdown(shutdownType ShutdownType) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + shutdownType0 := (uint32)(shutdownType) + wasmimport_TCPSocketShutdown((uint32)(self0), (uint32)(shutdownType0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.shutdown +//go:noescape +func wasmimport_TCPSocketShutdown(self0 uint32, shutdownType0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// StartBind represents the imported method "start-bind". +// +// Bind the socket to a specific network on the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the +// implementation to decide which +// network interface(s) to bind to. +// If the TCP/UDP port is zero, the socket will be bound to a random free port. +// +// Bind can be attempted multiple times on the same socket, even with +// different arguments on each iteration. But never concurrently and +// only as long as the previous bind failed. Once a bind succeeds, the +// binding can't be changed anymore. +// +// # Typical errors +// - `invalid-argument`: The `local-address` has the wrong address family. +// (EAFNOSUPPORT, EFAULT on Windows) +// - `invalid-argument`: `local-address` is not a unicast address. (EINVAL) +// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. +// (EINVAL) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS +// on Windows) +// - `address-in-use`: Address is already in use. (EADDRINUSE) +// - `address-not-bindable`: `local-address` is not an address that the `network` +// can bind to. (EADDRNOTAVAIL) +// - `not-in-progress`: A `bind` operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. +// (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// When binding to a non-zero port, this bind operation shouldn't be affected by the +// TIME_WAIT +// state of a recently closed socket on the same local address. In practice this means +// that the SO_REUSEADDR +// socket option should be set implicitly on all platforms, except on Windows where +// this is the default behavior +// and SO_REUSEADDR performs something different entirely. +// +// Unlike in POSIX, in WASI the bind operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `bind` as part of either `start-bind` or `finish-bind`. +// +// # References +// - +// - +// - +// - +// +// start-bind: func(network: borrow, local-address: ip-socket-address) -> +// result<_, error-code> +// +//go:nosplit +func (self TCPSocket) StartBind(network_ network.Network, localAddress network.IPSocketAddress) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + network0 := cm.Reinterpret[uint32](network_) + localAddress0, localAddress1, localAddress2, localAddress3, localAddress4, localAddress5, localAddress6, localAddress7, localAddress8, localAddress9, localAddress10, localAddress11 := lower_IPSocketAddress(localAddress) + wasmimport_TCPSocketStartBind((uint32)(self0), (uint32)(network0), (uint32)(localAddress0), (uint32)(localAddress1), (uint32)(localAddress2), (uint32)(localAddress3), (uint32)(localAddress4), (uint32)(localAddress5), (uint32)(localAddress6), (uint32)(localAddress7), (uint32)(localAddress8), (uint32)(localAddress9), (uint32)(localAddress10), (uint32)(localAddress11), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.start-bind +//go:noescape +func wasmimport_TCPSocketStartBind(self0 uint32, network0 uint32, localAddress0 uint32, localAddress1 uint32, localAddress2 uint32, localAddress3 uint32, localAddress4 uint32, localAddress5 uint32, localAddress6 uint32, localAddress7 uint32, localAddress8 uint32, localAddress9 uint32, localAddress10 uint32, localAddress11 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// StartConnect represents the imported method "start-connect". +// +// Connect to a remote endpoint. +// +// On success: +// - the socket is transitioned into the `connection` state. +// - a pair of streams is returned that can be used to read & write to the connection +// +// After a failed connection attempt, the socket will be in the `closed` +// state and the only valid action left is to `drop` the socket. A single +// socket can not be used to connect more than once. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. +// (EAFNOSUPPORT) +// - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, +// ENETUNREACH on Linux, EAFNOSUPPORT on MacOS) +// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. +// (EINVAL, EADDRNOTAVAIL on Illumos) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY +// (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL +// on Windows) +// - `invalid-argument`: The socket is already attached to a different network. +// The `network` passed to `connect` must be identical to the one passed to `bind`. +// - `invalid-state`: The socket is already in the `connected` state. +// (EISCONN) +// - `invalid-state`: The socket is already in the `listening` state. +// (EOPNOTSUPP, EINVAL on Windows) +// - `timeout`: Connection timed out. (ETIMEDOUT) +// - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED) +// - `connection-reset`: The connection was reset. (ECONNRESET) +// - `connection-aborted`: The connection was aborted. (ECONNABORTED) +// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, +// EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `address-in-use`: Tried to perform an implicit bind, but there were +// no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) +// - `not-in-progress`: A connect operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. +// (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// The POSIX equivalent of `start-connect` is the regular `connect` syscall. +// Because all WASI sockets are non-blocking this is expected to return +// EINPROGRESS, which should be translated to `ok()` in WASI. +// +// The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT` +// with a timeout of 0 on the socket descriptor. Followed by a check for +// the `SO_ERROR` socket option, in case the poll signaled readiness. +// +// # References +// - +// - +// - +// - +// +// start-connect: func(network: borrow, remote-address: ip-socket-address) +// -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) StartConnect(network_ network.Network, remoteAddress network.IPSocketAddress) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + network0 := cm.Reinterpret[uint32](network_) + remoteAddress0, remoteAddress1, remoteAddress2, remoteAddress3, remoteAddress4, remoteAddress5, remoteAddress6, remoteAddress7, remoteAddress8, remoteAddress9, remoteAddress10, remoteAddress11 := lower_IPSocketAddress(remoteAddress) + wasmimport_TCPSocketStartConnect((uint32)(self0), (uint32)(network0), (uint32)(remoteAddress0), (uint32)(remoteAddress1), (uint32)(remoteAddress2), (uint32)(remoteAddress3), (uint32)(remoteAddress4), (uint32)(remoteAddress5), (uint32)(remoteAddress6), (uint32)(remoteAddress7), (uint32)(remoteAddress8), (uint32)(remoteAddress9), (uint32)(remoteAddress10), (uint32)(remoteAddress11), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.start-connect +//go:noescape +func wasmimport_TCPSocketStartConnect(self0 uint32, network0 uint32, remoteAddress0 uint32, remoteAddress1 uint32, remoteAddress2 uint32, remoteAddress3 uint32, remoteAddress4 uint32, remoteAddress5 uint32, remoteAddress6 uint32, remoteAddress7 uint32, remoteAddress8 uint32, remoteAddress9 uint32, remoteAddress10 uint32, remoteAddress11 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// StartListen represents the imported method "start-listen". +// +// Start listening for new connections. +// +// Transitions the socket into the `listening` state. +// +// Unlike POSIX, the socket must already be explicitly bound. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ) +// - `invalid-state`: The socket is already in the `connected` state. +// (EISCONN, EINVAL on BSD) +// - `invalid-state`: The socket is already in the `listening` state. +// - `address-in-use`: Tried to perform an implicit bind, but there were +// no ephemeral ports available. (EADDRINUSE) +// - `not-in-progress`: A listen operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. +// (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// Unlike in POSIX, in WASI the listen operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `listen` as part of either `start-listen` or `finish-listen`. +// +// # References +// - +// - +// - +// - +// +// start-listen: func() -> result<_, error-code> +// +//go:nosplit +func (self TCPSocket) StartListen() (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_TCPSocketStartListen((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.start-listen +//go:noescape +func wasmimport_TCPSocketStartListen(self0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which can be used to poll for, or block on, +// completion of any of the asynchronous operations of this socket. +// +// When `finish-bind`, `finish-listen`, `finish-connect` or `accept` +// return `error(would-block)`, this pollable can be used to wait for +// their success or failure, after which the method can be retried. +// +// The pollable is not limited to the async operation that happens to be +// in progress at the time of calling `subscribe` (if any). Theoretically, +// `subscribe` only has to be called once per socket and can then be +// (re)used for the remainder of the socket's lifetime. +// +// See +// for a more information. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self TCPSocket) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_TCPSocketSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/tcp@0.2.0 [method]tcp-socket.subscribe +//go:noescape +func wasmimport_TCPSocketSubscribe(self0 uint32) (result0 uint32) diff --git a/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/empty.s b/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go b/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go new file mode 100644 index 0000000..a88c8ab --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/udp-create-socket/udp-create-socket.wit.go @@ -0,0 +1,52 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package udpcreatesocket represents the imported interface "wasi:sockets/udp-create-socket@0.2.0". +package udpcreatesocket + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/udp" + "github.com/ydnar/wasm-tools-go/cm" +) + +// CreateUDPSocket represents the imported function "create-udp-socket". +// +// Create a new UDP socket. +// +// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX. +// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. +// +// This function does not require a network capability handle. This is considered +// to be safe because +// at time of creation, the socket is not bound to any `network` yet. Up to the moment +// `bind` is called, +// the socket is effectively an in-memory configuration object, unable to communicate +// with the outside world. +// +// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous +// operations. +// +// # Typical errors +// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) +// - `new-socket-limit`: The new socket resource could not be created because of +// a system limit. (EMFILE, ENFILE) +// +// # References: +// - +// - +// - +// - +// +// create-udp-socket: func(address-family: ip-address-family) -> result +// +//go:nosplit +func CreateUDPSocket(addressFamily network.IPAddressFamily) (result cm.Result[udp.UDPSocket, udp.UDPSocket, network.ErrorCode]) { + addressFamily0 := (uint32)(addressFamily) + wasmimport_CreateUDPSocket((uint32)(addressFamily0), &result) + return +} + +//go:wasmimport wasi:sockets/udp-create-socket@0.2.0 create-udp-socket +//go:noescape +func wasmimport_CreateUDPSocket(addressFamily0 uint32, result *cm.Result[udp.UDPSocket, udp.UDPSocket, network.ErrorCode]) diff --git a/tests/go/wasi/bindings/wasi/sockets/udp/abi.go b/tests/go/wasi/bindings/wasi/sockets/udp/abi.go new file mode 100644 index 0000000..d5f1d36 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/udp/abi.go @@ -0,0 +1,101 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +package udp + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" + "unsafe" +) + +// IPSocketAddressShape is used for storage in variant or result types. +type IPSocketAddressShape struct { + shape [unsafe.Sizeof(network.IPSocketAddress{})]byte +} + +func lower_IPv4Address(v network.IPv4Address) (f0 uint32, f1 uint32, f2 uint32, f3 uint32) { + f0 = (uint32)(v[0]) + f1 = (uint32)(v[1]) + f2 = (uint32)(v[2]) + f3 = (uint32)(v[3]) + return +} + +func lower_IPv4SocketAddress(v network.IPv4SocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32) { + f0 = (uint32)(v.Port) + f1, f2, f3, f4 = lower_IPv4Address(v.Address) + return +} + +func lower_IPv6Address(v network.IPv6Address) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32) { + f0 = (uint32)(v[0]) + f1 = (uint32)(v[1]) + f2 = (uint32)(v[2]) + f3 = (uint32)(v[3]) + f4 = (uint32)(v[4]) + f5 = (uint32)(v[5]) + f6 = (uint32)(v[6]) + f7 = (uint32)(v[7]) + return +} + +func lower_IPv6SocketAddress(v network.IPv6SocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32, f8 uint32, f9 uint32, f10 uint32) { + f0 = (uint32)(v.Port) + f1 = (uint32)(v.FlowInfo) + f2, f3, f4, f5, f6, f7, f8, f9 = lower_IPv6Address(v.Address) + f10 = (uint32)(v.ScopeID) + return +} + +func lower_IPSocketAddress(v network.IPSocketAddress) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32, f8 uint32, f9 uint32, f10 uint32, f11 uint32) { + f0 = (uint32)(v.Tag()) + switch f0 { + case 0: // ipv4 + v1, v2, v3, v4, v5 := lower_IPv4SocketAddress(*v.IPv4()) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + case 1: // ipv6 + v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 := lower_IPv6SocketAddress(*v.IPv6()) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + f6 = (uint32)(v6) + f7 = (uint32)(v7) + f8 = (uint32)(v8) + f9 = (uint32)(v9) + f10 = (uint32)(v10) + f11 = (uint32)(v11) + } + return +} + +// TupleIncomingDatagramStreamOutgoingDatagramStreamShape is used for storage in variant or result types. +type TupleIncomingDatagramStreamOutgoingDatagramStreamShape struct { + shape [unsafe.Sizeof(cm.Tuple[IncomingDatagramStream, OutgoingDatagramStream]{})]byte +} + +func lower_OptionIPSocketAddress(v cm.Option[network.IPSocketAddress]) (f0 uint32, f1 uint32, f2 uint32, f3 uint32, f4 uint32, f5 uint32, f6 uint32, f7 uint32, f8 uint32, f9 uint32, f10 uint32, f11 uint32, f12 uint32) { + some := v.Some() + if some != nil { + f0 = 1 + v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 := lower_IPSocketAddress(*some) + f1 = (uint32)(v1) + f2 = (uint32)(v2) + f3 = (uint32)(v3) + f4 = (uint32)(v4) + f5 = (uint32)(v5) + f6 = (uint32)(v6) + f7 = (uint32)(v7) + f8 = (uint32)(v8) + f9 = (uint32)(v9) + f10 = (uint32)(v10) + f11 = (uint32)(v11) + f12 = (uint32)(v12) + } + return +} diff --git a/tests/go/wasi/bindings/wasi/sockets/udp/empty.s b/tests/go/wasi/bindings/wasi/sockets/udp/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/udp/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/wasi/sockets/udp/udp.wit.go b/tests/go/wasi/bindings/wasi/sockets/udp/udp.wit.go new file mode 100644 index 0000000..43fc7d6 --- /dev/null +++ b/tests/go/wasi/bindings/wasi/sockets/udp/udp.wit.go @@ -0,0 +1,641 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package udp represents the imported interface "wasi:sockets/udp@0.2.0". +package udp + +import ( + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/io/poll" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/sockets/network" + "github.com/ydnar/wasm-tools-go/cm" +) + +// IncomingDatagram represents the record "wasi:sockets/udp@0.2.0#incoming-datagram". +// +// A received datagram. +// +// record incoming-datagram { +// data: list, +// remote-address: ip-socket-address, +// } +type IncomingDatagram struct { + // The payload. + // + // Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes. + Data cm.List[uint8] + + // The source address. + // + // This field is guaranteed to match the remote address the stream was initialized + // with, if any. + // + // Equivalent to the `src_addr` out parameter of `recvfrom`. + RemoteAddress network.IPSocketAddress +} + +// OutgoingDatagram represents the record "wasi:sockets/udp@0.2.0#outgoing-datagram". +// +// A datagram to be sent out. +// +// record outgoing-datagram { +// data: list, +// remote-address: option, +// } +type OutgoingDatagram struct { + // The payload. + Data cm.List[uint8] + + // The destination address. + // + // The requirements on this field depend on how the stream was initialized: + // - with a remote address: this field must be None or match the stream's remote address + // exactly. + // - without a remote address: this field is required. + // + // If this value is None, the send operation is equivalent to `send` in POSIX. Otherwise + // it is equivalent to `sendto`. + RemoteAddress cm.Option[network.IPSocketAddress] +} + +// UDPSocket represents the imported resource "wasi:sockets/udp@0.2.0#udp-socket". +// +// A UDP socket handle. +// +// resource udp-socket +type UDPSocket cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "udp-socket". +// +// Drops a resource handle. +// +//go:nosplit +func (self UDPSocket) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [resource-drop]udp-socket +//go:noescape +func wasmimport_UDPSocketResourceDrop(self0 uint32) + +// AddressFamily represents the imported method "address-family". +// +// Whether this is a IPv4 or IPv6 socket. +// +// Equivalent to the SO_DOMAIN socket option. +// +// address-family: func() -> ip-address-family +// +//go:nosplit +func (self UDPSocket) AddressFamily() (result network.IPAddressFamily) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_UDPSocketAddressFamily((uint32)(self0)) + result = (network.IPAddressFamily)((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.address-family +//go:noescape +func wasmimport_UDPSocketAddressFamily(self0 uint32) (result0 uint32) + +// FinishBind represents the imported method "finish-bind". +// +// finish-bind: func() -> result<_, error-code> +// +//go:nosplit +func (self UDPSocket) FinishBind() (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketFinishBind((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.finish-bind +//go:noescape +func wasmimport_UDPSocketFinishBind(self0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// LocalAddress represents the imported method "local-address". +// +// Get the current bound address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `local-address` to return `invalid-state` when the +// socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +// +// local-address: func() -> result +// +//go:nosplit +func (self UDPSocket) LocalAddress() (result cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketLocalAddress((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.local-address +//go:noescape +func wasmimport_UDPSocketLocalAddress(self0 uint32, result *cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) + +// ReceiveBufferSize represents the imported method "receive-buffer-size". +// +// The kernel buffer space reserved for sends/receives on this socket. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or +// rounded. +// I.e. after setting a value, reading the same setting back may return a different +// value. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +// +// receive-buffer-size: func() -> result +// +//go:nosplit +func (self UDPSocket) ReceiveBufferSize() (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketReceiveBufferSize((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.receive-buffer-size +//go:noescape +func wasmimport_UDPSocketReceiveBufferSize(self0 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// RemoteAddress represents the imported method "remote-address". +// +// Get the address the socket is currently streaming to. +// +// # Typical errors +// - `invalid-state`: The socket is not streaming to a specific remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +// +// remote-address: func() -> result +// +//go:nosplit +func (self UDPSocket) RemoteAddress() (result cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketRemoteAddress((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.remote-address +//go:noescape +func wasmimport_UDPSocketRemoteAddress(self0 uint32, result *cm.Result[IPSocketAddressShape, network.IPSocketAddress, network.ErrorCode]) + +// SendBufferSize represents the imported method "send-buffer-size". +// +// send-buffer-size: func() -> result +// +//go:nosplit +func (self UDPSocket) SendBufferSize() (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketSendBufferSize((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.send-buffer-size +//go:noescape +func wasmimport_UDPSocketSendBufferSize(self0 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// SetReceiveBufferSize represents the imported method "set-receive-buffer-size". +// +// set-receive-buffer-size: func(value: u64) -> result<_, error-code> +// +//go:nosplit +func (self UDPSocket) SetReceiveBufferSize(value uint64) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_UDPSocketSetReceiveBufferSize((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.set-receive-buffer-size +//go:noescape +func wasmimport_UDPSocketSetReceiveBufferSize(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetSendBufferSize represents the imported method "set-send-buffer-size". +// +// set-send-buffer-size: func(value: u64) -> result<_, error-code> +// +//go:nosplit +func (self UDPSocket) SetSendBufferSize(value uint64) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint64)(value) + wasmimport_UDPSocketSetSendBufferSize((uint32)(self0), (uint64)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.set-send-buffer-size +//go:noescape +func wasmimport_UDPSocketSetSendBufferSize(self0 uint32, value0 uint64, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// SetUnicastHopLimit represents the imported method "set-unicast-hop-limit". +// +// set-unicast-hop-limit: func(value: u8) -> result<_, error-code> +// +//go:nosplit +func (self UDPSocket) SetUnicastHopLimit(value uint8) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + value0 := (uint32)(value) + wasmimport_UDPSocketSetUnicastHopLimit((uint32)(self0), (uint32)(value0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.set-unicast-hop-limit +//go:noescape +func wasmimport_UDPSocketSetUnicastHopLimit(self0 uint32, value0 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// StartBind represents the imported method "start-bind". +// +// Bind the socket to a specific network on the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the +// implementation to decide which +// network interface(s) to bind to. +// If the port is zero, the socket will be bound to a random free port. +// +// # Typical errors +// - `invalid-argument`: The `local-address` has the wrong address family. +// (EAFNOSUPPORT, EFAULT on Windows) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS +// on Windows) +// - `address-in-use`: Address is already in use. (EADDRINUSE) +// - `address-not-bindable`: `local-address` is not an address that the `network` +// can bind to. (EADDRNOTAVAIL) +// - `not-in-progress`: A `bind` operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. +// (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// Unlike in POSIX, in WASI the bind operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `bind` as part of either `start-bind` or `finish-bind`. +// +// # References +// - +// - +// - +// - +// +// start-bind: func(network: borrow, local-address: ip-socket-address) -> +// result<_, error-code> +// +//go:nosplit +func (self UDPSocket) StartBind(network_ network.Network, localAddress network.IPSocketAddress) (result cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + network0 := cm.Reinterpret[uint32](network_) + localAddress0, localAddress1, localAddress2, localAddress3, localAddress4, localAddress5, localAddress6, localAddress7, localAddress8, localAddress9, localAddress10, localAddress11 := lower_IPSocketAddress(localAddress) + wasmimport_UDPSocketStartBind((uint32)(self0), (uint32)(network0), (uint32)(localAddress0), (uint32)(localAddress1), (uint32)(localAddress2), (uint32)(localAddress3), (uint32)(localAddress4), (uint32)(localAddress5), (uint32)(localAddress6), (uint32)(localAddress7), (uint32)(localAddress8), (uint32)(localAddress9), (uint32)(localAddress10), (uint32)(localAddress11), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.start-bind +//go:noescape +func wasmimport_UDPSocketStartBind(self0 uint32, network0 uint32, localAddress0 uint32, localAddress1 uint32, localAddress2 uint32, localAddress3 uint32, localAddress4 uint32, localAddress5 uint32, localAddress6 uint32, localAddress7 uint32, localAddress8 uint32, localAddress9 uint32, localAddress10 uint32, localAddress11 uint32, result *cm.Result[network.ErrorCode, struct{}, network.ErrorCode]) + +// Stream represents the imported method "stream". +// +// Set up inbound & outbound communication channels, optionally to a specific peer. +// +// This function only changes the local socket configuration and does not generate +// any network traffic. +// On success, the `remote-address` of the socket is updated. The `local-address` +// may be updated as well, +// based on the best network path to `remote-address`. +// +// When a `remote-address` is provided, the returned streams are limited to communicating +// with that specific peer: +// - `send` can only be used to send to this destination. +// - `receive` will only return datagrams sent from the provided `remote-address`. +// +// This method may be called multiple times on the same socket to change its association, +// but +// only the most recently returned pair of streams will be operational. Implementations +// may trap if +// the streams returned by a previous invocation haven't been dropped yet before calling +// `stream` again. +// +// The POSIX equivalent in pseudo-code is: +// +// if (was previously connected) { +// connect(s, AF_UNSPEC) +// } +// if (remote_address is Some) { +// connect(s, remote_address) +// } +// +// Unlike in POSIX, the socket must already be explicitly bound. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. +// (EAFNOSUPPORT) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY +// (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, +// EADDRNOTAVAIL) +// - `invalid-state`: The socket is not bound. +// - `address-in-use`: Tried to perform an implicit bind, but there were +// no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, +// ENETRESET, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// +// # References +// - +// - +// - +// - +// +// %stream: func(remote-address: option) -> result, error-code> +// +//go:nosplit +func (self UDPSocket) Stream(remoteAddress cm.Option[network.IPSocketAddress]) (result cm.Result[TupleIncomingDatagramStreamOutgoingDatagramStreamShape, cm.Tuple[IncomingDatagramStream, OutgoingDatagramStream], network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + remoteAddress0, remoteAddress1, remoteAddress2, remoteAddress3, remoteAddress4, remoteAddress5, remoteAddress6, remoteAddress7, remoteAddress8, remoteAddress9, remoteAddress10, remoteAddress11, remoteAddress12 := lower_OptionIPSocketAddress(remoteAddress) + wasmimport_UDPSocketStream((uint32)(self0), (uint32)(remoteAddress0), (uint32)(remoteAddress1), (uint32)(remoteAddress2), (uint32)(remoteAddress3), (uint32)(remoteAddress4), (uint32)(remoteAddress5), (uint32)(remoteAddress6), (uint32)(remoteAddress7), (uint32)(remoteAddress8), (uint32)(remoteAddress9), (uint32)(remoteAddress10), (uint32)(remoteAddress11), (uint32)(remoteAddress12), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.stream +//go:noescape +func wasmimport_UDPSocketStream(self0 uint32, remoteAddress0 uint32, remoteAddress1 uint32, remoteAddress2 uint32, remoteAddress3 uint32, remoteAddress4 uint32, remoteAddress5 uint32, remoteAddress6 uint32, remoteAddress7 uint32, remoteAddress8 uint32, remoteAddress9 uint32, remoteAddress10 uint32, remoteAddress11 uint32, remoteAddress12 uint32, result *cm.Result[TupleIncomingDatagramStreamOutgoingDatagramStreamShape, cm.Tuple[IncomingDatagramStream, OutgoingDatagramStream], network.ErrorCode]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once the socket is ready for I/O. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self UDPSocket) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_UDPSocketSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.subscribe +//go:noescape +func wasmimport_UDPSocketSubscribe(self0 uint32) (result0 uint32) + +// UnicastHopLimit represents the imported method "unicast-hop-limit". +// +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +// +// unicast-hop-limit: func() -> result +// +//go:nosplit +func (self UDPSocket) UnicastHopLimit() (result cm.Result[uint8, uint8, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_UDPSocketUnicastHopLimit((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]udp-socket.unicast-hop-limit +//go:noescape +func wasmimport_UDPSocketUnicastHopLimit(self0 uint32, result *cm.Result[uint8, uint8, network.ErrorCode]) + +// IncomingDatagramStream represents the imported resource "wasi:sockets/udp@0.2.0#incoming-datagram-stream". +// +// resource incoming-datagram-stream +type IncomingDatagramStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "incoming-datagram-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self IncomingDatagramStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_IncomingDatagramStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [resource-drop]incoming-datagram-stream +//go:noescape +func wasmimport_IncomingDatagramStreamResourceDrop(self0 uint32) + +// Receive represents the imported method "receive". +// +// Receive messages on the socket. +// +// This function attempts to receive up to `max-results` datagrams on the socket without +// blocking. +// The returned list may contain fewer elements than requested, but never more. +// +// This function returns successfully with an empty list when either: +// - `max-results` is 0, or: +// - `max-results` is greater than 0, but no results are immediately available. +// This function never returns `error(would-block)`. +// +// # Typical errors +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET +// on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +// +// receive: func(max-results: u64) -> result, error-code> +// +//go:nosplit +func (self IncomingDatagramStream) Receive(maxResults uint64) (result cm.Result[cm.List[IncomingDatagram], cm.List[IncomingDatagram], network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + maxResults0 := (uint64)(maxResults) + wasmimport_IncomingDatagramStreamReceive((uint32)(self0), (uint64)(maxResults0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]incoming-datagram-stream.receive +//go:noescape +func wasmimport_IncomingDatagramStreamReceive(self0 uint32, maxResults0 uint64, result *cm.Result[cm.List[IncomingDatagram], cm.List[IncomingDatagram], network.ErrorCode]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once the stream is ready to receive again. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self IncomingDatagramStream) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_IncomingDatagramStreamSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]incoming-datagram-stream.subscribe +//go:noescape +func wasmimport_IncomingDatagramStreamSubscribe(self0 uint32) (result0 uint32) + +// OutgoingDatagramStream represents the imported resource "wasi:sockets/udp@0.2.0#outgoing-datagram-stream". +// +// resource outgoing-datagram-stream +type OutgoingDatagramStream cm.Resource + +// ResourceDrop represents the imported resource-drop for resource "outgoing-datagram-stream". +// +// Drops a resource handle. +// +//go:nosplit +func (self OutgoingDatagramStream) ResourceDrop() { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingDatagramStreamResourceDrop((uint32)(self0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [resource-drop]outgoing-datagram-stream +//go:noescape +func wasmimport_OutgoingDatagramStreamResourceDrop(self0 uint32) + +// CheckSend represents the imported method "check-send". +// +// Check readiness for sending. This function never blocks. +// +// Returns the number of datagrams permitted for the next call to `send`, +// or an error. Calling `send` with more datagrams than this function has +// permitted will trap. +// +// When this function returns ok(0), the `subscribe` pollable will +// become ready when this function will report at least ok(1), or an +// error. +// +// Never returns `would-block`. +// +// check-send: func() -> result +// +//go:nosplit +func (self OutgoingDatagramStream) CheckSend() (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + wasmimport_OutgoingDatagramStreamCheckSend((uint32)(self0), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]outgoing-datagram-stream.check-send +//go:noescape +func wasmimport_OutgoingDatagramStreamCheckSend(self0 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// Send represents the imported method "send". +// +// Send messages on the socket. +// +// This function attempts to send all provided `datagrams` on the socket without blocking +// and +// returns how many messages were actually sent (or queued for sending). This function +// never +// returns `error(would-block)`. If none of the datagrams were able to be sent, `ok(0)` +// is returned. +// +// This function semantically behaves the same as iterating the `datagrams` list and +// sequentially +// sending each individual datagram until either the end of the list has been reached +// or the first error occurred. +// If at least one datagram has been sent successfully, this function never returns +// an error. +// +// If the input list is empty, the function returns `ok(0)`. +// +// Each call to `send` must be permitted by a preceding `check-send`. Implementations +// must trap if +// either `check-send` was not called or `datagrams` contains more items than `check-send` +// permitted. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. +// (EAFNOSUPPORT) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY +// (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, +// EADDRNOTAVAIL) +// - `invalid-argument`: The socket is in "connected" mode and `remote-address` +// is `some` value that does not match the address passed to `stream`. (EISCONN) +// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` +// was provided. (EDESTADDRREQ) +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, +// ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +// +// send: func(datagrams: list) -> result +// +//go:nosplit +func (self OutgoingDatagramStream) Send(datagrams cm.List[OutgoingDatagram]) (result cm.Result[uint64, uint64, network.ErrorCode]) { + self0 := cm.Reinterpret[uint32](self) + datagrams0, datagrams1 := cm.LowerList(datagrams) + wasmimport_OutgoingDatagramStreamSend((uint32)(self0), (*OutgoingDatagram)(datagrams0), (uint32)(datagrams1), &result) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]outgoing-datagram-stream.send +//go:noescape +func wasmimport_OutgoingDatagramStreamSend(self0 uint32, datagrams0 *OutgoingDatagram, datagrams1 uint32, result *cm.Result[uint64, uint64, network.ErrorCode]) + +// Subscribe represents the imported method "subscribe". +// +// Create a `pollable` which will resolve once the stream is ready to send again. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +// +// subscribe: func() -> pollable +// +//go:nosplit +func (self OutgoingDatagramStream) Subscribe() (result poll.Pollable) { + self0 := cm.Reinterpret[uint32](self) + result0 := wasmimport_OutgoingDatagramStreamSubscribe((uint32)(self0)) + result = cm.Reinterpret[poll.Pollable]((uint32)(result0)) + return +} + +//go:wasmimport wasi:sockets/udp@0.2.0 [method]outgoing-datagram-stream.subscribe +//go:noescape +func wasmimport_OutgoingDatagramStreamSubscribe(self0 uint32) (result0 uint32) diff --git a/tests/go/wasi/bindings/west-test/fib/fib/empty.s b/tests/go/wasi/bindings/west-test/fib/fib/empty.s new file mode 100644 index 0000000..5444f20 --- /dev/null +++ b/tests/go/wasi/bindings/west-test/fib/fib/empty.s @@ -0,0 +1,3 @@ +// This file exists for testing this package without WebAssembly, +// allowing empty function bodies with a //go:wasmimport directive. +// See https://pkg.go.dev/cmd/compile for more information. diff --git a/tests/go/wasi/bindings/west-test/fib/fib/fib.wit.go b/tests/go/wasi/bindings/west-test/fib/fib/fib.wit.go new file mode 100644 index 0000000..ae6ab59 --- /dev/null +++ b/tests/go/wasi/bindings/west-test/fib/fib/fib.wit.go @@ -0,0 +1,20 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package fib represents the imported interface "west-test:fib/fib". +package fib + +// Fib represents the imported function "fib". +// +// fib: func(n: u32) -> u64 +// +//go:nosplit +func Fib(n uint32) (result uint64) { + n0 := (uint32)(n) + result0 := wasmimport_Fib((uint32)(n0)) + result = (uint64)((uint64)(result0)) + return +} + +//go:wasmimport west-test:fib/fib fib +//go:noescape +func wasmimport_Fib(n0 uint32) (result0 uint64) diff --git a/tests/go/wasi/bindings/west-test/wasi/service/service.wit.go b/tests/go/wasi/bindings/west-test/wasi/service/service.wit.go new file mode 100644 index 0000000..43c2607 --- /dev/null +++ b/tests/go/wasi/bindings/west-test/wasi/service/service.wit.go @@ -0,0 +1,4 @@ +// Code generated by wit-bindgen-go. DO NOT EDIT. + +// Package service represents the world "west-test:wasi/service". +package service diff --git a/go/internal/tests/wasi/wasi.go b/tests/go/wasi/wasi.go similarity index 91% rename from go/internal/tests/wasi/wasi.go rename to tests/go/wasi/wasi.go index f1b8e8d..9b18152 100644 --- a/go/internal/tests/wasi/wasi.go +++ b/tests/go/wasi/wasi.go @@ -6,8 +6,8 @@ import ( "log/slog" "unsafe" - incominghandler "github.com/rvolosatovs/west/go/internal/tests/wasi/bindings/wasi/http/incoming-handler" - "github.com/rvolosatovs/west/go/internal/tests/wasi/bindings/wasi/http/types" + incominghandler "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/incoming-handler" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/types" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/internal/tests/wasi/wasi_test.go b/tests/go/wasi/wasi_test.go similarity index 84% rename from go/internal/tests/wasi/wasi_test.go rename to tests/go/wasi/wasi_test.go index 96a06d7..5a1e7d9 100644 --- a/go/internal/tests/wasi/wasi_test.go +++ b/tests/go/wasi/wasi_test.go @@ -6,12 +6,12 @@ import ( "testing" "unsafe" - west "github.com/rvolosatovs/west/go" - _ "github.com/rvolosatovs/west/go/bindings" - testtypes "github.com/rvolosatovs/west/go/bindings/wasi/http/types" - httptest "github.com/rvolosatovs/west/go/bindings/west/test/http-test" - incominghandler "github.com/rvolosatovs/west/go/internal/tests/wasi/bindings/wasi/http/incoming-handler" - "github.com/rvolosatovs/west/go/internal/tests/wasi/bindings/wasi/http/types" + west "github.com/rvolosatovs/west" + _ "github.com/rvolosatovs/west/bindings" + testtypes "github.com/rvolosatovs/west/bindings/wasi/http/types" + httptest "github.com/rvolosatovs/west/bindings/west/test/http-test" + incominghandler "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/incoming-handler" + "github.com/rvolosatovs/west/tests/go/wasi/bindings/wasi/http/types" "github.com/stretchr/testify/assert" "github.com/ydnar/wasm-tools-go/cm" ) diff --git a/go/internal/tests/wasi/wit/app.wit b/tests/go/wasi/wit/app.wit similarity index 100% rename from go/internal/tests/wasi/wit/app.wit rename to tests/go/wasi/wit/app.wit diff --git a/go/internal/tests/wasi/wit/deps.lock b/tests/go/wasi/wit/deps.lock similarity index 100% rename from go/internal/tests/wasi/wit/deps.lock rename to tests/go/wasi/wit/deps.lock diff --git a/go/internal/tests/wasi/wit/deps.toml b/tests/go/wasi/wit/deps.toml similarity index 100% rename from go/internal/tests/wasi/wit/deps.toml rename to tests/go/wasi/wit/deps.toml diff --git a/go/internal/tests/wasi/wit/deps/cli/command.wit b/tests/go/wasi/wit/deps/cli/command.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/command.wit rename to tests/go/wasi/wit/deps/cli/command.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/environment.wit b/tests/go/wasi/wit/deps/cli/environment.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/environment.wit rename to tests/go/wasi/wit/deps/cli/environment.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/exit.wit b/tests/go/wasi/wit/deps/cli/exit.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/exit.wit rename to tests/go/wasi/wit/deps/cli/exit.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/imports.wit b/tests/go/wasi/wit/deps/cli/imports.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/imports.wit rename to tests/go/wasi/wit/deps/cli/imports.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/run.wit b/tests/go/wasi/wit/deps/cli/run.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/run.wit rename to tests/go/wasi/wit/deps/cli/run.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/stdio.wit b/tests/go/wasi/wit/deps/cli/stdio.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/stdio.wit rename to tests/go/wasi/wit/deps/cli/stdio.wit diff --git a/go/internal/tests/wasi/wit/deps/cli/terminal.wit b/tests/go/wasi/wit/deps/cli/terminal.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/cli/terminal.wit rename to tests/go/wasi/wit/deps/cli/terminal.wit diff --git a/go/internal/tests/wasi/wit/deps/clocks/monotonic-clock.wit b/tests/go/wasi/wit/deps/clocks/monotonic-clock.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/clocks/monotonic-clock.wit rename to tests/go/wasi/wit/deps/clocks/monotonic-clock.wit diff --git a/go/internal/tests/wasi/wit/deps/clocks/wall-clock.wit b/tests/go/wasi/wit/deps/clocks/wall-clock.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/clocks/wall-clock.wit rename to tests/go/wasi/wit/deps/clocks/wall-clock.wit diff --git a/go/internal/tests/wasi/wit/deps/clocks/world.wit b/tests/go/wasi/wit/deps/clocks/world.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/clocks/world.wit rename to tests/go/wasi/wit/deps/clocks/world.wit diff --git a/go/internal/tests/wasi/wit/deps/fib/fib.wit b/tests/go/wasi/wit/deps/fib/fib.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/fib/fib.wit rename to tests/go/wasi/wit/deps/fib/fib.wit diff --git a/go/internal/tests/wasi/wit/deps/filesystem/preopens.wit b/tests/go/wasi/wit/deps/filesystem/preopens.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/filesystem/preopens.wit rename to tests/go/wasi/wit/deps/filesystem/preopens.wit diff --git a/go/internal/tests/wasi/wit/deps/filesystem/types.wit b/tests/go/wasi/wit/deps/filesystem/types.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/filesystem/types.wit rename to tests/go/wasi/wit/deps/filesystem/types.wit diff --git a/go/internal/tests/wasi/wit/deps/filesystem/world.wit b/tests/go/wasi/wit/deps/filesystem/world.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/filesystem/world.wit rename to tests/go/wasi/wit/deps/filesystem/world.wit diff --git a/go/internal/tests/wasi/wit/deps/http/handler.wit b/tests/go/wasi/wit/deps/http/handler.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/http/handler.wit rename to tests/go/wasi/wit/deps/http/handler.wit diff --git a/go/internal/tests/wasi/wit/deps/http/proxy.wit b/tests/go/wasi/wit/deps/http/proxy.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/http/proxy.wit rename to tests/go/wasi/wit/deps/http/proxy.wit diff --git a/go/internal/tests/wasi/wit/deps/http/types.wit b/tests/go/wasi/wit/deps/http/types.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/http/types.wit rename to tests/go/wasi/wit/deps/http/types.wit diff --git a/go/internal/tests/wasi/wit/deps/io/error.wit b/tests/go/wasi/wit/deps/io/error.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/io/error.wit rename to tests/go/wasi/wit/deps/io/error.wit diff --git a/go/internal/tests/wasi/wit/deps/io/poll.wit b/tests/go/wasi/wit/deps/io/poll.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/io/poll.wit rename to tests/go/wasi/wit/deps/io/poll.wit diff --git a/go/internal/tests/wasi/wit/deps/io/streams.wit b/tests/go/wasi/wit/deps/io/streams.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/io/streams.wit rename to tests/go/wasi/wit/deps/io/streams.wit diff --git a/go/internal/tests/wasi/wit/deps/io/world.wit b/tests/go/wasi/wit/deps/io/world.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/io/world.wit rename to tests/go/wasi/wit/deps/io/world.wit diff --git a/go/internal/tests/wasi/wit/deps/random/insecure-seed.wit b/tests/go/wasi/wit/deps/random/insecure-seed.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/random/insecure-seed.wit rename to tests/go/wasi/wit/deps/random/insecure-seed.wit diff --git a/go/internal/tests/wasi/wit/deps/random/insecure.wit b/tests/go/wasi/wit/deps/random/insecure.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/random/insecure.wit rename to tests/go/wasi/wit/deps/random/insecure.wit diff --git a/go/internal/tests/wasi/wit/deps/random/random.wit b/tests/go/wasi/wit/deps/random/random.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/random/random.wit rename to tests/go/wasi/wit/deps/random/random.wit diff --git a/go/internal/tests/wasi/wit/deps/random/world.wit b/tests/go/wasi/wit/deps/random/world.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/random/world.wit rename to tests/go/wasi/wit/deps/random/world.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/instance-network.wit b/tests/go/wasi/wit/deps/sockets/instance-network.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/instance-network.wit rename to tests/go/wasi/wit/deps/sockets/instance-network.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/ip-name-lookup.wit b/tests/go/wasi/wit/deps/sockets/ip-name-lookup.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/ip-name-lookup.wit rename to tests/go/wasi/wit/deps/sockets/ip-name-lookup.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/network.wit b/tests/go/wasi/wit/deps/sockets/network.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/network.wit rename to tests/go/wasi/wit/deps/sockets/network.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/tcp-create-socket.wit b/tests/go/wasi/wit/deps/sockets/tcp-create-socket.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/tcp-create-socket.wit rename to tests/go/wasi/wit/deps/sockets/tcp-create-socket.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/tcp.wit b/tests/go/wasi/wit/deps/sockets/tcp.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/tcp.wit rename to tests/go/wasi/wit/deps/sockets/tcp.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/udp-create-socket.wit b/tests/go/wasi/wit/deps/sockets/udp-create-socket.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/udp-create-socket.wit rename to tests/go/wasi/wit/deps/sockets/udp-create-socket.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/udp.wit b/tests/go/wasi/wit/deps/sockets/udp.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/udp.wit rename to tests/go/wasi/wit/deps/sockets/udp.wit diff --git a/go/internal/tests/wasi/wit/deps/sockets/world.wit b/tests/go/wasi/wit/deps/sockets/world.wit similarity index 100% rename from go/internal/tests/wasi/wit/deps/sockets/world.wit rename to tests/go/wasi/wit/deps/sockets/world.wit diff --git a/go/west.go b/west.go similarity index 89% rename from go/west.go rename to west.go index c1e18ad..7cfcb89 100644 --- a/go/west.go +++ b/west.go @@ -1,14 +1,14 @@ //go:generate cargo build -p west-sys --release -//go:generate go run github.com/ydnar/wasm-tools-go/cmd/wit-bindgen-go@v0.1.5 generate -w imports -o bindings ../wit +//go:generate go run github.com/ydnar/wasm-tools-go/cmd/wit-bindgen-go@v0.1.5 generate -w imports -o bindings ./wit package west -// #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/../lib/x86_64-darwin -lwest -// #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/../lib/aarch64-darwin -lwest -// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/../lib/x86_64-linux -lwest -// #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/../lib/aarch64-linux -lwest -// #cgo windows,amd64 LDFLAGS: -L${SRCDIR}/../lib/x86_64-windows -lwest -// #include "../include/west.h" +// #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/lib/x86_64-darwin -lwest +// #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/lib/aarch64-darwin -lwest +// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/lib/x86_64-linux -lwest +// #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/lib/aarch64-linux -lwest +// #cgo windows,amd64 LDFLAGS: -L${SRCDIR}/lib/x86_64-windows -lwest +// #include "./include/west.h" // #include import "C" diff --git a/west_darwin_amd64.go b/west_darwin_amd64.go new file mode 100644 index 0000000..5db51fc --- /dev/null +++ b/west_darwin_amd64.go @@ -0,0 +1,3 @@ +//go:generate cp ./target/release/libwest_sys.a ./lib/x86_64-darwin/libwest.a + +package west diff --git a/west_darwin_arm64.go b/west_darwin_arm64.go new file mode 100644 index 0000000..dd14dc1 --- /dev/null +++ b/west_darwin_arm64.go @@ -0,0 +1,3 @@ +//go:generate cp ./target/release/libwest_sys.a ./lib/aarch64-darwin/libwest.a + +package west diff --git a/west_linux_amd64.go b/west_linux_amd64.go new file mode 100644 index 0000000..6ff1c45 --- /dev/null +++ b/west_linux_amd64.go @@ -0,0 +1,3 @@ +//go:generate cp ./target/release/libwest_sys.a ./lib/x86_64-linux/libwest.a + +package west diff --git a/west_linux_arm64.go b/west_linux_arm64.go new file mode 100644 index 0000000..34eb09f --- /dev/null +++ b/west_linux_arm64.go @@ -0,0 +1,3 @@ +//go:generate cp ./target/release/libwest_sys.a ./lib/aarch64-linux/libwest.a + +package west diff --git a/west_windows_amd64.go b/west_windows_amd64.go new file mode 100644 index 0000000..6bab720 --- /dev/null +++ b/west_windows_amd64.go @@ -0,0 +1,3 @@ +//go:generate cp ./target/release/libwest_sys.a ./lib/x86_64-windows/libwest.a + +package west