Merge pull request #2 from Lore09/pelato

Pelato framework
This commit is contained in:
Lorenzo Venerandi
2025-01-29 17:45:12 +01:00
committed by GitHub
325 changed files with 19304 additions and 269 deletions

4
.env.template Normal file
View File

@@ -0,0 +1,4 @@
REGISTRY_URL=
REGISTRY_USER=
REGISTRY_PASSWORD=
PARALLEL_BUILD=

9
.gitignore vendored
View File

@@ -1,2 +1,7 @@
build/* # Python
__pycache__/ **/__pycache__/
.venv
# Environment
.env
.vscode

16
main.py
View File

@@ -1,16 +0,0 @@
import src.task_splitter.code_processor as splitter
import src.task_splitter.code_generator as generator
input_file = "source-code/tasks.c" # Replace this with your actual file name
output_dir = "build/"
functions = splitter.extract_functions_from_file(input_file)
print(f"Found {len(functions)} functions in the file.")
generator.build_code_from_functions(functions)
print("Code has been generated for each function.")
splitter.create_independent_files(functions, output_dir)
print("Functions have been split into separate files with their own main functions.")
splitter.save_functions_to_yaml(functions, output_dir + "functions.yaml")

42
pelato.py Normal file
View File

@@ -0,0 +1,42 @@
import argparse
import src
def main():
parser = argparse.ArgumentParser(
description="Generate, build and deploy WASM components written in go"
)
subparsers = parser.add_subparsers(dest="command", help="Command list")
parser_generate = subparsers.add_parser("gen", help="Generate Go code")
parser_generate.add_argument("dir", type=str, help="Project directory")
parser_build = subparsers.add_parser("build", help="Build WASM component")
parser_build.add_argument("dir", type=str, help="Project directory")
parser_deploy = subparsers.add_parser("deploy", help="Deploy WASM components")
parser_deploy.add_argument("dir", type=str, help="Project directory")
parser_all = subparsers.add_parser("brush", help="Everything above")
parser_all.add_argument("dir", type=str, help="Project directory")
# Parsing degli argomenti
args = parser.parse_args()
# Setup Pelato
pelato = src.Pelato()
# Esecuzione del comando specificato
if args.command == "gen":
pelato.generate(args.dir)
elif args.command == "build":
pelato.build(args.dir)
elif args.command == "deploy":
pelato.deploy(args.dir)
elif args.command == "brush":
pelato.all(args.dir)
else:
parser.print_help()
if __name__ == "__main__":
main()

1
project/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
gen

12
project/tasks/task1.go Normal file
View File

@@ -0,0 +1,12 @@
package main
import (
)
func exec_task(arg string) string{
response := "" + arg
return response
}

11
project/workflow.yaml Normal file
View File

@@ -0,0 +1,11 @@
tasks:
- name: Data Aggregation # Displayed name
type: processor_nats # Used to select template
code: task1.go # Go code file inside tasks/ dir
target: # Where the component will be deployed
- edge
- cloud
source_topic: temp_sensor # Source NATS topic
dest_topic: aggregated_data # Destination NATS topic
component_name: data_aggregation # Component name displayed in the OCI artifact
version: 1.0.0

View File

@@ -7,7 +7,7 @@ L'infrastuttura simula un flusso IoT ed è composta da:
- ambiente Edge, semplice macchina Linux con docker compose, Wasmcloud e NATS Leaf come docker container - ambiente Edge, semplice macchina Linux con docker compose, Wasmcloud e NATS Leaf come docker container
- dispositivi IoT collegati all'ambiente Edge - dispositivi IoT collegati all'ambiente Edge
![infra](/project/img/infra.png) ![infra](/res/img/infra.png)
# Pipeline # Pipeline
@@ -35,7 +35,7 @@ Nel file workflow vengono descritti i vari componenti, un esempio potrebbe esser
```yaml ```yaml
tasks: tasks:
- name: Data Aggregation # Displayed name - name: Data Aggregation # Displayed name
type: processing # Used to select template type: processor_nats # Used to select template
code: aggregate.go # Go code file inside tasks/ dir code: aggregate.go # Go code file inside tasks/ dir
target: # Where the component will be deployed target: # Where the component will be deployed
- edge - edge
@@ -68,9 +68,9 @@ func exec_task(arg string) string{
### Generazione del codice ### Generazione del codice
Il parser utilizza il campo `type` del workflow per selezionare il corretto template fra quelli implementati (per ora) Il parser utilizza il campo `type` del workflow per selezionare il corretto template fra quelli implementati (per ora)
- producer -- produzione di dati e scrittura di essi in un topic NATS - producer_nats -- produzione di dati e scrittura di essi in un topic NATS
- processor -- lettura di dati da un topic, processamento dei dati e scrittura su un altro topic - processor_nats -- lettura di dati da un topic, processamento dei dati e scrittura su un altro topic
- dbsync -- lettura di dati da un topic e scrittura su un DB (Postgres) - dbsync_nats -- lettura di dati da un topic e scrittura su un DB (Postgres)
Viene sostituito il file delle task con quello del template, i campi del file `workflow` vengono utilizzati per compilare il file `wadm.yaml`. Viene sostituito il file delle task con quello del template, i campi del file `workflow` vengono utilizzati per compilare il file `wadm.yaml`.
@@ -157,4 +157,4 @@ spec:
Il target del deployment viene selezionato tramite il campo `spreadscaler`, che indirizza i componenti nell'host con il tag corrispondente. Il target del deployment viene selezionato tramite il campo `spreadscaler`, che indirizza i componenti nell'host con il tag corrispondente.
### Pipeline scheme ### Pipeline scheme
![pipeline](project/img/pipeline.png) ![pipeline](res/img/pipeline.png)

10
requirements.txt Normal file
View File

@@ -0,0 +1,10 @@
certifi==2024.12.14
charset-normalizer==3.4.1
docker==7.1.0
idna==3.10
Jinja2==3.1.5
MarkupSafe==3.0.2
python-dotenv==1.0.1
PyYAML==6.0.2
requests==2.32.3
urllib3==2.3.0

View File

Before

Width:  |  Height:  |  Size: 571 KiB

After

Width:  |  Height:  |  Size: 571 KiB

View File

Before

Width:  |  Height:  |  Size: 810 KiB

After

Width:  |  Height:  |  Size: 810 KiB

View File

@@ -1,19 +0,0 @@
@Task
@LibDeps("stdio.h","stdlib.h")
float get_average_rand(float values[]){
return 5;
}
@ModuleName("Tattitto")
@TaskCloud
@LibDeps("math.h")
int is_even(int number){
if(number%2==0)return 1;
else return 0;
}
@LibDeps("stdio.h","string.h")
@TaskDevice
void printaaaa(String text){
printf("aaaa %s\n",text);
}

View File

@@ -0,0 +1,30 @@
from dotenv import load_dotenv
import os
import src.code_generator.generator as code_generator
import src.wasm_builder.build as wasm_builder
class Pelato:
def __init__(self):
self.setup_vars()
def setup_vars(self):
load_dotenv()
self.registry_url = os.getenv('REGISTRY_URL')
self.reg_user = os.getenv('REGISTRY_USER')
self.reg_pass = os.getenv('REGISTRY_PASSWORD')
self.detached = os.getenv('PARALLEL_BUILD')
def generate(self, project_dir):
code_generator.generate(project_dir, self.registry_url)
def build(self, project_dir):
wasm_builder.build_project(project_dir, self.reg_user, self.reg_pass, self.detached)
def deploy(self, project_dir):
print(f"Deploying WASM components for project {project_dir}")
def all(self, project_dir):
print(f"Doing everything for project {project_dir}")

View File

@@ -0,0 +1,58 @@
import yaml
import shutil
import logging
import os
import src.code_generator.template_compiler as template_compiler
def __parse_yaml(yaml_file):
with open(yaml_file, 'r') as stream:
try:
return yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
return None
def __remove_dir_if_exists(dir_path):
if os.path.exists(dir_path):
if os.path.isdir(dir_path):
shutil.rmtree(dir_path)
def generate(project_dir, registry_url):
# Check if the project directory is valid
if not os.path.exists(f"{project_dir}/workflow.yaml") or not os.path.exists(f"{project_dir}/tasks"):
logging.error(f"Project directory is not valid")
return
# Parsing del file di configurazione
config = __parse_yaml(f"{project_dir}/workflow.yaml")
if config is None:
logging.error("Error parsing workflow.yaml")
return
print(f"Generating code for project {config['project_name']}")
# Rimozione della cartella di output
output_dir = f"{project_dir}/gen"
__remove_dir_if_exists(output_dir)
# Creazione della cartella di output
os.makedirs(output_dir, exist_ok=True)
# for each task in the workflow
for task in config['tasks']:
try:
task['registry_url'] = registry_url
template_compiler.handle_task(task, output_dir)
# Copy the code file to the output folder
shutil.copy2(f"{project_dir}/tasks/{task['code']}", f"{output_dir}/{task['component_name']}/{task['code']}")
print(f" - Task {task['component_name']} generated")
except Exception as e:
logging.error(f"Error generating task {task['component_name']}: {e}")
continue

View File

@@ -0,0 +1,92 @@
import logging
from jinja2 import FileSystemLoader, Environment
import os
import shutil
def handle_task(task, output_dir):
try:
match task['type']:
case 'producer_nats':
__generate_producer(task, output_dir)
case 'processor_nats':
__generate_processor(task, output_dir)
case 'dbsync_nats':
__generate_dbsync(task, output_dir)
case _:
logging.error(f"Task type {task['type']} not supported")
pass
except KeyError as e:
logging.error(f"Error parsing task: {e}")
pass
def __generate_producer(task, output_dir):
# Copy the template folder to the output folder
__copytree("src/code_generator/templates/producer_nats", f"{output_dir}/{task['component_name']}")
# Replace each file of the output dir with the template
for filename in os.listdir(f"{output_dir}/{task['component_name']}"):
# Skip the following files
if filename in ['Dockerfile', 'go.mod', 'go.sum', 'tools.go']:
continue
# Skip if it's a directory
if os.path.isdir(f"{output_dir}/{task['component_name']}/{filename}"):
continue
__replace_file_with_template(filename, f"{output_dir}/{task['component_name']}", task)
def __generate_processor(task, output_dir):
# Copy the template folder to the output folder
__copytree("src/code_generator/templates/processor_nats", f"{output_dir}/{task['component_name']}")
# Replace each file of the output dir with the template
for filename in os.listdir(f"{output_dir}/{task['component_name']}"):
# Skip the following files
if filename in ['Dockerfile', 'go.mod', 'go.sum', 'tools.go', 'bindings.wadge.go']:
continue
# Skip if it's a directory
if os.path.isdir(f"{output_dir}/{task['component_name']}/{filename}"):
continue
__replace_file_with_template(filename, f"{output_dir}/{task['component_name']}", task)
def __generate_dbsync(task, output_dir):
pass
def __copytree(src, dst, symlinks=False, ignore=None):
# Create the destination directory
os.makedirs(dst, exist_ok=True)
# Copy the files
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
def __replace_file_with_template(filename, output_dir, template_vars):
try:
templateLoader = FileSystemLoader(searchpath=output_dir)
templateEnv = Environment(loader=templateLoader)
template = templateEnv.get_template(filename)
outputText = template.render(template_vars)
# Replace the file with the rendered template
with open(f"{output_dir}/{filename}", 'w') as f:
f.write(outputText)
except Exception as e:
logging.error(f"Error rendering template {filename}: {e}")
return

View File

@@ -0,0 +1,51 @@
FROM ubuntu:24.04 AS wash-build-image
# Install dependencies and tools
RUN apt-get update && apt-get install -y \
curl \
wget \
tar \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# ----------------- Install WasmCloud -----------------
RUN curl -s "https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh" | bash && \
apt-get install -y wash
# ----------------- Install Go 1.23 -----------------
RUN wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz && \
rm go1.23.4.linux-amd64.tar.gz
# Set Go environment variables
ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go"
ENV GOROOT="/usr/local/go"
# ----------------- Install TinyGo 0.34.0 -----------------
RUN wget https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb && \
dpkg -i tinygo_0.34.0_amd64.deb && \
rm tinygo_0.34.0_amd64.deb
# ----------------- Install Rust -----------------
# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
. "$HOME/.cargo/env" && \
cargo install --locked wasm-tools
# Set Rust environment variables
ENV PATH="/root/.cargo/bin:${PATH}"
# Verify installations
RUN go version && tinygo version && cargo --version && wash --version && wasm-tools --version
# ----------------- Build the WasmCloud module -----------------
FROM wash-build-image
RUN mkdir /app
WORKDIR /app
# Install go dependencies, build the wasm module, push it to the registry
CMD ["sh", "-c", "go env -w GOFLAGS=-buildvcs=false && go mod download && go mod verify && wash build && wash push $REGISTRY build/*.wasm"]

View File

@@ -0,0 +1,130 @@
//go:build !wasm && !wasi && !wasip1 && !wasip2 && !wasm_unknown && !tinygo.wasm
// Code generated by wadge-bindgen-go DO NOT EDIT
package main
import (
gitea_rebus_ninja__lore__wasm___nats___stream___client__gen__wasmcloud__messaging__consumer "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/consumer"
gitea_rebus_ninja__lore__wasm___nats___stream___client__gen__wasmcloud__messaging__types "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/types"
github_com__bytecodealliance__wasm___tools___go__cm "github.com/bytecodealliance/wasm-tools-go/cm"
wadge "go.wasmcloud.dev/wadge"
"runtime"
"unsafe"
)
const _ string = runtime.Compiler
var _ unsafe.Pointer
//go:linkname wasmimport_Log gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/logging/logging.wasmimport_Log
func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasi:logging/logging@0.1.0-draft", "log", func() unsafe.Pointer {
ptr := unsafe.Pointer(&level0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(context0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&context1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(message0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&message1)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_Publish gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/consumer.wasmimport_Publish
func wasmimport_Publish(msg0 *uint8, msg1 uint32, msg2 *uint8, msg3 uint32, msg4 uint32, msg5 *uint8, msg6 uint32, result *github_com__bytecodealliance__wasm___tools___go__cm.Result[string, struct{}, string]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasmcloud:messaging/consumer@0.2.0", "publish", func() unsafe.Pointer {
ptr := unsafe.Pointer(msg0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(msg2)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg3)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg4)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(msg5)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&msg6)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}
//go:linkname wasmimport_Request gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasmcloud/messaging/consumer.wasmimport_Request
func wasmimport_Request(subject0 *uint8, subject1 uint32, body0 *uint8, body1 uint32, timeoutMs0 uint32, result *github_com__bytecodealliance__wasm___tools___go__cm.Result[gitea_rebus_ninja__lore__wasm___nats___stream___client__gen__wasmcloud__messaging__consumer.BrokerMessageShape, gitea_rebus_ninja__lore__wasm___nats___stream___client__gen__wasmcloud__messaging__types.BrokerMessage, string]) {
var __p runtime.Pinner
defer __p.Unpin()
if __err := wadge.WithCurrentInstance(func(__instance *wadge.Instance) error {
return __instance.Call("wasmcloud:messaging/consumer@0.2.0", "request", func() unsafe.Pointer {
ptr := unsafe.Pointer(subject0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&subject1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(body0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&body1)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(&timeoutMs0)
__p.Pin(ptr)
return ptr
}(), func() unsafe.Pointer {
ptr := unsafe.Pointer(result)
__p.Pin(ptr)
return ptr
}())
}); __err != nil {
wadge.CurrentErrorHandler()(__err)
}
return
}

View File

@@ -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.

View File

@@ -0,0 +1,21 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package environment
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/environment@0.2.0 get-environment
//go:noescape
func wasmimport_GetEnvironment(result *cm.List[[2]string])
//go:wasmimport wasi:cli/environment@0.2.0 get-arguments
//go:noescape
func wasmimport_GetArguments(result *cm.List[string])
//go:wasmimport wasi:cli/environment@0.2.0 initial-cwd
//go:noescape
func wasmimport_InitialCWD(result *cm.Option[string])

View File

@@ -0,0 +1,38 @@
// 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/bytecodealliance/wasm-tools-go/cm"
)
// GetEnvironment represents the imported function "get-environment".
//
// get-environment: func() -> list<tuple<string, string>>
//
//go:nosplit
func GetEnvironment() (result cm.List[[2]string]) {
wasmimport_GetEnvironment(&result)
return
}
// GetArguments represents the imported function "get-arguments".
//
// get-arguments: func() -> list<string>
//
//go:nosplit
func GetArguments() (result cm.List[string]) {
wasmimport_GetArguments(&result)
return
}
// InitialCWD represents the imported function "initial-cwd".
//
// initial-cwd: func() -> option<string>
//
//go:nosplit
func InitialCWD() (result cm.Option[string]) {
wasmimport_InitialCWD(&result)
return
}

View File

@@ -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.

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package exit
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/exit@0.2.0 exit
//go:noescape
func wasmimport_Exit(status0 uint32)

View File

@@ -0,0 +1,19 @@
// 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/bytecodealliance/wasm-tools-go/cm"
)
// Exit represents the imported function "exit".
//
// exit: func(status: result)
//
//go:nosplit
func Exit(status cm.BoolResult) {
status0 := cm.BoolToU32(status)
wasmimport_Exit((uint32)(status0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package stderr
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/stderr@0.2.0 get-stderr
//go:noescape
func wasmimport_GetStderr() (result0 uint32)

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package stderr represents the imported interface "wasi:cli/stderr@0.2.0".
package stderr
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/streams"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// OutputStream represents the imported type alias "wasi:cli/stderr@0.2.0#output-stream".
//
// See [streams.OutputStream] for more information.
type OutputStream = streams.OutputStream
// GetStderr represents the imported function "get-stderr".
//
// get-stderr: func() -> output-stream
//
//go:nosplit
func GetStderr() (result OutputStream) {
result0 := wasmimport_GetStderr()
result = cm.Reinterpret[OutputStream]((uint32)(result0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package stdin
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/stdin@0.2.0 get-stdin
//go:noescape
func wasmimport_GetStdin() (result0 uint32)

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package stdin represents the imported interface "wasi:cli/stdin@0.2.0".
package stdin
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/streams"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// InputStream represents the imported type alias "wasi:cli/stdin@0.2.0#input-stream".
//
// See [streams.InputStream] for more information.
type InputStream = streams.InputStream
// GetStdin represents the imported function "get-stdin".
//
// get-stdin: func() -> input-stream
//
//go:nosplit
func GetStdin() (result InputStream) {
result0 := wasmimport_GetStdin()
result = cm.Reinterpret[InputStream]((uint32)(result0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package stdout
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/stdout@0.2.0 get-stdout
//go:noescape
func wasmimport_GetStdout() (result0 uint32)

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package stdout represents the imported interface "wasi:cli/stdout@0.2.0".
package stdout
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/streams"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// OutputStream represents the imported type alias "wasi:cli/stdout@0.2.0#output-stream".
//
// See [streams.OutputStream] for more information.
type OutputStream = streams.OutputStream
// GetStdout represents the imported function "get-stdout".
//
// get-stdout: func() -> output-stream
//
//go:nosplit
func GetStdout() (result OutputStream) {
result0 := wasmimport_GetStdout()
result = cm.Reinterpret[OutputStream]((uint32)(result0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package terminalinput represents the imported interface "wasi:cli/terminal-input@0.2.0".
package terminalinput
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// TerminalInput represents the imported resource "wasi:cli/terminal-input@0.2.0#terminal-input".
//
// 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
}

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package terminalinput
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/terminal-input@0.2.0 [resource-drop]terminal-input
//go:noescape
func wasmimport_TerminalInputResourceDrop(self0 uint32)

View File

@@ -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.

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package terminaloutput represents the imported interface "wasi:cli/terminal-output@0.2.0".
package terminaloutput
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// TerminalOutput represents the imported resource "wasi:cli/terminal-output@0.2.0#terminal-output".
//
// 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
}

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package terminaloutput
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/terminal-output@0.2.0 [resource-drop]terminal-output
//go:noescape
func wasmimport_TerminalOutputResourceDrop(self0 uint32)

View File

@@ -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.

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package terminalstderr represents the imported interface "wasi:cli/terminal-stderr@0.2.0".
package terminalstderr
import (
terminaloutput "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/cli/terminal-output"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// TerminalOutput represents the imported type alias "wasi:cli/terminal-stderr@0.2.0#terminal-output".
//
// See [terminaloutput.TerminalOutput] for more information.
type TerminalOutput = terminaloutput.TerminalOutput
// GetTerminalStderr represents the imported function "get-terminal-stderr".
//
// get-terminal-stderr: func() -> option<terminal-output>
//
//go:nosplit
func GetTerminalStderr() (result cm.Option[TerminalOutput]) {
wasmimport_GetTerminalStderr(&result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package terminalstderr
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/terminal-stderr@0.2.0 get-terminal-stderr
//go:noescape
func wasmimport_GetTerminalStderr(result *cm.Option[TerminalOutput])

View File

@@ -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.

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package terminalstdin represents the imported interface "wasi:cli/terminal-stdin@0.2.0".
package terminalstdin
import (
terminalinput "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/cli/terminal-input"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// TerminalInput represents the imported type alias "wasi:cli/terminal-stdin@0.2.0#terminal-input".
//
// See [terminalinput.TerminalInput] for more information.
type TerminalInput = terminalinput.TerminalInput
// GetTerminalStdin represents the imported function "get-terminal-stdin".
//
// get-terminal-stdin: func() -> option<terminal-input>
//
//go:nosplit
func GetTerminalStdin() (result cm.Option[TerminalInput]) {
wasmimport_GetTerminalStdin(&result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package terminalstdin
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/terminal-stdin@0.2.0 get-terminal-stdin
//go:noescape
func wasmimport_GetTerminalStdin(result *cm.Option[TerminalInput])

View File

@@ -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.

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package terminalstdout represents the imported interface "wasi:cli/terminal-stdout@0.2.0".
package terminalstdout
import (
terminaloutput "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/cli/terminal-output"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// TerminalOutput represents the imported type alias "wasi:cli/terminal-stdout@0.2.0#terminal-output".
//
// See [terminaloutput.TerminalOutput] for more information.
type TerminalOutput = terminaloutput.TerminalOutput
// GetTerminalStdout represents the imported function "get-terminal-stdout".
//
// get-terminal-stdout: func() -> option<terminal-output>
//
//go:nosplit
func GetTerminalStdout() (result cm.Option[TerminalOutput]) {
wasmimport_GetTerminalStdout(&result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package terminalstdout
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:cli@0.2.0".
//go:wasmimport wasi:cli/terminal-stdout@0.2.0 get-terminal-stdout
//go:noescape
func wasmimport_GetTerminalStdout(result *cm.Option[TerminalOutput])

View File

@@ -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.

View File

@@ -0,0 +1,70 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package monotonicclock represents the imported interface "wasi:clocks/monotonic-clock@0.2.0".
package monotonicclock
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/poll"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Pollable represents the imported type alias "wasi:clocks/monotonic-clock@0.2.0#pollable".
//
// See [poll.Pollable] for more information.
type Pollable = poll.Pollable
// Instant represents the u64 "wasi:clocks/monotonic-clock@0.2.0#instant".
//
// type instant = u64
type Instant uint64
// Duration represents the u64 "wasi:clocks/monotonic-clock@0.2.0#duration".
//
// type duration = u64
type Duration uint64
// Now represents the imported function "now".
//
// now: func() -> instant
//
//go:nosplit
func Now() (result Instant) {
result0 := wasmimport_Now()
result = (Instant)((uint64)(result0))
return
}
// Resolution represents the imported function "resolution".
//
// resolution: func() -> duration
//
//go:nosplit
func Resolution() (result Duration) {
result0 := wasmimport_Resolution()
result = (Duration)((uint64)(result0))
return
}
// SubscribeInstant represents the imported function "subscribe-instant".
//
// subscribe-instant: func(when: instant) -> pollable
//
//go:nosplit
func SubscribeInstant(when Instant) (result Pollable) {
when0 := (uint64)(when)
result0 := wasmimport_SubscribeInstant((uint64)(when0))
result = cm.Reinterpret[Pollable]((uint32)(result0))
return
}
// SubscribeDuration represents the imported function "subscribe-duration".
//
// subscribe-duration: func(when: duration) -> pollable
//
//go:nosplit
func SubscribeDuration(when Duration) (result Pollable) {
when0 := (uint64)(when)
result0 := wasmimport_SubscribeDuration((uint64)(when0))
result = cm.Reinterpret[Pollable]((uint32)(result0))
return
}

View File

@@ -0,0 +1,21 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package monotonicclock
// This file contains wasmimport and wasmexport declarations for "wasi:clocks@0.2.0".
//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 now
//go:noescape
func wasmimport_Now() (result0 uint64)
//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 resolution
//go:noescape
func wasmimport_Resolution() (result0 uint64)
//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 subscribe-instant
//go:noescape
func wasmimport_SubscribeInstant(when0 uint64) (result0 uint32)
//go:wasmimport wasi:clocks/monotonic-clock@0.2.0 subscribe-duration
//go:noescape
func wasmimport_SubscribeDuration(when0 uint64) (result0 uint32)

View File

@@ -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.

View File

@@ -0,0 +1,40 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package wallclock represents the imported interface "wasi:clocks/wall-clock@0.2.0".
package wallclock
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// DateTime represents the record "wasi:clocks/wall-clock@0.2.0#datetime".
//
// record datetime {
// seconds: u64,
// nanoseconds: u32,
// }
type DateTime struct {
_ cm.HostLayout
Seconds uint64
Nanoseconds uint32
}
// Now represents the imported function "now".
//
// now: func() -> datetime
//
//go:nosplit
func Now() (result DateTime) {
wasmimport_Now(&result)
return
}
// Resolution represents the imported function "resolution".
//
// resolution: func() -> datetime
//
//go:nosplit
func Resolution() (result DateTime) {
wasmimport_Resolution(&result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package wallclock
// This file contains wasmimport and wasmexport declarations for "wasi:clocks@0.2.0".
//go:wasmimport wasi:clocks/wall-clock@0.2.0 now
//go:noescape
func wasmimport_Now(result *DateTime)
//go:wasmimport wasi:clocks/wall-clock@0.2.0 resolution
//go:noescape
func wasmimport_Resolution(result *DateTime)

View File

@@ -0,0 +1,20 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package runtime
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
"unsafe"
)
// OptionStringShape is used for storage in variant or result types.
type OptionStringShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(cm.Option[string]{})]byte
}
// ConfigErrorShape is used for storage in variant or result types.
type ConfigErrorShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(ConfigError{})]byte
}

View File

@@ -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.

View File

@@ -0,0 +1,17 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package runtime
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:config@0.2.0-draft".
//go:wasmimport wasi:config/runtime@0.2.0-draft get
//go:noescape
func wasmimport_Get(key0 *uint8, key1 uint32, result *cm.Result[OptionStringShape, cm.Option[string], ConfigError])
//go:wasmimport wasi:config/runtime@0.2.0-draft get-all
//go:noescape
func wasmimport_GetAll(result *cm.Result[ConfigErrorShape, cm.List[[2]string], ConfigError])

View File

@@ -0,0 +1,86 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package runtime represents the imported interface "wasi:config/runtime@0.2.0-draft".
package runtime
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// ConfigError represents the variant "wasi:config/runtime@0.2.0-draft#config-error".
//
// An error type that encapsulates the different errors that can occur fetching config
//
// variant config-error {
// upstream(string),
// io(string),
// }
type ConfigError cm.Variant[uint8, string, string]
// ConfigErrorUpstream returns a [ConfigError] of case "upstream".
//
// This indicates an error from an "upstream" config source.
// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue
// buckets, etc),
// the error message is a string.
func ConfigErrorUpstream(data string) ConfigError {
return cm.New[ConfigError](0, data)
}
// Upstream returns a non-nil *[string] if [ConfigError] represents the variant case "upstream".
func (self *ConfigError) Upstream() *string {
return cm.Case[string](self, 0)
}
// ConfigErrorIO returns a [ConfigError] of case "io".
//
// This indicates an error from an I/O operation.
// As this could be almost _anything_ (such as a file read, network connection, etc),
// the error message is a string.
// Depending on how this ends up being consumed,
// we may consider moving this to use the `wasi:io/error` type instead.
// For simplicity right now in supporting multiple implementations, it is being left
// as a string.
func ConfigErrorIO(data string) ConfigError {
return cm.New[ConfigError](1, data)
}
// IO returns a non-nil *[string] if [ConfigError] represents the variant case "io".
func (self *ConfigError) IO() *string {
return cm.Case[string](self, 1)
}
var stringsConfigError = [2]string{
"upstream",
"io",
}
// String implements [fmt.Stringer], returning the variant case name of v.
func (v ConfigError) String() string {
return stringsConfigError[v.Tag()]
}
// Get represents the imported function "get".
//
// Gets a single opaque config value set at the given key if it exists
//
// get: func(key: string) -> result<option<string>, config-error>
//
//go:nosplit
func Get(key string) (result cm.Result[OptionStringShape, cm.Option[string], ConfigError]) {
key0, key1 := cm.LowerString(key)
wasmimport_Get((*uint8)(key0), (uint32)(key1), &result)
return
}
// GetAll represents the imported function "get-all".
//
// Gets a list of all set config data
//
// get-all: func() -> result<list<tuple<string, string>>, config-error>
//
//go:nosplit
func GetAll() (result cm.Result[ConfigErrorShape, cm.List[[2]string], ConfigError]) {
wasmimport_GetAll(&result)
return
}

View File

@@ -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.

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package preopens
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:filesystem@0.2.0".
//go:wasmimport wasi:filesystem/preopens@0.2.0 get-directories
//go:noescape
func wasmimport_GetDirectories(result *cm.List[cm.Tuple[Descriptor, string]])

View File

@@ -0,0 +1,24 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package preopens represents the imported interface "wasi:filesystem/preopens@0.2.0".
package preopens
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/filesystem/types"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Descriptor represents the imported type alias "wasi:filesystem/preopens@0.2.0#descriptor".
//
// See [types.Descriptor] for more information.
type Descriptor = types.Descriptor
// GetDirectories represents the imported function "get-directories".
//
// get-directories: func() -> list<tuple<descriptor, string>>
//
//go:nosplit
func GetDirectories() (result cm.List[cm.Tuple[Descriptor, string]]) {
wasmimport_GetDirectories(&result)
return
}

View File

@@ -0,0 +1,50 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package types
import (
wallclock "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/clocks/wall-clock"
"github.com/bytecodealliance/wasm-tools-go/cm"
"unsafe"
)
// MetadataHashValueShape is used for storage in variant or result types.
type MetadataHashValueShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(MetadataHashValue{})]byte
}
// TupleListU8BoolShape is used for storage in variant or result types.
type TupleListU8BoolShape struct {
_ cm.HostLayout
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 {
_ cm.HostLayout
shape [unsafe.Sizeof(DescriptorStat{})]byte
}
// OptionDirectoryEntryShape is used for storage in variant or result types.
type OptionDirectoryEntryShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(cm.Option[DirectoryEntry]{})]byte
}

View File

@@ -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.

View File

@@ -0,0 +1,133 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package types
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:filesystem@0.2.0".
//go:wasmimport wasi:filesystem/types@0.2.0 [resource-drop]descriptor
//go:noescape
func wasmimport_DescriptorResourceDrop(self0 uint32)
//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])
//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.append-via-stream
//go:noescape
func wasmimport_DescriptorAppendViaStream(self0 uint32, result *cm.Result[OutputStream, OutputStream, ErrorCode])
//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])
//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])
//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])
//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.is-same-object
//go:noescape
func wasmimport_DescriptorIsSameObject(self0 uint32, other0 uint32) (result0 uint32)
//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])
//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])
//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])
//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])
//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])
//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])
//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[InputStream, InputStream, ErrorCode])
//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])
//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])
//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])
//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])
//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])
//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])
//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.stat
//go:noescape
func wasmimport_DescriptorStat(self0 uint32, result *cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode])
//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])
//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])
//go:wasmimport wasi:filesystem/types@0.2.0 [method]descriptor.sync
//go:noescape
func wasmimport_DescriptorSync(self0 uint32, result *cm.Result[ErrorCode, struct{}, ErrorCode])
//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])
//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])
//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])
//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[OutputStream, OutputStream, ErrorCode])
//go:wasmimport wasi:filesystem/types@0.2.0 [resource-drop]directory-entry-stream
//go:noescape
func wasmimport_DirectoryEntryStreamResourceDrop(self0 uint32)
//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])
//go:wasmimport wasi:filesystem/types@0.2.0 filesystem-error-code
//go:noescape
func wasmimport_FilesystemErrorCode(err0 uint32, result *cm.Option[ErrorCode])

View File

@@ -0,0 +1,787 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package types represents the imported interface "wasi:filesystem/types@0.2.0".
package types
import (
wallclock "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/clocks/wall-clock"
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/streams"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// InputStream represents the imported type alias "wasi:filesystem/types@0.2.0#input-stream".
//
// See [streams.InputStream] for more information.
type InputStream = streams.InputStream
// OutputStream represents the imported type alias "wasi:filesystem/types@0.2.0#output-stream".
//
// See [streams.OutputStream] for more information.
type OutputStream = streams.OutputStream
// Error represents the imported type alias "wasi:filesystem/types@0.2.0#error".
//
// See [streams.Error] for more information.
type Error = streams.Error
// DateTime represents the type alias "wasi:filesystem/types@0.2.0#datetime".
//
// See [wallclock.DateTime] for more information.
type DateTime = wallclock.DateTime
// FileSize represents the u64 "wasi:filesystem/types@0.2.0#filesize".
//
// type filesize = u64
type FileSize uint64
// DescriptorType represents the enum "wasi:filesystem/types@0.2.0#descriptor-type".
//
// enum descriptor-type {
// unknown,
// block-device,
// character-device,
// directory,
// fifo,
// symbolic-link,
// regular-file,
// socket
// }
type DescriptorType uint8
const (
DescriptorTypeUnknown DescriptorType = iota
DescriptorTypeBlockDevice
DescriptorTypeCharacterDevice
DescriptorTypeDirectory
DescriptorTypeFIFO
DescriptorTypeSymbolicLink
DescriptorTypeRegularFile
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".
//
// flags descriptor-flags {
// read,
// write,
// file-integrity-sync,
// data-integrity-sync,
// requested-write-sync,
// mutate-directory,
// }
type DescriptorFlags uint8
const (
DescriptorFlagsRead DescriptorFlags = 1 << iota
DescriptorFlagsWrite
DescriptorFlagsFileIntegritySync
DescriptorFlagsDataIntegritySync
DescriptorFlagsRequestedWriteSync
DescriptorFlagsMutateDirectory
)
// PathFlags represents the flags "wasi:filesystem/types@0.2.0#path-flags".
//
// flags path-flags {
// symlink-follow,
// }
type PathFlags uint8
const (
PathFlagsSymlinkFollow PathFlags = 1 << iota
)
// OpenFlags represents the flags "wasi:filesystem/types@0.2.0#open-flags".
//
// flags open-flags {
// create,
// directory,
// exclusive,
// truncate,
// }
type OpenFlags uint8
const (
OpenFlagsCreate OpenFlags = 1 << iota
OpenFlagsDirectory
OpenFlagsExclusive
OpenFlagsTruncate
)
// LinkCount represents the u64 "wasi:filesystem/types@0.2.0#link-count".
//
// type link-count = u64
type LinkCount uint64
// DescriptorStat represents the record "wasi:filesystem/types@0.2.0#descriptor-stat".
//
// record descriptor-stat {
// %type: descriptor-type,
// link-count: link-count,
// size: filesize,
// data-access-timestamp: option<datetime>,
// data-modification-timestamp: option<datetime>,
// status-change-timestamp: option<datetime>,
// }
type DescriptorStat struct {
_ cm.HostLayout
Type DescriptorType
LinkCount LinkCount
Size FileSize
DataAccessTimestamp cm.Option[DateTime]
DataModificationTimestamp cm.Option[DateTime]
StatusChangeTimestamp cm.Option[DateTime]
}
// NewTimestamp represents the variant "wasi:filesystem/types@0.2.0#new-timestamp".
//
// variant new-timestamp {
// no-change,
// now,
// timestamp(datetime),
// }
type NewTimestamp cm.Variant[uint8, DateTime, DateTime]
// NewTimestampNoChange returns a [NewTimestamp] of case "no-change".
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".
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".
func NewTimestampTimestamp(data DateTime) NewTimestamp {
return cm.New[NewTimestamp](2, data)
}
// Timestamp returns a non-nil *[DateTime] if [NewTimestamp] represents the variant case "timestamp".
func (self *NewTimestamp) Timestamp() *DateTime {
return cm.Case[DateTime](self, 2)
}
var stringsNewTimestamp = [3]string{
"no-change",
"now",
"timestamp",
}
// String implements [fmt.Stringer], returning the variant case name of v.
func (v NewTimestamp) String() string {
return stringsNewTimestamp[v.Tag()]
}
// DirectoryEntry represents the record "wasi:filesystem/types@0.2.0#directory-entry".
//
// record directory-entry {
// %type: descriptor-type,
// name: string,
// }
type DirectoryEntry struct {
_ cm.HostLayout
Type DescriptorType
Name string
}
// ErrorCode represents the enum "wasi:filesystem/types@0.2.0#error-code".
//
// 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 (
ErrorCodeAccess ErrorCode = iota
ErrorCodeWouldBlock
ErrorCodeAlready
ErrorCodeBadDescriptor
ErrorCodeBusy
ErrorCodeDeadlock
ErrorCodeQuota
ErrorCodeExist
ErrorCodeFileTooLarge
ErrorCodeIllegalByteSequence
ErrorCodeInProgress
ErrorCodeInterrupted
ErrorCodeInvalid
ErrorCodeIO
ErrorCodeIsDirectory
ErrorCodeLoop
ErrorCodeTooManyLinks
ErrorCodeMessageSize
ErrorCodeNameTooLong
ErrorCodeNoDevice
ErrorCodeNoEntry
ErrorCodeNoLock
ErrorCodeInsufficientMemory
ErrorCodeInsufficientSpace
ErrorCodeNotDirectory
ErrorCodeNotEmpty
ErrorCodeNotRecoverable
ErrorCodeUnsupported
ErrorCodeNoTTY
ErrorCodeNoSuchDevice
ErrorCodeOverflow
ErrorCodeNotPermitted
ErrorCodePipe
ErrorCodeReadOnly
ErrorCodeInvalidSeek
ErrorCodeTextFileBusy
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".
//
// enum advice {
// normal,
// sequential,
// random,
// will-need,
// dont-need,
// no-reuse
// }
type Advice uint8
const (
AdviceNormal Advice = iota
AdviceSequential
AdviceRandom
AdviceWillNeed
AdviceDontNeed
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".
//
// record metadata-hash-value {
// lower: u64,
// upper: u64,
// }
type MetadataHashValue struct {
_ cm.HostLayout
Lower uint64
Upper uint64
}
// Descriptor represents the imported resource "wasi:filesystem/types@0.2.0#descriptor".
//
// 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
}
// Advise represents the imported method "advise".
//
// 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
}
// AppendViaStream represents the imported method "append-via-stream".
//
// append-via-stream: func() -> result<output-stream, error-code>
//
//go:nosplit
func (self Descriptor) AppendViaStream() (result cm.Result[OutputStream, OutputStream, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorAppendViaStream((uint32)(self0), &result)
return
}
// CreateDirectoryAt represents the imported method "create-directory-at".
//
// 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
}
// GetFlags represents the imported method "get-flags".
//
// get-flags: func() -> result<descriptor-flags, error-code>
//
//go:nosplit
func (self Descriptor) GetFlags() (result cm.Result[DescriptorFlags, DescriptorFlags, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorGetFlags((uint32)(self0), &result)
return
}
// GetType represents the imported method "get-type".
//
// get-type: func() -> result<descriptor-type, error-code>
//
//go:nosplit
func (self Descriptor) GetType() (result cm.Result[DescriptorType, DescriptorType, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorGetType((uint32)(self0), &result)
return
}
// IsSameObject represents the imported method "is-same-object".
//
// is-same-object: func(other: borrow<descriptor>) -> 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
}
// LinkAt represents the imported method "link-at".
//
// link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow<descriptor>,
// 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
}
// MetadataHash represents the imported method "metadata-hash".
//
// metadata-hash: func() -> result<metadata-hash-value, error-code>
//
//go:nosplit
func (self Descriptor) MetadataHash() (result cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorMetadataHash((uint32)(self0), &result)
return
}
// MetadataHashAt represents the imported method "metadata-hash-at".
//
// metadata-hash-at: func(path-flags: path-flags, path: string) -> result<metadata-hash-value,
// error-code>
//
//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
}
// OpenAt represents the imported method "open-at".
//
// open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags:
// descriptor-flags) -> result<descriptor, error-code>
//
//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
}
// Read represents the imported method "read".
//
// read: func(length: filesize, offset: filesize) -> result<tuple<list<u8>, 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
}
// ReadDirectory represents the imported method "read-directory".
//
// read-directory: func() -> result<directory-entry-stream, error-code>
//
//go:nosplit
func (self Descriptor) ReadDirectory() (result cm.Result[DirectoryEntryStream, DirectoryEntryStream, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorReadDirectory((uint32)(self0), &result)
return
}
// ReadViaStream represents the imported method "read-via-stream".
//
// read-via-stream: func(offset: filesize) -> result<input-stream, error-code>
//
//go:nosplit
func (self Descriptor) ReadViaStream(offset FileSize) (result cm.Result[InputStream, InputStream, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
offset0 := (uint64)(offset)
wasmimport_DescriptorReadViaStream((uint32)(self0), (uint64)(offset0), &result)
return
}
// ReadLinkAt represents the imported method "readlink-at".
//
// readlink-at: func(path: string) -> result<string, error-code>
//
//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
}
// RemoveDirectoryAt represents the imported method "remove-directory-at".
//
// 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
}
// RenameAt represents the imported method "rename-at".
//
// rename-at: func(old-path: string, new-descriptor: borrow<descriptor>, 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
}
// SetSize represents the imported method "set-size".
//
// 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
}
// SetTimes represents the imported method "set-times".
//
// 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
}
// SetTimesAt represents the imported method "set-times-at".
//
// 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
}
// Stat represents the imported method "stat".
//
// stat: func() -> result<descriptor-stat, error-code>
//
//go:nosplit
func (self Descriptor) Stat() (result cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_DescriptorStat((uint32)(self0), &result)
return
}
// StatAt represents the imported method "stat-at".
//
// stat-at: func(path-flags: path-flags, path: string) -> result<descriptor-stat,
// error-code>
//
//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
}
// SymlinkAt represents the imported method "symlink-at".
//
// 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
}
// Sync represents the imported method "sync".
//
// 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
}
// SyncData represents the imported method "sync-data".
//
// 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
}
// UnlinkFileAt represents the imported method "unlink-file-at".
//
// 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
}
// Write represents the imported method "write".
//
// write: func(buffer: list<u8>, offset: filesize) -> result<filesize, error-code>
//
//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
}
// WriteViaStream represents the imported method "write-via-stream".
//
// write-via-stream: func(offset: filesize) -> result<output-stream, error-code>
//
//go:nosplit
func (self Descriptor) WriteViaStream(offset FileSize) (result cm.Result[OutputStream, OutputStream, ErrorCode]) {
self0 := cm.Reinterpret[uint32](self)
offset0 := (uint64)(offset)
wasmimport_DescriptorWriteViaStream((uint32)(self0), (uint64)(offset0), &result)
return
}
// DirectoryEntryStream represents the imported resource "wasi:filesystem/types@0.2.0#directory-entry-stream".
//
// 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
}
// ReadDirectoryEntry represents the imported method "read-directory-entry".
//
// read-directory-entry: func() -> result<option<directory-entry>, 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
}
// FilesystemErrorCode represents the imported function "filesystem-error-code".
//
// filesystem-error-code: func(err: borrow<error>) -> option<error-code>
//
//go:nosplit
func FilesystemErrorCode(err Error) (result cm.Option[ErrorCode]) {
err0 := cm.Reinterpret[uint32](err)
wasmimport_FilesystemErrorCode((uint32)(err0), &result)
return
}

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package outgoinghandler
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/http/types"
"github.com/bytecodealliance/wasm-tools-go/cm"
"unsafe"
)
// ErrorCodeShape is used for storage in variant or result types.
type ErrorCodeShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(types.ErrorCode{})]byte
}
func lower_OptionRequestOptions(v cm.Option[RequestOptions]) (f0 uint32, f1 uint32) {
some := v.Some()
if some != nil {
f0 = 1
v1 := cm.Reinterpret[uint32](*some)
f1 = (uint32)(v1)
}
return
}

View File

@@ -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.

View File

@@ -0,0 +1,42 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package outgoinghandler represents the imported interface "wasi:http/outgoing-handler@0.2.0".
package outgoinghandler
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/http/types"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// OutgoingRequest represents the imported type alias "wasi:http/outgoing-handler@0.2.0#outgoing-request".
//
// See [types.OutgoingRequest] for more information.
type OutgoingRequest = types.OutgoingRequest
// RequestOptions represents the imported type alias "wasi:http/outgoing-handler@0.2.0#request-options".
//
// See [types.RequestOptions] for more information.
type RequestOptions = types.RequestOptions
// FutureIncomingResponse represents the imported type alias "wasi:http/outgoing-handler@0.2.0#future-incoming-response".
//
// See [types.FutureIncomingResponse] for more information.
type FutureIncomingResponse = types.FutureIncomingResponse
// ErrorCode represents the type alias "wasi:http/outgoing-handler@0.2.0#error-code".
//
// See [types.ErrorCode] for more information.
type ErrorCode = types.ErrorCode
// Handle represents the imported function "handle".
//
// handle: func(request: outgoing-request, options: option<request-options>) -> result<future-incoming-response,
// error-code>
//
//go:nosplit
func Handle(request OutgoingRequest, options cm.Option[RequestOptions]) (result cm.Result[ErrorCodeShape, FutureIncomingResponse, ErrorCode]) {
request0 := cm.Reinterpret[uint32](request)
options0, options1 := lower_OptionRequestOptions(options)
wasmimport_Handle((uint32)(request0), (uint32)(options0), (uint32)(options1), &result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package outgoinghandler
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:http@0.2.0".
//go:wasmimport wasi:http/outgoing-handler@0.2.0 handle
//go:noescape
func wasmimport_Handle(request0 uint32, options0 uint32, options1 uint32, result *cm.Result[ErrorCodeShape, FutureIncomingResponse, ErrorCode])

View File

@@ -0,0 +1,264 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package types
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
"unsafe"
)
// OptionFieldSizePayloadShape is used for storage in variant or result types.
type OptionFieldSizePayloadShape struct {
_ cm.HostLayout
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[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 {
_ cm.HostLayout
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
}
func lower_OptionTrailers(v cm.Option[Trailers]) (f0 uint32, f1 uint32) {
some := v.Some()
if some != nil {
f0 = 1
v1 := cm.Reinterpret[uint32](*some)
f1 = (uint32)(v1)
}
return
}

View File

@@ -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.

View File

@@ -0,0 +1,257 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package types
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:http@0.2.0".
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]fields
//go:noescape
func wasmimport_FieldsResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [constructor]fields
//go:noescape
func wasmimport_NewFields() (result0 uint32)
//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])
//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])
//go:wasmimport wasi:http/types@0.2.0 [method]fields.clone
//go:noescape
func wasmimport_FieldsClone(self0 uint32) (result0 uint32)
//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])
//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]])
//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])
//go:wasmimport wasi:http/types@0.2.0 [method]fields.has
//go:noescape
func wasmimport_FieldsHas(self0 uint32, name0 *uint8, name1 uint32) (result0 uint32)
//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])
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-request
//go:noescape
func wasmimport_IncomingRequestResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.authority
//go:noescape
func wasmimport_IncomingRequestAuthority(self0 uint32, result *cm.Option[string])
//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{}])
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.headers
//go:noescape
func wasmimport_IncomingRequestHeaders(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.method
//go:noescape
func wasmimport_IncomingRequestMethod(self0 uint32, result *Method)
//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])
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-request.scheme
//go:noescape
func wasmimport_IncomingRequestScheme(self0 uint32, result *cm.Option[Scheme])
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-request
//go:noescape
func wasmimport_OutgoingRequestResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [constructor]outgoing-request
//go:noescape
func wasmimport_NewOutgoingRequest(headers0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.authority
//go:noescape
func wasmimport_OutgoingRequestAuthority(self0 uint32, result *cm.Option[string])
//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{}])
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.headers
//go:noescape
func wasmimport_OutgoingRequestHeaders(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.method
//go:noescape
func wasmimport_OutgoingRequestMethod(self0 uint32, result *Method)
//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])
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-request.scheme
//go:noescape
func wasmimport_OutgoingRequestScheme(self0 uint32, result *cm.Option[Scheme])
//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)
//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)
//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)
//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)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]request-options
//go:noescape
func wasmimport_RequestOptionsResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [constructor]request-options
//go:noescape
func wasmimport_NewRequestOptions() (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]request-options.between-bytes-timeout
//go:noescape
func wasmimport_RequestOptionsBetweenBytesTimeout(self0 uint32, result *cm.Option[Duration])
//go:wasmimport wasi:http/types@0.2.0 [method]request-options.connect-timeout
//go:noescape
func wasmimport_RequestOptionsConnectTimeout(self0 uint32, result *cm.Option[Duration])
//go:wasmimport wasi:http/types@0.2.0 [method]request-options.first-byte-timeout
//go:noescape
func wasmimport_RequestOptionsFirstByteTimeout(self0 uint32, result *cm.Option[Duration])
//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)
//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)
//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)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]response-outparam
//go:noescape
func wasmimport_ResponseOutparamResourceDrop(self0 uint32)
//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)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-response
//go:noescape
func wasmimport_IncomingResponseResourceDrop(self0 uint32)
//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{}])
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-response.headers
//go:noescape
func wasmimport_IncomingResponseHeaders(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-response.status
//go:noescape
func wasmimport_IncomingResponseStatus(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]incoming-body
//go:noescape
func wasmimport_IncomingBodyResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [static]incoming-body.finish
//go:noescape
func wasmimport_IncomingBodyFinish(this0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [method]incoming-body.stream
//go:noescape
func wasmimport_IncomingBodyStream(self0 uint32, result *cm.Result[InputStream, InputStream, struct{}])
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]future-trailers
//go:noescape
func wasmimport_FutureTrailersResourceDrop(self0 uint32)
//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[Trailers], ErrorCode], cm.Result[ErrorCodeShape, cm.Option[Trailers], ErrorCode], struct{}]])
//go:wasmimport wasi:http/types@0.2.0 [method]future-trailers.subscribe
//go:noescape
func wasmimport_FutureTrailersSubscribe(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-response
//go:noescape
func wasmimport_OutgoingResponseResourceDrop(self0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [constructor]outgoing-response
//go:noescape
func wasmimport_NewOutgoingResponse(headers0 uint32) (result0 uint32)
//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{}])
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.headers
//go:noescape
func wasmimport_OutgoingResponseHeaders(self0 uint32) (result0 uint32)
//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)
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-response.status-code
//go:noescape
func wasmimport_OutgoingResponseStatusCode(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]outgoing-body
//go:noescape
func wasmimport_OutgoingBodyResourceDrop(self0 uint32)
//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])
//go:wasmimport wasi:http/types@0.2.0 [method]outgoing-body.write
//go:noescape
func wasmimport_OutgoingBodyWrite(self0 uint32, result *cm.Result[OutputStream, OutputStream, struct{}])
//go:wasmimport wasi:http/types@0.2.0 [resource-drop]future-incoming-response
//go:noescape
func wasmimport_FutureIncomingResponseResourceDrop(self0 uint32)
//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{}]])
//go:wasmimport wasi:http/types@0.2.0 [method]future-incoming-response.subscribe
//go:noescape
func wasmimport_FutureIncomingResponseSubscribe(self0 uint32) (result0 uint32)
//go:wasmimport wasi:http/types@0.2.0 http-error-code
//go:noescape
func wasmimport_HTTPErrorCode(err0 uint32, result *cm.Option[ErrorCode])

File diff suppressed because it is too large Load Diff

View File

@@ -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.

View File

@@ -0,0 +1,35 @@
// 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/bytecodealliance/wasm-tools-go/cm"
)
// Error represents the imported resource "wasi:io/error@0.2.0#error".
//
// 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
}
// ToDebugString represents the imported method "to-debug-string".
//
// to-debug-string: func() -> string
//
//go:nosplit
func (self Error) ToDebugString() (result string) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_ErrorToDebugString((uint32)(self0), &result)
return
}

View File

@@ -0,0 +1,13 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package ioerror
// This file contains wasmimport and wasmexport declarations for "wasi:io@0.2.0".
//go:wasmimport wasi:io/error@0.2.0 [resource-drop]error
//go:noescape
func wasmimport_ErrorResourceDrop(self0 uint32)
//go:wasmimport wasi:io/error@0.2.0 [method]error.to-debug-string
//go:noescape
func wasmimport_ErrorToDebugString(self0 uint32, result *string)

View File

@@ -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.

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package poll
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:io@0.2.0".
//go:wasmimport wasi:io/poll@0.2.0 [resource-drop]pollable
//go:noescape
func wasmimport_PollableResourceDrop(self0 uint32)
//go:wasmimport wasi:io/poll@0.2.0 [method]pollable.block
//go:noescape
func wasmimport_PollableBlock(self0 uint32)
//go:wasmimport wasi:io/poll@0.2.0 [method]pollable.ready
//go:noescape
func wasmimport_PollableReady(self0 uint32) (result0 uint32)
//go:wasmimport wasi:io/poll@0.2.0 poll
//go:noescape
func wasmimport_Poll(in0 *Pollable, in1 uint32, result *cm.List[uint32])

View File

@@ -0,0 +1,58 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package poll represents the imported interface "wasi:io/poll@0.2.0".
package poll
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Pollable represents the imported resource "wasi:io/poll@0.2.0#pollable".
//
// 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
}
// Block represents the imported method "block".
//
// block: func()
//
//go:nosplit
func (self Pollable) Block() {
self0 := cm.Reinterpret[uint32](self)
wasmimport_PollableBlock((uint32)(self0))
return
}
// Ready represents the imported method "ready".
//
// 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
}
// Poll represents the imported function "poll".
//
// poll: func(in: list<borrow<pollable>>) -> list<u32>
//
//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
}

View File

@@ -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.

View File

@@ -0,0 +1,77 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package streams
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:io@0.2.0".
//go:wasmimport wasi:io/streams@0.2.0 [resource-drop]input-stream
//go:noescape
func wasmimport_InputStreamResourceDrop(self0 uint32)
//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])
//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])
//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])
//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])
//go:wasmimport wasi:io/streams@0.2.0 [method]input-stream.subscribe
//go:noescape
func wasmimport_InputStreamSubscribe(self0 uint32) (result0 uint32)
//go:wasmimport wasi:io/streams@0.2.0 [resource-drop]output-stream
//go:noescape
func wasmimport_OutputStreamResourceDrop(self0 uint32)
//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])
//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])
//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])
//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])
//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])
//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])
//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])
//go:wasmimport wasi:io/streams@0.2.0 [method]output-stream.subscribe
//go:noescape
func wasmimport_OutputStreamSubscribe(self0 uint32) (result0 uint32)
//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])
//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])

View File

@@ -0,0 +1,270 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package streams represents the imported interface "wasi:io/streams@0.2.0".
package streams
import (
ioerror "gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/error"
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/io/poll"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Error represents the imported type alias "wasi:io/streams@0.2.0#error".
//
// See [ioerror.Error] for more information.
type Error = ioerror.Error
// Pollable represents the imported type alias "wasi:io/streams@0.2.0#pollable".
//
// See [poll.Pollable] for more information.
type Pollable = poll.Pollable
// StreamError represents the imported variant "wasi:io/streams@0.2.0#stream-error".
//
// variant stream-error {
// last-operation-failed(error),
// closed,
// }
type StreamError cm.Variant[uint8, Error, Error]
// StreamErrorLastOperationFailed returns a [StreamError] of case "last-operation-failed".
func StreamErrorLastOperationFailed(data Error) StreamError {
return cm.New[StreamError](0, data)
}
// LastOperationFailed returns a non-nil *[Error] if [StreamError] represents the variant case "last-operation-failed".
func (self *StreamError) LastOperationFailed() *Error {
return cm.Case[Error](self, 0)
}
// StreamErrorClosed returns a [StreamError] of case "closed".
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
}
var stringsStreamError = [2]string{
"last-operation-failed",
"closed",
}
// String implements [fmt.Stringer], returning the variant case name of v.
func (v StreamError) String() string {
return stringsStreamError[v.Tag()]
}
// InputStream represents the imported resource "wasi:io/streams@0.2.0#input-stream".
//
// 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
}
// BlockingRead represents the imported method "blocking-read".
//
// blocking-read: func(len: u64) -> result<list<u8>, 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
}
// BlockingSkip represents the imported method "blocking-skip".
//
// blocking-skip: func(len: u64) -> result<u64, stream-error>
//
//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
}
// Read represents the imported method "read".
//
// read: func(len: u64) -> result<list<u8>, 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
}
// Skip represents the imported method "skip".
//
// skip: func(len: u64) -> result<u64, stream-error>
//
//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
}
// Subscribe represents the imported method "subscribe".
//
// subscribe: func() -> pollable
//
//go:nosplit
func (self InputStream) Subscribe() (result Pollable) {
self0 := cm.Reinterpret[uint32](self)
result0 := wasmimport_InputStreamSubscribe((uint32)(self0))
result = cm.Reinterpret[Pollable]((uint32)(result0))
return
}
// OutputStream represents the imported resource "wasi:io/streams@0.2.0#output-stream".
//
// 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
}
// BlockingFlush represents the imported method "blocking-flush".
//
// 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
}
// BlockingSplice represents the imported method "blocking-splice".
//
// blocking-splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>
//
//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
}
// BlockingWriteAndFlush represents the imported method "blocking-write-and-flush".
//
// blocking-write-and-flush: func(contents: list<u8>) -> 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
}
// BlockingWriteZeroesAndFlush represents the imported method "blocking-write-zeroes-and-flush".
//
// 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
}
// CheckWrite represents the imported method "check-write".
//
// check-write: func() -> result<u64, stream-error>
//
//go:nosplit
func (self OutputStream) CheckWrite() (result cm.Result[uint64, uint64, StreamError]) {
self0 := cm.Reinterpret[uint32](self)
wasmimport_OutputStreamCheckWrite((uint32)(self0), &result)
return
}
// Flush represents the imported method "flush".
//
// 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
}
// Splice represents the imported method "splice".
//
// splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>
//
//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
}
// Subscribe represents the imported method "subscribe".
//
// subscribe: func() -> pollable
//
//go:nosplit
func (self OutputStream) Subscribe() (result Pollable) {
self0 := cm.Reinterpret[uint32](self)
result0 := wasmimport_OutputStreamSubscribe((uint32)(self0))
result = cm.Reinterpret[Pollable]((uint32)(result0))
return
}
// Write represents the imported method "write".
//
// write: func(contents: list<u8>) -> 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
}
// WriteZeroes represents the imported method "write-zeroes".
//
// 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
}

View File

@@ -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.

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package logging
// This file contains wasmimport and wasmexport declarations for "wasi:logging@0.1.0-draft".
//go:wasmimport wasi:logging/logging@0.1.0-draft log
//go:noescape
func wasmimport_Log(level0 uint32, context0 *uint8, context1 uint32, message0 *uint8, message1 uint32)

View File

@@ -0,0 +1,82 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package logging represents the imported interface "wasi:logging/logging@0.1.0-draft".
//
// WASI Logging is a logging API intended to let users emit log messages with
// simple priority levels and context values.
package logging
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Level represents the enum "wasi:logging/logging@0.1.0-draft#level".
//
// A log level, describing a kind of message.
//
// enum level {
// trace,
// debug,
// info,
// warn,
// error,
// critical
// }
type Level uint8
const (
// Describes messages about the values of variables and the flow of
// control within a program.
LevelTrace Level = iota
// Describes messages likely to be of interest to someone debugging a
// program.
LevelDebug
// Describes messages likely to be of interest to someone monitoring a
// program.
LevelInfo
// Describes messages indicating hazardous situations.
LevelWarn
// Describes messages indicating serious errors.
LevelError
// Describes messages indicating fatal errors.
LevelCritical
)
var stringsLevel = [6]string{
"trace",
"debug",
"info",
"warn",
"error",
"critical",
}
// String implements [fmt.Stringer], returning the enum case name of e.
func (e Level) String() string {
return stringsLevel[e]
}
// Log represents the imported function "log".
//
// Emit a log message.
//
// A log message has a `level` describing what kind of message is being
// sent, a context, which is an uninterpreted string meant to help
// consumers group similar messages, and a string containing the message
// text.
//
// log: func(level: level, context: string, message: string)
//
//go:nosplit
func Log(level Level, context string, message string) {
level0 := (uint32)(level)
context0, context1 := cm.LowerString(context)
message0, message1 := cm.LowerString(message)
wasmimport_Log((uint32)(level0), (*uint8)(context0), (uint32)(context1), (*uint8)(message0), (uint32)(message1))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,14 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package insecureseed represents the imported interface "wasi:random/insecure-seed@0.2.0".
package insecureseed
// InsecureSeed represents the imported function "insecure-seed".
//
// insecure-seed: func() -> tuple<u64, u64>
//
//go:nosplit
func InsecureSeed() (result [2]uint64) {
wasmimport_InsecureSeed(&result)
return
}

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package insecureseed
// This file contains wasmimport and wasmexport declarations for "wasi:random@0.2.0".
//go:wasmimport wasi:random/insecure-seed@0.2.0 insecure-seed
//go:noescape
func wasmimport_InsecureSeed(result *[2]uint64)

View File

@@ -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.

View File

@@ -0,0 +1,17 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package insecure
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:random@0.2.0".
//go:wasmimport wasi:random/insecure@0.2.0 get-insecure-random-bytes
//go:noescape
func wasmimport_GetInsecureRandomBytes(len0 uint64, result *cm.List[uint8])
//go:wasmimport wasi:random/insecure@0.2.0 get-insecure-random-u64
//go:noescape
func wasmimport_GetInsecureRandomU64() (result0 uint64)

View File

@@ -0,0 +1,30 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package insecure represents the imported interface "wasi:random/insecure@0.2.0".
package insecure
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// GetInsecureRandomBytes represents the imported function "get-insecure-random-bytes".
//
// get-insecure-random-bytes: func(len: u64) -> list<u8>
//
//go:nosplit
func GetInsecureRandomBytes(len_ uint64) (result cm.List[uint8]) {
len0 := (uint64)(len_)
wasmimport_GetInsecureRandomBytes((uint64)(len0), &result)
return
}
// GetInsecureRandomU64 represents the imported function "get-insecure-random-u64".
//
// get-insecure-random-u64: func() -> u64
//
//go:nosplit
func GetInsecureRandomU64() (result uint64) {
result0 := wasmimport_GetInsecureRandomU64()
result = (uint64)((uint64)(result0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,17 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package random
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// This file contains wasmimport and wasmexport declarations for "wasi:random@0.2.0".
//go:wasmimport wasi:random/random@0.2.0 get-random-bytes
//go:noescape
func wasmimport_GetRandomBytes(len0 uint64, result *cm.List[uint8])
//go:wasmimport wasi:random/random@0.2.0 get-random-u64
//go:noescape
func wasmimport_GetRandomU64() (result0 uint64)

View File

@@ -0,0 +1,30 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package random represents the imported interface "wasi:random/random@0.2.0".
package random
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// GetRandomBytes represents the imported function "get-random-bytes".
//
// get-random-bytes: func(len: u64) -> list<u8>
//
//go:nosplit
func GetRandomBytes(len_ uint64) (result cm.List[uint8]) {
len0 := (uint64)(len_)
wasmimport_GetRandomBytes((uint64)(len0), &result)
return
}
// GetRandomU64 represents the imported function "get-random-u64".
//
// get-random-u64: func() -> u64
//
//go:nosplit
func GetRandomU64() (result uint64) {
result0 := wasmimport_GetRandomU64()
result = (uint64)((uint64)(result0))
return
}

View File

@@ -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.

View File

@@ -0,0 +1,25 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
// Package instancenetwork represents the imported interface "wasi:sockets/instance-network@0.2.0".
package instancenetwork
import (
"gitea.rebus.ninja/lore/wasm-nats-stream-client/gen/wasi/sockets/network"
"github.com/bytecodealliance/wasm-tools-go/cm"
)
// Network represents the imported type alias "wasi:sockets/instance-network@0.2.0#network".
//
// See [network.Network] for more information.
type Network = network.Network
// InstanceNetwork represents the imported function "instance-network".
//
// instance-network: func() -> network
//
//go:nosplit
func InstanceNetwork() (result Network) {
result0 := wasmimport_InstanceNetwork()
result = cm.Reinterpret[Network]((uint32)(result0))
return
}

View File

@@ -0,0 +1,9 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package instancenetwork
// This file contains wasmimport and wasmexport declarations for "wasi:sockets@0.2.0".
//go:wasmimport wasi:sockets/instance-network@0.2.0 instance-network
//go:noescape
func wasmimport_InstanceNetwork() (result0 uint32)

View File

@@ -0,0 +1,14 @@
// Code generated by wit-bindgen-go. DO NOT EDIT.
package ipnamelookup
import (
"github.com/bytecodealliance/wasm-tools-go/cm"
"unsafe"
)
// OptionIPAddressShape is used for storage in variant or result types.
type OptionIPAddressShape struct {
_ cm.HostLayout
shape [unsafe.Sizeof(cm.Option[IPAddress]{})]byte
}

View File

@@ -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.

Some files were not shown because too many files have changed in this diff Show More