diff --git a/crates/templates/src/manager.rs b/crates/templates/src/manager.rs index 39b0f5e7c8..92f06f4cee 100644 --- a/crates/templates/src/manager.rs +++ b/crates/templates/src/manager.rs @@ -615,7 +615,7 @@ mod tests { } } - const TPLS_IN_THIS: usize = 12; + const TPLS_IN_THIS: usize = 13; #[tokio::test] async fn can_install_into_new_directory() { diff --git a/templates/http-c/content/README.md b/templates/http-c/content/README.md new file mode 100644 index 0000000000..b658ed3a78 --- /dev/null +++ b/templates/http-c/content/README.md @@ -0,0 +1,23 @@ +# Prerequisites + +You will need: + +* The WASI SDK + * Installation: https://github.com/WebAssembly/wasi-sdk#install + * Releases: https://github.com/WebAssembly/wasi-sdk/releases + +# Building + +* Set the `WASI_SDK_PATH` environment variable to the root of your WASI SDK installation (per the installation instructions at https://github.com/WebAssembly/wasi-sdk#install) +* Run `spin build` + +# WASI and Spin host bindings + +The `bindings` directory contains generated bindings for Spin. If you need to regenerate bindings: + +* Install `wit-bindgen` (https://github.com/bytecodealliance/wit-bindgen#cli-installation) - requires Rust (https://rust-lang.org/tools/install/) +* Copy the `wit` directory from https://github.com/spinframework/spin into this folder +* Delete the existing `bindings` directory +* Run `wit-bindgen c ./wit/ --out-dir bindings -w http-trigger` + +However, C bindings for WASI P3 and other async APIs are not yet mature, so if you do need to regenerate bindings, it is currently recommended that you **NOT** do so from Spin `HEAD`. diff --git a/templates/http-c/content/bindings/http_trigger.c b/templates/http-c/content/bindings/http_trigger.c new file mode 100644 index 0000000000..656f83ebd0 --- /dev/null +++ b/templates/http-c/content/bindings/http_trigger.c @@ -0,0 +1,13534 @@ +// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT! +#include "http_trigger.h" +#include +#include + +// Imported Functions from `spin:postgres/postgres@3.0.0` + +__attribute__((__import_module__("spin:postgres/postgres@3.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_spin_postgres_3_0_0_postgres_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:postgres/postgres@3.0.0"), __import_name__("[method]connection.query"))) +extern void __wasm_import_spin_postgres_3_0_0_postgres_method_connection_query(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:postgres/postgres@3.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_spin_postgres_3_0_0_postgres_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `spin:postgres/postgres@4.0.0` + +__attribute__((__import_module__("spin:postgres/postgres@4.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_spin_postgres_4_0_0_postgres_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:postgres/postgres@4.0.0"), __import_name__("[method]connection.query"))) +extern void __wasm_import_spin_postgres_4_0_0_postgres_method_connection_query(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:postgres/postgres@4.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_spin_postgres_4_0_0_postgres_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `spin:sqlite/sqlite@3.0.0` + +__attribute__((__import_module__("spin:sqlite/sqlite@3.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_spin_sqlite_sqlite_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:sqlite/sqlite@3.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_spin_sqlite_sqlite_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("spin:sqlite/sqlite@3.0.0"), __import_name__("[method]connection.last-insert-rowid"))) +extern int64_t __wasm_import_spin_sqlite_sqlite_method_connection_last_insert_rowid(int32_t); + +__attribute__((__import_module__("spin:sqlite/sqlite@3.0.0"), __import_name__("[method]connection.changes"))) +extern int64_t __wasm_import_spin_sqlite_sqlite_method_connection_changes(int32_t); + +// Imported Functions from `wasi:config/store@0.2.0-draft-2024-09-27` + +__attribute__((__import_module__("wasi:config/store@0.2.0-draft-2024-09-27"), __import_name__("get"))) +extern void __wasm_import_wasi_config_store_get(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:config/store@0.2.0-draft-2024-09-27"), __import_name__("get-all"))) +extern void __wasm_import_wasi_config_store_get_all(uint8_t *); + +// Imported Functions from `wasi:io/poll@0.2.0` + +__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.ready"))) +extern int32_t __wasm_import_wasi_io_0_2_0_poll_method_pollable_ready(int32_t); + +__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[method]pollable.block"))) +extern void __wasm_import_wasi_io_0_2_0_poll_method_pollable_block(int32_t); + +__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("poll"))) +extern void __wasm_import_wasi_io_0_2_0_poll_poll(uint8_t *, size_t, uint8_t *); + +// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` + +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("now"))) +extern int64_t __wasm_import_wasi_clocks_0_2_0_monotonic_clock_now(void); + +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("resolution"))) +extern int64_t __wasm_import_wasi_clocks_0_2_0_monotonic_clock_resolution(void); + +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-instant"))) +extern int32_t __wasm_import_wasi_clocks_0_2_0_monotonic_clock_subscribe_instant(int64_t); + +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0"), __import_name__("subscribe-duration"))) +extern int32_t __wasm_import_wasi_clocks_0_2_0_monotonic_clock_subscribe_duration(int64_t); + +// Imported Functions from `wasi:io/error@0.2.0` + +__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[method]error.to-debug-string"))) +extern void __wasm_import_wasi_io_0_2_0_error_method_error_to_debug_string(int32_t, uint8_t *); + +// Imported Functions from `wasi:io/streams@0.2.0` + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.read"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_input_stream_read(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-read"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_input_stream_blocking_read(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.skip"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_input_stream_skip(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.blocking-skip"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_input_stream_blocking_skip(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]input-stream.subscribe"))) +extern int32_t __wasm_import_wasi_io_0_2_0_streams_method_input_stream_subscribe(int32_t); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.check-write"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_check_write(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_write(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-and-flush"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.flush"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_flush(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-flush"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_flush(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.subscribe"))) +extern int32_t __wasm_import_wasi_io_0_2_0_streams_method_output_stream_subscribe(int32_t); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.write-zeroes"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_write_zeroes(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-write-zeroes-and-flush"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_write_zeroes_and_flush(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.splice"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_splice(int32_t, int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[method]output-stream.blocking-splice"))) +extern void __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_splice(int32_t, int32_t, int64_t, uint8_t *); + +// Imported Functions from `wasi:http/types@0.2.0` + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("http-error-code"))) +extern void __wasm_import_wasi_http_0_2_0_types_http_error_code(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[constructor]fields"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_constructor_fields(void); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[static]fields.from-list"))) +extern void __wasm_import_wasi_http_0_2_0_types_static_fields_from_list(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.get"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_fields_get(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.has"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_fields_has(int32_t, uint8_t *, size_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.set"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_fields_set(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.delete"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_fields_delete(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.append"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_fields_append(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.entries"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_fields_entries(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]fields.clone"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_fields_clone(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.method"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_request_method(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.path-with-query"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_request_path_with_query(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.scheme"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_request_scheme(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.authority"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_request_authority(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.headers"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_incoming_request_headers(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-request.consume"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_request_consume(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[constructor]outgoing-request"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_constructor_outgoing_request(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.body"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_body(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.method"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_method(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.set-method"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_method(int32_t, int32_t, uint8_t *, size_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.path-with-query"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_path_with_query(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.set-path-with-query"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_path_with_query(int32_t, int32_t, uint8_t *, size_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.scheme"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_scheme(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.set-scheme"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_scheme(int32_t, int32_t, int32_t, uint8_t *, size_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.authority"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_authority(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.set-authority"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_authority(int32_t, int32_t, uint8_t *, size_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-request.headers"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_headers(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[constructor]request-options"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_constructor_request_options(void); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.connect-timeout"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_request_options_connect_timeout(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.set-connect-timeout"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_request_options_set_connect_timeout(int32_t, int32_t, int64_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.first-byte-timeout"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_request_options_first_byte_timeout(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.set-first-byte-timeout"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_request_options_set_first_byte_timeout(int32_t, int32_t, int64_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.between-bytes-timeout"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_request_options_between_bytes_timeout(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]request-options.set-between-bytes-timeout"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_request_options_set_between_bytes_timeout(int32_t, int32_t, int64_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[static]response-outparam.set"))) +extern void __wasm_import_wasi_http_0_2_0_types_static_response_outparam_set(int32_t, int32_t, int32_t, int32_t, int64_t, uint8_t *, uint8_t *, size_t, int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-response.status"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_incoming_response_status(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-response.headers"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_incoming_response_headers(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-response.consume"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_response_consume(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]incoming-body.stream"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_incoming_body_stream(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[static]incoming-body.finish"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_static_incoming_body_finish(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]future-trailers.subscribe"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_future_trailers_subscribe(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]future-trailers.get"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_future_trailers_get(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[constructor]outgoing-response"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_constructor_outgoing_response(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-response.status-code"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_status_code(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-response.set-status-code"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_set_status_code(int32_t, int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-response.headers"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_headers(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-response.body"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_body(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]outgoing-body.write"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_outgoing_body_write(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[static]outgoing-body.finish"))) +extern void __wasm_import_wasi_http_0_2_0_types_static_outgoing_body_finish(int32_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]future-incoming-response.subscribe"))) +extern int32_t __wasm_import_wasi_http_0_2_0_types_method_future_incoming_response_subscribe(int32_t); + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[method]future-incoming-response.get"))) +extern void __wasm_import_wasi_http_0_2_0_types_method_future_incoming_response_get(int32_t, uint8_t *); + +// Imported Functions from `wasi:http/outgoing-handler@0.2.0` + +__attribute__((__import_module__("wasi:http/outgoing-handler@0.2.0"), __import_name__("handle"))) +extern void __wasm_import_wasi_http_0_2_0_outgoing_handler_handle(int32_t, int32_t, int32_t, uint8_t *); + +// Imported Functions from `fermyon:spin/llm@2.0.0` + +__attribute__((__import_module__("fermyon:spin/llm@2.0.0"), __import_name__("infer"))) +extern void __wasm_import_fermyon_spin_2_0_0_llm_infer(uint8_t *, size_t, uint8_t *, size_t, int32_t, int32_t, float, int32_t, float, int32_t, float, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/llm@2.0.0"), __import_name__("generate-embeddings"))) +extern void __wasm_import_fermyon_spin_2_0_0_llm_generate_embeddings(uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `fermyon:spin/redis@2.0.0` + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.publish"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_publish(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.get"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_get(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.set"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_set(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.incr"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_incr(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.del"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_del(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.sadd"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_sadd(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.smembers"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_smembers(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.srem"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_srem(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `fermyon:spin/mqtt@2.0.0` + +__attribute__((__import_module__("fermyon:spin/mqtt@2.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_mqtt_static_connection_open(uint8_t *, size_t, uint8_t *, size_t, uint8_t *, size_t, int64_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/mqtt@2.0.0"), __import_name__("[method]connection.publish"))) +extern void __wasm_import_fermyon_spin_2_0_0_mqtt_method_connection_publish(int32_t, uint8_t *, size_t, uint8_t *, size_t, int32_t, uint8_t *); + +// Imported Functions from `fermyon:spin/postgres@2.0.0` + +__attribute__((__import_module__("fermyon:spin/postgres@2.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_postgres_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/postgres@2.0.0"), __import_name__("[method]connection.query"))) +extern void __wasm_import_fermyon_spin_2_0_0_postgres_method_connection_query(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/postgres@2.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_fermyon_spin_2_0_0_postgres_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `fermyon:spin/mysql@2.0.0` + +__attribute__((__import_module__("fermyon:spin/mysql@2.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_mysql_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/mysql@2.0.0"), __import_name__("[method]connection.query"))) +extern void __wasm_import_fermyon_spin_2_0_0_mysql_method_connection_query(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/mysql@2.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_fermyon_spin_2_0_0_mysql_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `fermyon:spin/sqlite@2.0.0` + +__attribute__((__import_module__("fermyon:spin/sqlite@2.0.0"), __import_name__("[static]connection.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_sqlite_static_connection_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/sqlite@2.0.0"), __import_name__("[method]connection.execute"))) +extern void __wasm_import_fermyon_spin_2_0_0_sqlite_method_connection_execute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `fermyon:spin/key-value@2.0.0` + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[static]store.open"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_static_store_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[method]store.get"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_method_store_get(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[method]store.set"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_method_store_set(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[method]store.delete"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_method_store_delete(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[method]store.exists"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_method_store_exists(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[method]store.get-keys"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_method_store_get_keys(int32_t, uint8_t *); + +// Imported Functions from `fermyon:spin/variables@2.0.0` + +__attribute__((__import_module__("fermyon:spin/variables@2.0.0"), __import_name__("get"))) +extern void __wasm_import_fermyon_spin_2_0_0_variables_get(uint8_t *, size_t, uint8_t *); + +// Imported Functions from `wasi:cli/environment@0.2.0` + +__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-environment"))) +extern void __wasm_import_wasi_cli_0_2_0_environment_get_environment(uint8_t *); + +__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-arguments"))) +extern void __wasm_import_wasi_cli_0_2_0_environment_get_arguments(uint8_t *); + +__attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("initial-cwd"))) +extern void __wasm_import_wasi_cli_0_2_0_environment_initial_cwd(uint8_t *); + +// Imported Functions from `wasi:cli/exit@0.2.0` + +__attribute__((__import_module__("wasi:cli/exit@0.2.0"), __import_name__("exit"))) +extern void __wasm_import_wasi_cli_0_2_0_exit_exit(int32_t); + +// Imported Functions from `wasi:cli/stdin@0.2.0` + +__attribute__((__import_module__("wasi:cli/stdin@0.2.0"), __import_name__("get-stdin"))) +extern int32_t __wasm_import_wasi_cli_0_2_0_stdin_get_stdin(void); + +// Imported Functions from `wasi:cli/stdout@0.2.0` + +__attribute__((__import_module__("wasi:cli/stdout@0.2.0"), __import_name__("get-stdout"))) +extern int32_t __wasm_import_wasi_cli_0_2_0_stdout_get_stdout(void); + +// Imported Functions from `wasi:cli/stderr@0.2.0` + +__attribute__((__import_module__("wasi:cli/stderr@0.2.0"), __import_name__("get-stderr"))) +extern int32_t __wasm_import_wasi_cli_0_2_0_stderr_get_stderr(void); + +// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` + +__attribute__((__import_module__("wasi:cli/terminal-stdin@0.2.0"), __import_name__("get-terminal-stdin"))) +extern void __wasm_import_wasi_cli_0_2_0_terminal_stdin_get_terminal_stdin(uint8_t *); + +// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` + +__attribute__((__import_module__("wasi:cli/terminal-stdout@0.2.0"), __import_name__("get-terminal-stdout"))) +extern void __wasm_import_wasi_cli_0_2_0_terminal_stdout_get_terminal_stdout(uint8_t *); + +// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` + +__attribute__((__import_module__("wasi:cli/terminal-stderr@0.2.0"), __import_name__("get-terminal-stderr"))) +extern void __wasm_import_wasi_cli_0_2_0_terminal_stderr_get_terminal_stderr(uint8_t *); + +// Imported Functions from `wasi:clocks/wall-clock@0.2.0` + +__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("now"))) +extern void __wasm_import_wasi_clocks_0_2_0_wall_clock_now(uint8_t *); + +__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0"), __import_name__("resolution"))) +extern void __wasm_import_wasi_clocks_0_2_0_wall_clock_resolution(uint8_t *); + +// Imported Functions from `wasi:filesystem/types@0.2.0` + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-via-stream"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read_via_stream(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write-via-stream"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_write_via_stream(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.append-via-stream"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_append_via_stream(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.advise"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync-data"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_sync_data(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-flags"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_get_flags(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.get-type"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_get_type(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-size"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read(int32_t, int64_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.write"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_write(int32_t, uint8_t *, size_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.read-directory"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read_directory(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.sync"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_sync(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.create-directory-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_create_directory_at(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_stat(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.stat-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_stat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.set-times-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_times_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.link-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_link_at(int32_t, int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.open-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_open_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.readlink-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_readlink_at(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.remove-directory-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_remove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.rename-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_rename_at(int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.symlink-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_symlink_at(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.unlink-file-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_unlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.is-same-object"))) +extern int32_t __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_is_same_object(int32_t, int32_t); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]descriptor.metadata-hash-at"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[method]directory-entry-stream.read-directory-entry"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_method_directory_entry_stream_read_directory_entry(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("filesystem-error-code"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_filesystem_error_code(int32_t, uint8_t *); + +// Imported Functions from `wasi:filesystem/preopens@0.2.0` + +__attribute__((__import_module__("wasi:filesystem/preopens@0.2.0"), __import_name__("get-directories"))) +extern void __wasm_import_wasi_filesystem_0_2_0_preopens_get_directories(uint8_t *); + +// Imported Functions from `wasi:sockets/instance-network@0.2.0` + +__attribute__((__import_module__("wasi:sockets/instance-network@0.2.0"), __import_name__("instance-network"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_instance_network_instance_network(void); + +// Imported Functions from `wasi:sockets/udp@0.2.0` + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.start-bind"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.finish-bind"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_finish_bind(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.stream"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_stream(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.local-address"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_local_address(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.remote-address"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_remote_address(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.address-family"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_address_family(int32_t); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.unicast-hop-limit"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_unicast_hop_limit(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_receive_buffer_size(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.send-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_send_buffer_size(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.set-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]udp-socket.subscribe"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_subscribe(int32_t); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.receive"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_receive(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]incoming-datagram-stream.subscribe"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_subscribe(int32_t); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.check-send"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_check_send(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.send"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_send(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[method]outgoing-datagram-stream.subscribe"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_subscribe(int32_t); + +// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` + +__attribute__((__import_module__("wasi:sockets/udp-create-socket@0.2.0"), __import_name__("create-udp-socket"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_create_socket_create_udp_socket(int32_t, uint8_t *); + +// Imported Functions from `wasi:sockets/tcp@0.2.0` + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-bind"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-bind"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_bind(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-connect"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-connect"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_connect(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.start-listen"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_listen(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.finish-listen"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_listen(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.accept"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_accept(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.local-address"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_local_address(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.remote-address"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_remote_address(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.is-listening"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_is_listening(int32_t); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.address-family"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_address_family(int32_t); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-enabled"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_enabled(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-idle-time"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_idle_time(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-interval"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_interval(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.keep-alive-count"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_count(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.hop-limit"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_hop_limit(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-hop-limit"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_hop_limit(int32_t, int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_receive_buffer_size(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.send-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_send_buffer_size(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.subscribe"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_subscribe(int32_t); + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[method]tcp-socket.shutdown"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_shutdown(int32_t, int32_t, uint8_t *); + +// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` + +__attribute__((__import_module__("wasi:sockets/tcp-create-socket@0.2.0"), __import_name__("create-tcp-socket"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_create_socket_create_tcp_socket(int32_t, uint8_t *); + +// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` + +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("resolve-addresses"))) +extern void __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_resolve_addresses(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.resolve-next-address"))) +extern void __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_resolve_next_address(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[method]resolve-address-stream.subscribe"))) +extern int32_t __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_subscribe(int32_t); + +// Imported Functions from `wasi:random/random@0.2.0` + +__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-bytes"))) +extern void __wasm_import_wasi_random_0_2_0_random_get_random_bytes(int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:random/random@0.2.0"), __import_name__("get-random-u64"))) +extern int64_t __wasm_import_wasi_random_0_2_0_random_get_random_u64(void); + +// Imported Functions from `wasi:random/insecure@0.2.0` + +__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-bytes"))) +extern void __wasm_import_wasi_random_0_2_0_insecure_get_insecure_random_bytes(int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:random/insecure@0.2.0"), __import_name__("get-insecure-random-u64"))) +extern int64_t __wasm_import_wasi_random_0_2_0_insecure_get_insecure_random_u64(void); + +// Imported Functions from `wasi:random/insecure-seed@0.2.0` + +__attribute__((__import_module__("wasi:random/insecure-seed@0.2.0"), __import_name__("insecure-seed"))) +extern void __wasm_import_wasi_random_0_2_0_insecure_seed_insecure_seed(uint8_t *); + +// Imported Functions from `wasi:keyvalue/store@0.2.0-draft2` + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("open"))) +extern void __wasm_import_wasi_keyvalue_store_open(uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[method]bucket.get"))) +extern void __wasm_import_wasi_keyvalue_store_method_bucket_get(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[method]bucket.set"))) +extern void __wasm_import_wasi_keyvalue_store_method_bucket_set(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[method]bucket.delete"))) +extern void __wasm_import_wasi_keyvalue_store_method_bucket_delete(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[method]bucket.exists"))) +extern void __wasm_import_wasi_keyvalue_store_method_bucket_exists(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[method]bucket.list-keys"))) +extern void __wasm_import_wasi_keyvalue_store_method_bucket_list_keys(int32_t, int32_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `wasi:keyvalue/atomics@0.2.0-draft2` + +__attribute__((__import_module__("wasi:keyvalue/atomics@0.2.0-draft2"), __import_name__("[static]cas.new"))) +extern void __wasm_import_wasi_keyvalue_atomics_static_cas_new(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/atomics@0.2.0-draft2"), __import_name__("[method]cas.current"))) +extern void __wasm_import_wasi_keyvalue_atomics_method_cas_current(int32_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/atomics@0.2.0-draft2"), __import_name__("increment"))) +extern void __wasm_import_wasi_keyvalue_atomics_increment(int32_t, uint8_t *, size_t, int64_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/atomics@0.2.0-draft2"), __import_name__("swap"))) +extern void __wasm_import_wasi_keyvalue_atomics_swap(int32_t, uint8_t *, size_t, uint8_t *); + +// Imported Functions from `wasi:keyvalue/batch@0.2.0-draft2` + +__attribute__((__import_module__("wasi:keyvalue/batch@0.2.0-draft2"), __import_name__("get-many"))) +extern void __wasm_import_wasi_keyvalue_batch_get_many(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/batch@0.2.0-draft2"), __import_name__("set-many"))) +extern void __wasm_import_wasi_keyvalue_batch_set_many(int32_t, uint8_t *, size_t, uint8_t *); + +__attribute__((__import_module__("wasi:keyvalue/batch@0.2.0-draft2"), __import_name__("delete-many"))) +extern void __wasm_import_wasi_keyvalue_batch_delete_many(int32_t, uint8_t *, size_t, uint8_t *); + +// Exported Functions from `wasi:http/incoming-handler@0.2.0` + + +// Canonical ABI intrinsics + +__attribute__((__weak__, __export_name__("cabi_realloc"))) +void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { + (void) old_size; + if (new_size == 0) return (void*) align; + void *ret = realloc(ptr, new_size); + if (!ret) abort(); + return ret; +} + +// Helper Functions + +void spin_postgres_3_0_0_postgres_error_free(spin_postgres_3_0_0_postgres_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.connection_failed); + break; + } + case 1: { + http_trigger_string_free(&ptr->val.bad_parameter); + break; + } + case 2: { + http_trigger_string_free(&ptr->val.query_failed); + break; + } + case 3: { + http_trigger_string_free(&ptr->val.value_conversion_failed); + break; + } + case 4: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void http_trigger_list_u8_free(http_trigger_list_u8_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + uint8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +void spin_postgres_3_0_0_postgres_db_value_free(spin_postgres_3_0_0_postgres_db_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 8: { + http_trigger_list_u8_free(&ptr->val.binary); + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + } +} + +void spin_postgres_3_0_0_postgres_parameter_value_free(spin_postgres_3_0_0_postgres_parameter_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 8: { + http_trigger_list_u8_free(&ptr->val.binary); + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + } +} + +void spin_postgres_3_0_0_postgres_column_free(spin_postgres_3_0_0_postgres_column_t *ptr) { + http_trigger_string_free(&ptr->name); +} + +void spin_postgres_3_0_0_postgres_row_free(spin_postgres_3_0_0_postgres_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_3_0_0_postgres_db_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_3_0_0_postgres_db_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_3_0_0_postgres_list_column_free(spin_postgres_3_0_0_postgres_list_column_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_3_0_0_postgres_column_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_3_0_0_postgres_column_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_3_0_0_postgres_list_row_free(spin_postgres_3_0_0_postgres_list_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_3_0_0_postgres_row_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_3_0_0_postgres_row_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_3_0_0_postgres_row_set_free(spin_postgres_3_0_0_postgres_row_set_t *ptr) { + spin_postgres_3_0_0_postgres_list_column_free(&ptr->columns); + spin_postgres_3_0_0_postgres_list_row_free(&ptr->rows); +} + +__attribute__((__import_module__("spin:postgres/postgres@3.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_spin_postgres_3_0_0_postgres_connection_drop(int32_t handle); + +void spin_postgres_3_0_0_postgres_connection_drop_own(spin_postgres_3_0_0_postgres_own_connection_t handle) { + __wasm_import_spin_postgres_3_0_0_postgres_connection_drop(handle.__handle); +} + +void spin_postgres_3_0_0_postgres_connection_drop_borrow(spin_postgres_3_0_0_postgres_borrow_connection_t handle) { + __wasm_import_spin_postgres_3_0_0_postgres_connection_drop(handle.__handle); +} + +spin_postgres_3_0_0_postgres_borrow_connection_t spin_postgres_3_0_0_postgres_borrow_connection(spin_postgres_3_0_0_postgres_own_connection_t arg) { + return (spin_postgres_3_0_0_postgres_borrow_connection_t) { arg.__handle }; +} + +void spin_postgres_3_0_0_postgres_result_own_connection_error_free(spin_postgres_3_0_0_postgres_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + spin_postgres_3_0_0_postgres_error_free(&ptr->val.err); + } +} + +void spin_postgres_3_0_0_postgres_list_parameter_value_free(spin_postgres_3_0_0_postgres_list_parameter_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_3_0_0_postgres_parameter_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_3_0_0_postgres_parameter_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_3_0_0_postgres_result_row_set_error_free(spin_postgres_3_0_0_postgres_result_row_set_error_t *ptr) { + if (!ptr->is_err) { + spin_postgres_3_0_0_postgres_row_set_free(&ptr->val.ok); + } else { + spin_postgres_3_0_0_postgres_error_free(&ptr->val.err); + } +} + +void spin_postgres_3_0_0_postgres_result_u64_error_free(spin_postgres_3_0_0_postgres_result_u64_error_t *ptr) { + if (!ptr->is_err) { + } else { + spin_postgres_3_0_0_postgres_error_free(&ptr->val.err); + } +} + +void http_trigger_option_string_free(http_trigger_option_string_t *ptr) { + if (ptr->is_some) { + http_trigger_string_free(&ptr->val); + } +} + +void http_trigger_tuple2_string_string_free(http_trigger_tuple2_string_string_t *ptr) { + http_trigger_string_free(&ptr->f0); + http_trigger_string_free(&ptr->f1); +} + +void http_trigger_list_tuple2_string_string_free(http_trigger_list_tuple2_string_string_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_tuple2_string_string_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_tuple2_string_string_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_db_error_free(spin_postgres_4_0_0_postgres_db_error_t *ptr) { + http_trigger_string_free(&ptr->as_text); + http_trigger_string_free(&ptr->severity); + http_trigger_string_free(&ptr->code); + http_trigger_string_free(&ptr->message); + http_trigger_option_string_free(&ptr->detail); + http_trigger_list_tuple2_string_string_free(&ptr->extras); +} + +void spin_postgres_4_0_0_postgres_query_error_free(spin_postgres_4_0_0_postgres_query_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.text); + break; + } + case 1: { + spin_postgres_4_0_0_postgres_db_error_free(&ptr->val.db_error); + break; + } + } +} + +void spin_postgres_4_0_0_postgres_error_free(spin_postgres_4_0_0_postgres_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.connection_failed); + break; + } + case 1: { + http_trigger_string_free(&ptr->val.bad_parameter); + break; + } + case 2: { + spin_postgres_4_0_0_postgres_query_error_free(&ptr->val.query_failed); + break; + } + case 3: { + http_trigger_string_free(&ptr->val.value_conversion_failed); + break; + } + case 4: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void spin_postgres_4_0_0_postgres_db_data_type_free(spin_postgres_4_0_0_postgres_db_data_type_t *ptr) { + switch ((int32_t) ptr->tag) { + case 24: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void spin_postgres_4_0_0_postgres_column_free(spin_postgres_4_0_0_postgres_column_t *ptr) { + http_trigger_string_free(&ptr->name); + spin_postgres_4_0_0_postgres_db_data_type_free(&ptr->data_type); +} + +void spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_t *ptr) { + if (ptr->is_some) { + } +} + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_t *ptr) { + spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_free(&ptr->f0); + spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_free(&ptr->f1); +} + +void spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_t *ptr) { + if (ptr->is_some) { + } +} + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_t *ptr) { + spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_free(&ptr->f0); + spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_free(&ptr->f1); +} + +void spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_t *ptr) { + http_trigger_string_free(&ptr->f0); +} + +void spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_t *ptr) { + if (ptr->is_some) { + spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_free(&ptr->val); + } +} + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_t *ptr) { + spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_free(&ptr->f0); + spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_free(&ptr->f1); +} + +void http_trigger_option_s32_free(http_trigger_option_s32_t *ptr) { + if (ptr->is_some) { + } +} + +void http_trigger_list_option_s32_free(http_trigger_list_option_s32_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_option_s32_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_option_s32_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void http_trigger_option_s64_free(http_trigger_option_s64_t *ptr) { + if (ptr->is_some) { + } +} + +void http_trigger_list_option_s64_free(http_trigger_list_option_s64_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_option_s64_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_option_s64_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void http_trigger_list_option_string_free(http_trigger_list_option_string_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_option_string_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_option_string_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_db_value_free(spin_postgres_4_0_0_postgres_db_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + http_trigger_string_free(&ptr->val.uuid); + break; + } + case 14: { + break; + } + case 15: { + http_trigger_string_free(&ptr->val.decimal); + break; + } + case 16: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_free(&ptr->val.range_int32); + break; + } + case 17: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_free(&ptr->val.range_int64); + break; + } + case 18: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_free(&ptr->val.range_decimal); + break; + } + case 19: { + http_trigger_list_option_s32_free(&ptr->val.array_int32); + break; + } + case 20: { + http_trigger_list_option_s64_free(&ptr->val.array_int64); + break; + } + case 21: { + http_trigger_list_option_string_free(&ptr->val.array_decimal); + break; + } + case 22: { + http_trigger_list_option_string_free(&ptr->val.array_str); + break; + } + case 23: { + break; + } + case 25: { + break; + } + } +} + +void spin_postgres_4_0_0_postgres_parameter_value_free(spin_postgres_4_0_0_postgres_parameter_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + http_trigger_string_free(&ptr->val.uuid); + break; + } + case 14: { + break; + } + case 15: { + http_trigger_string_free(&ptr->val.decimal); + break; + } + case 16: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_free(&ptr->val.range_int32); + break; + } + case 17: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_free(&ptr->val.range_int64); + break; + } + case 18: { + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_free(&ptr->val.range_decimal); + break; + } + case 19: { + http_trigger_list_option_s32_free(&ptr->val.array_int32); + break; + } + case 20: { + http_trigger_list_option_s64_free(&ptr->val.array_int64); + break; + } + case 21: { + http_trigger_list_option_string_free(&ptr->val.array_decimal); + break; + } + case 22: { + http_trigger_list_option_string_free(&ptr->val.array_str); + break; + } + case 23: { + break; + } + } +} + +void spin_postgres_4_0_0_postgres_row_free(spin_postgres_4_0_0_postgres_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_4_0_0_postgres_db_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_4_0_0_postgres_db_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_list_column_free(spin_postgres_4_0_0_postgres_list_column_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_4_0_0_postgres_column_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_4_0_0_postgres_column_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_list_row_free(spin_postgres_4_0_0_postgres_list_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_4_0_0_postgres_row_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_4_0_0_postgres_row_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_row_set_free(spin_postgres_4_0_0_postgres_row_set_t *ptr) { + spin_postgres_4_0_0_postgres_list_column_free(&ptr->columns); + spin_postgres_4_0_0_postgres_list_row_free(&ptr->rows); +} + +__attribute__((__import_module__("spin:postgres/postgres@4.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_spin_postgres_4_0_0_postgres_connection_drop(int32_t handle); + +void spin_postgres_4_0_0_postgres_connection_drop_own(spin_postgres_4_0_0_postgres_own_connection_t handle) { + __wasm_import_spin_postgres_4_0_0_postgres_connection_drop(handle.__handle); +} + +void spin_postgres_4_0_0_postgres_connection_drop_borrow(spin_postgres_4_0_0_postgres_borrow_connection_t handle) { + __wasm_import_spin_postgres_4_0_0_postgres_connection_drop(handle.__handle); +} + +spin_postgres_4_0_0_postgres_borrow_connection_t spin_postgres_4_0_0_postgres_borrow_connection(spin_postgres_4_0_0_postgres_own_connection_t arg) { + return (spin_postgres_4_0_0_postgres_borrow_connection_t) { arg.__handle }; +} + +void spin_postgres_4_0_0_postgres_result_own_connection_error_free(spin_postgres_4_0_0_postgres_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + spin_postgres_4_0_0_postgres_error_free(&ptr->val.err); + } +} + +void spin_postgres_4_0_0_postgres_list_parameter_value_free(spin_postgres_4_0_0_postgres_list_parameter_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_postgres_4_0_0_postgres_parameter_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_postgres_4_0_0_postgres_parameter_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_postgres_4_0_0_postgres_result_row_set_error_free(spin_postgres_4_0_0_postgres_result_row_set_error_t *ptr) { + if (!ptr->is_err) { + spin_postgres_4_0_0_postgres_row_set_free(&ptr->val.ok); + } else { + spin_postgres_4_0_0_postgres_error_free(&ptr->val.err); + } +} + +void spin_postgres_4_0_0_postgres_result_u64_error_free(spin_postgres_4_0_0_postgres_result_u64_error_t *ptr) { + if (!ptr->is_err) { + } else { + spin_postgres_4_0_0_postgres_error_free(&ptr->val.err); + } +} + +__attribute__((__import_module__("spin:sqlite/sqlite@3.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_spin_sqlite_sqlite_connection_drop(int32_t handle); + +void spin_sqlite_sqlite_connection_drop_own(spin_sqlite_sqlite_own_connection_t handle) { + __wasm_import_spin_sqlite_sqlite_connection_drop(handle.__handle); +} + +void spin_sqlite_sqlite_connection_drop_borrow(spin_sqlite_sqlite_borrow_connection_t handle) { + __wasm_import_spin_sqlite_sqlite_connection_drop(handle.__handle); +} + +spin_sqlite_sqlite_borrow_connection_t spin_sqlite_sqlite_borrow_connection(spin_sqlite_sqlite_own_connection_t arg) { + return (spin_sqlite_sqlite_borrow_connection_t) { arg.__handle }; +} + +void spin_sqlite_sqlite_error_free(spin_sqlite_sqlite_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 4: { + http_trigger_string_free(&ptr->val.io); + break; + } + } +} + +void spin_sqlite_sqlite_value_free(spin_sqlite_sqlite_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + http_trigger_string_free(&ptr->val.text); + break; + } + case 3: { + break; + } + } +} + +void spin_sqlite_sqlite_list_value_free(spin_sqlite_sqlite_list_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_sqlite_sqlite_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_sqlite_sqlite_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_sqlite_sqlite_row_result_free(spin_sqlite_sqlite_row_result_t *ptr) { + spin_sqlite_sqlite_list_value_free(&ptr->values); +} + +void http_trigger_list_string_free(http_trigger_list_string_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_string_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_string_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_sqlite_sqlite_list_row_result_free(spin_sqlite_sqlite_list_row_result_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + spin_sqlite_sqlite_row_result_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + spin_sqlite_sqlite_row_result_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void spin_sqlite_sqlite_query_result_free(spin_sqlite_sqlite_query_result_t *ptr) { + http_trigger_list_string_free(&ptr->columns); + spin_sqlite_sqlite_list_row_result_free(&ptr->rows); +} + +void spin_sqlite_sqlite_result_own_connection_error_free(spin_sqlite_sqlite_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + spin_sqlite_sqlite_error_free(&ptr->val.err); + } +} + +void spin_sqlite_sqlite_result_query_result_error_free(spin_sqlite_sqlite_result_query_result_error_t *ptr) { + if (!ptr->is_err) { + spin_sqlite_sqlite_query_result_free(&ptr->val.ok); + } else { + spin_sqlite_sqlite_error_free(&ptr->val.err); + } +} + +void wasi_config_store_error_free(wasi_config_store_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.upstream); + break; + } + case 1: { + http_trigger_string_free(&ptr->val.io); + break; + } + } +} + +void wasi_config_store_result_option_string_error_free(wasi_config_store_result_option_string_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_config_store_error_free(&ptr->val.err); + } +} + +void wasi_config_store_result_list_tuple2_string_string_error_free(wasi_config_store_result_list_tuple2_string_string_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_config_store_error_free(&ptr->val.err); + } +} + +__attribute__((__import_module__("wasi:io/poll@0.2.0"), __import_name__("[resource-drop]pollable"))) +extern void __wasm_import_wasi_io_0_2_0_poll_pollable_drop(int32_t handle); + +void wasi_io_0_2_0_poll_pollable_drop_own(wasi_io_0_2_0_poll_own_pollable_t handle) { + __wasm_import_wasi_io_0_2_0_poll_pollable_drop(handle.__handle); +} + +void wasi_io_0_2_0_poll_pollable_drop_borrow(wasi_io_0_2_0_poll_borrow_pollable_t handle) { + __wasm_import_wasi_io_0_2_0_poll_pollable_drop(handle.__handle); +} + +wasi_io_0_2_0_poll_borrow_pollable_t wasi_io_0_2_0_poll_borrow_pollable(wasi_io_0_2_0_poll_own_pollable_t arg) { + return (wasi_io_0_2_0_poll_borrow_pollable_t) { arg.__handle }; +} + +void wasi_io_0_2_0_poll_list_borrow_pollable_free(wasi_io_0_2_0_poll_list_borrow_pollable_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_io_0_2_0_poll_borrow_pollable_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +void http_trigger_list_u32_free(http_trigger_list_u32_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + uint32_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +__attribute__((__import_module__("wasi:io/error@0.2.0"), __import_name__("[resource-drop]error"))) +extern void __wasm_import_wasi_io_0_2_0_error_error_drop(int32_t handle); + +void wasi_io_0_2_0_error_error_drop_own(wasi_io_0_2_0_error_own_error_t handle) { + __wasm_import_wasi_io_0_2_0_error_error_drop(handle.__handle); +} + +void wasi_io_0_2_0_error_error_drop_borrow(wasi_io_0_2_0_error_borrow_error_t handle) { + __wasm_import_wasi_io_0_2_0_error_error_drop(handle.__handle); +} + +wasi_io_0_2_0_error_borrow_error_t wasi_io_0_2_0_error_borrow_error(wasi_io_0_2_0_error_own_error_t arg) { + return (wasi_io_0_2_0_error_borrow_error_t) { arg.__handle }; +} + +void wasi_io_0_2_0_streams_stream_error_free(wasi_io_0_2_0_streams_stream_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + } +} + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]input-stream"))) +extern void __wasm_import_wasi_io_0_2_0_streams_input_stream_drop(int32_t handle); + +void wasi_io_0_2_0_streams_input_stream_drop_own(wasi_io_0_2_0_streams_own_input_stream_t handle) { + __wasm_import_wasi_io_0_2_0_streams_input_stream_drop(handle.__handle); +} + +void wasi_io_0_2_0_streams_input_stream_drop_borrow(wasi_io_0_2_0_streams_borrow_input_stream_t handle) { + __wasm_import_wasi_io_0_2_0_streams_input_stream_drop(handle.__handle); +} + +wasi_io_0_2_0_streams_borrow_input_stream_t wasi_io_0_2_0_streams_borrow_input_stream(wasi_io_0_2_0_streams_own_input_stream_t arg) { + return (wasi_io_0_2_0_streams_borrow_input_stream_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:io/streams@0.2.0"), __import_name__("[resource-drop]output-stream"))) +extern void __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(int32_t handle); + +void wasi_io_0_2_0_streams_output_stream_drop_own(wasi_io_0_2_0_streams_own_output_stream_t handle) { + __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(handle.__handle); +} + +void wasi_io_0_2_0_streams_output_stream_drop_borrow(wasi_io_0_2_0_streams_borrow_output_stream_t handle) { + __wasm_import_wasi_io_0_2_0_streams_output_stream_drop(handle.__handle); +} + +wasi_io_0_2_0_streams_borrow_output_stream_t wasi_io_0_2_0_streams_borrow_output_stream(wasi_io_0_2_0_streams_own_output_stream_t arg) { + return (wasi_io_0_2_0_streams_borrow_output_stream_t) { arg.__handle }; +} + +void wasi_io_0_2_0_streams_result_list_u8_stream_error_free(wasi_io_0_2_0_streams_result_list_u8_stream_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_io_0_2_0_streams_stream_error_free(&ptr->val.err); + } +} + +void wasi_io_0_2_0_streams_result_u64_stream_error_free(wasi_io_0_2_0_streams_result_u64_stream_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_io_0_2_0_streams_stream_error_free(&ptr->val.err); + } +} + +void wasi_io_0_2_0_streams_result_void_stream_error_free(wasi_io_0_2_0_streams_result_void_stream_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_io_0_2_0_streams_stream_error_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_method_free(wasi_http_0_2_0_types_method_t *ptr) { + switch ((int32_t) ptr->tag) { + case 9: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void wasi_http_0_2_0_types_scheme_free(wasi_http_0_2_0_types_scheme_t *ptr) { + switch ((int32_t) ptr->tag) { + case 2: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void http_trigger_option_u16_free(http_trigger_option_u16_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_dns_error_payload_free(wasi_http_0_2_0_types_dns_error_payload_t *ptr) { + http_trigger_option_u16_free(&ptr->info_code); +} + +void http_trigger_option_u8_free(http_trigger_option_u8_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_tls_alert_received_payload_free(wasi_http_0_2_0_types_tls_alert_received_payload_t *ptr) { + http_trigger_option_u8_free(&ptr->alert_id); +} + +void http_trigger_option_u32_free(http_trigger_option_u32_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_field_size_payload_free(wasi_http_0_2_0_types_field_size_payload_t *ptr) { + http_trigger_option_u32_free(&ptr->field_size); +} + +void http_trigger_option_u64_free(http_trigger_option_u64_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_option_field_size_payload_free(wasi_http_0_2_0_types_option_field_size_payload_t *ptr) { + if (ptr->is_some) { + wasi_http_0_2_0_types_field_size_payload_free(&ptr->val); + } +} + +void wasi_http_0_2_0_types_error_code_free(wasi_http_0_2_0_types_error_code_t *ptr) { + switch ((int32_t) ptr->tag) { + case 1: { + wasi_http_0_2_0_types_dns_error_payload_free(&ptr->val.dns_error); + break; + } + case 14: { + wasi_http_0_2_0_types_tls_alert_received_payload_free(&ptr->val.tls_alert_received); + break; + } + case 17: { + http_trigger_option_u64_free(&ptr->val.http_request_body_size); + break; + } + case 21: { + http_trigger_option_u32_free(&ptr->val.http_request_header_section_size); + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_free(&ptr->val.http_request_header_size); + break; + } + case 23: { + http_trigger_option_u32_free(&ptr->val.http_request_trailer_section_size); + break; + } + case 24: { + wasi_http_0_2_0_types_field_size_payload_free(&ptr->val.http_request_trailer_size); + break; + } + case 26: { + http_trigger_option_u32_free(&ptr->val.http_response_header_section_size); + break; + } + case 27: { + wasi_http_0_2_0_types_field_size_payload_free(&ptr->val.http_response_header_size); + break; + } + case 28: { + http_trigger_option_u64_free(&ptr->val.http_response_body_size); + break; + } + case 29: { + http_trigger_option_u32_free(&ptr->val.http_response_trailer_section_size); + break; + } + case 30: { + wasi_http_0_2_0_types_field_size_payload_free(&ptr->val.http_response_trailer_size); + break; + } + case 31: { + break; + } + case 32: { + break; + } + case 38: { + break; + } + } +} + +void wasi_http_0_2_0_types_header_error_free(wasi_http_0_2_0_types_header_error_t *ptr) { + switch ((int32_t) ptr->tag) { + } +} + +void wasi_http_0_2_0_types_field_key_free(wasi_http_0_2_0_types_field_key_t *ptr) { + http_trigger_string_free(ptr); +} + +void wasi_http_0_2_0_types_field_value_free(wasi_http_0_2_0_types_field_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + uint8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]fields"))) +extern void __wasm_import_wasi_http_0_2_0_types_fields_drop(int32_t handle); + +void wasi_http_0_2_0_types_fields_drop_own(wasi_http_0_2_0_types_own_fields_t handle) { + __wasm_import_wasi_http_0_2_0_types_fields_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_fields_drop_borrow(wasi_http_0_2_0_types_borrow_fields_t handle) { + __wasm_import_wasi_http_0_2_0_types_fields_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_fields_t wasi_http_0_2_0_types_borrow_fields(wasi_http_0_2_0_types_own_fields_t arg) { + return (wasi_http_0_2_0_types_borrow_fields_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]incoming-request"))) +extern void __wasm_import_wasi_http_0_2_0_types_incoming_request_drop(int32_t handle); + +void wasi_http_0_2_0_types_incoming_request_drop_own(wasi_http_0_2_0_types_own_incoming_request_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_request_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_incoming_request_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_request_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_request_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_incoming_request_t wasi_http_0_2_0_types_borrow_incoming_request(wasi_http_0_2_0_types_own_incoming_request_t arg) { + return (wasi_http_0_2_0_types_borrow_incoming_request_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]outgoing-request"))) +extern void __wasm_import_wasi_http_0_2_0_types_outgoing_request_drop(int32_t handle); + +void wasi_http_0_2_0_types_outgoing_request_drop_own(wasi_http_0_2_0_types_own_outgoing_request_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_request_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_outgoing_request_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_request_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_request_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_outgoing_request_t wasi_http_0_2_0_types_borrow_outgoing_request(wasi_http_0_2_0_types_own_outgoing_request_t arg) { + return (wasi_http_0_2_0_types_borrow_outgoing_request_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]request-options"))) +extern void __wasm_import_wasi_http_0_2_0_types_request_options_drop(int32_t handle); + +void wasi_http_0_2_0_types_request_options_drop_own(wasi_http_0_2_0_types_own_request_options_t handle) { + __wasm_import_wasi_http_0_2_0_types_request_options_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_request_options_drop_borrow(wasi_http_0_2_0_types_borrow_request_options_t handle) { + __wasm_import_wasi_http_0_2_0_types_request_options_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_request_options_t wasi_http_0_2_0_types_borrow_request_options(wasi_http_0_2_0_types_own_request_options_t arg) { + return (wasi_http_0_2_0_types_borrow_request_options_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]response-outparam"))) +extern void __wasm_import_wasi_http_0_2_0_types_response_outparam_drop(int32_t handle); + +void wasi_http_0_2_0_types_response_outparam_drop_own(wasi_http_0_2_0_types_own_response_outparam_t handle) { + __wasm_import_wasi_http_0_2_0_types_response_outparam_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_response_outparam_drop_borrow(wasi_http_0_2_0_types_borrow_response_outparam_t handle) { + __wasm_import_wasi_http_0_2_0_types_response_outparam_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_response_outparam_t wasi_http_0_2_0_types_borrow_response_outparam(wasi_http_0_2_0_types_own_response_outparam_t arg) { + return (wasi_http_0_2_0_types_borrow_response_outparam_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]incoming-response"))) +extern void __wasm_import_wasi_http_0_2_0_types_incoming_response_drop(int32_t handle); + +void wasi_http_0_2_0_types_incoming_response_drop_own(wasi_http_0_2_0_types_own_incoming_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_response_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_incoming_response_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_response_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_incoming_response_t wasi_http_0_2_0_types_borrow_incoming_response(wasi_http_0_2_0_types_own_incoming_response_t arg) { + return (wasi_http_0_2_0_types_borrow_incoming_response_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]incoming-body"))) +extern void __wasm_import_wasi_http_0_2_0_types_incoming_body_drop(int32_t handle); + +void wasi_http_0_2_0_types_incoming_body_drop_own(wasi_http_0_2_0_types_own_incoming_body_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_body_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_incoming_body_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_body_t handle) { + __wasm_import_wasi_http_0_2_0_types_incoming_body_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_incoming_body_t wasi_http_0_2_0_types_borrow_incoming_body(wasi_http_0_2_0_types_own_incoming_body_t arg) { + return (wasi_http_0_2_0_types_borrow_incoming_body_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]future-trailers"))) +extern void __wasm_import_wasi_http_0_2_0_types_future_trailers_drop(int32_t handle); + +void wasi_http_0_2_0_types_future_trailers_drop_own(wasi_http_0_2_0_types_own_future_trailers_t handle) { + __wasm_import_wasi_http_0_2_0_types_future_trailers_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_future_trailers_drop_borrow(wasi_http_0_2_0_types_borrow_future_trailers_t handle) { + __wasm_import_wasi_http_0_2_0_types_future_trailers_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_future_trailers_t wasi_http_0_2_0_types_borrow_future_trailers(wasi_http_0_2_0_types_own_future_trailers_t arg) { + return (wasi_http_0_2_0_types_borrow_future_trailers_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]outgoing-response"))) +extern void __wasm_import_wasi_http_0_2_0_types_outgoing_response_drop(int32_t handle); + +void wasi_http_0_2_0_types_outgoing_response_drop_own(wasi_http_0_2_0_types_own_outgoing_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_response_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_outgoing_response_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_response_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_outgoing_response_t wasi_http_0_2_0_types_borrow_outgoing_response(wasi_http_0_2_0_types_own_outgoing_response_t arg) { + return (wasi_http_0_2_0_types_borrow_outgoing_response_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]outgoing-body"))) +extern void __wasm_import_wasi_http_0_2_0_types_outgoing_body_drop(int32_t handle); + +void wasi_http_0_2_0_types_outgoing_body_drop_own(wasi_http_0_2_0_types_own_outgoing_body_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_body_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_outgoing_body_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_body_t handle) { + __wasm_import_wasi_http_0_2_0_types_outgoing_body_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_outgoing_body_t wasi_http_0_2_0_types_borrow_outgoing_body(wasi_http_0_2_0_types_own_outgoing_body_t arg) { + return (wasi_http_0_2_0_types_borrow_outgoing_body_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:http/types@0.2.0"), __import_name__("[resource-drop]future-incoming-response"))) +extern void __wasm_import_wasi_http_0_2_0_types_future_incoming_response_drop(int32_t handle); + +void wasi_http_0_2_0_types_future_incoming_response_drop_own(wasi_http_0_2_0_types_own_future_incoming_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_future_incoming_response_drop(handle.__handle); +} + +void wasi_http_0_2_0_types_future_incoming_response_drop_borrow(wasi_http_0_2_0_types_borrow_future_incoming_response_t handle) { + __wasm_import_wasi_http_0_2_0_types_future_incoming_response_drop(handle.__handle); +} + +wasi_http_0_2_0_types_borrow_future_incoming_response_t wasi_http_0_2_0_types_borrow_future_incoming_response(wasi_http_0_2_0_types_own_future_incoming_response_t arg) { + return (wasi_http_0_2_0_types_borrow_future_incoming_response_t) { arg.__handle }; +} + +void wasi_http_0_2_0_types_option_error_code_free(wasi_http_0_2_0_types_option_error_code_t *ptr) { + if (ptr->is_some) { + wasi_http_0_2_0_types_error_code_free(&ptr->val); + } +} + +void http_trigger_tuple2_field_key_field_value_free(http_trigger_tuple2_field_key_field_value_t *ptr) { + wasi_http_0_2_0_types_field_key_free(&ptr->f0); + wasi_http_0_2_0_types_field_value_free(&ptr->f1); +} + +void http_trigger_list_tuple2_field_key_field_value_free(http_trigger_list_tuple2_field_key_field_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_tuple2_field_key_field_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_tuple2_field_key_field_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_http_0_2_0_types_result_own_fields_header_error_free(wasi_http_0_2_0_types_result_own_fields_header_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_types_header_error_free(&ptr->val.err); + } +} + +void http_trigger_list_field_value_free(http_trigger_list_field_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_http_0_2_0_types_field_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + wasi_http_0_2_0_types_field_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_http_0_2_0_types_result_void_header_error_free(wasi_http_0_2_0_types_result_void_header_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_types_header_error_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_option_scheme_free(wasi_http_0_2_0_types_option_scheme_t *ptr) { + if (ptr->is_some) { + wasi_http_0_2_0_types_scheme_free(&ptr->val); + } +} + +void wasi_http_0_2_0_types_result_own_incoming_body_void_free(wasi_http_0_2_0_types_result_own_incoming_body_void_t *ptr) { + if (!ptr->is_err) { + } +} + +void wasi_http_0_2_0_types_result_own_outgoing_body_void_free(wasi_http_0_2_0_types_result_own_outgoing_body_void_t *ptr) { + if (!ptr->is_err) { + } +} + +void wasi_http_0_2_0_types_result_void_void_free(wasi_http_0_2_0_types_result_void_void_t *ptr) { + if (!ptr->is_err) { + } +} + +void http_trigger_option_duration_free(http_trigger_option_duration_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_result_own_outgoing_response_error_code_free(wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_types_error_code_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_result_own_input_stream_void_free(wasi_http_0_2_0_types_result_own_input_stream_void_t *ptr) { + if (!ptr->is_err) { + } +} + +void wasi_http_0_2_0_types_option_own_trailers_free(wasi_http_0_2_0_types_option_own_trailers_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_types_result_option_own_trailers_error_code_free(wasi_http_0_2_0_types_result_option_own_trailers_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_http_0_2_0_types_option_own_trailers_free(&ptr->val.ok); + } else { + wasi_http_0_2_0_types_error_code_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_free(wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t *ptr) { + if (!ptr->is_err) { + wasi_http_0_2_0_types_result_option_own_trailers_error_code_free(&ptr->val.ok); + } +} + +void wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_free(wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_t *ptr) { + if (ptr->is_some) { + wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_free(&ptr->val); + } +} + +void wasi_http_0_2_0_types_result_own_output_stream_void_free(wasi_http_0_2_0_types_result_own_output_stream_void_t *ptr) { + if (!ptr->is_err) { + } +} + +void wasi_http_0_2_0_types_result_void_error_code_free(wasi_http_0_2_0_types_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_types_error_code_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_result_own_incoming_response_error_code_free(wasi_http_0_2_0_types_result_own_incoming_response_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_types_error_code_free(&ptr->val.err); + } +} + +void wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_free(wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t *ptr) { + if (!ptr->is_err) { + wasi_http_0_2_0_types_result_own_incoming_response_error_code_free(&ptr->val.ok); + } +} + +void wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_free(wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_t *ptr) { + if (ptr->is_some) { + wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_free(&ptr->val); + } +} + +void wasi_http_0_2_0_outgoing_handler_error_code_free(wasi_http_0_2_0_outgoing_handler_error_code_t *ptr) { + wasi_http_0_2_0_types_error_code_free(ptr); +} + +void wasi_http_0_2_0_outgoing_handler_option_own_request_options_free(wasi_http_0_2_0_outgoing_handler_option_own_request_options_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_free(wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_http_0_2_0_outgoing_handler_error_code_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_llm_inferencing_model_free(fermyon_spin_2_0_0_llm_inferencing_model_t *ptr) { + http_trigger_string_free(ptr); +} + +void fermyon_spin_2_0_0_llm_error_free(fermyon_spin_2_0_0_llm_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 1: { + http_trigger_string_free(&ptr->val.runtime_error); + break; + } + case 2: { + http_trigger_string_free(&ptr->val.invalid_input); + break; + } + } +} + +void fermyon_spin_2_0_0_llm_inferencing_result_free(fermyon_spin_2_0_0_llm_inferencing_result_t *ptr) { + http_trigger_string_free(&ptr->text); +} + +void fermyon_spin_2_0_0_llm_embedding_model_free(fermyon_spin_2_0_0_llm_embedding_model_t *ptr) { + http_trigger_string_free(ptr); +} + +void http_trigger_list_f32_free(http_trigger_list_f32_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + float *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +void http_trigger_list_list_f32_free(http_trigger_list_list_f32_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_list_f32_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_list_f32_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_llm_embeddings_result_free(fermyon_spin_2_0_0_llm_embeddings_result_t *ptr) { + http_trigger_list_list_f32_free(&ptr->embeddings); +} + +void fermyon_spin_2_0_0_llm_option_inferencing_params_free(fermyon_spin_2_0_0_llm_option_inferencing_params_t *ptr) { + if (ptr->is_some) { + } +} + +void fermyon_spin_2_0_0_llm_result_inferencing_result_error_free(fermyon_spin_2_0_0_llm_result_inferencing_result_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_llm_inferencing_result_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_llm_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_llm_result_embeddings_result_error_free(fermyon_spin_2_0_0_llm_result_embeddings_result_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_llm_embeddings_result_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_llm_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_error_free(fermyon_spin_2_0_0_redis_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 3: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +__attribute__((__import_module__("fermyon:spin/redis@2.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_fermyon_spin_2_0_0_redis_connection_drop(int32_t handle); + +void fermyon_spin_2_0_0_redis_connection_drop_own(fermyon_spin_2_0_0_redis_own_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_redis_connection_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_redis_connection_drop_borrow(fermyon_spin_2_0_0_redis_borrow_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_redis_connection_drop(handle.__handle); +} + +fermyon_spin_2_0_0_redis_borrow_connection_t fermyon_spin_2_0_0_redis_borrow_connection(fermyon_spin_2_0_0_redis_own_connection_t arg) { + return (fermyon_spin_2_0_0_redis_borrow_connection_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_redis_payload_free(fermyon_spin_2_0_0_redis_payload_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + uint8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_redis_redis_parameter_free(fermyon_spin_2_0_0_redis_redis_parameter_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + fermyon_spin_2_0_0_redis_payload_free(&ptr->val.binary); + break; + } + } +} + +void fermyon_spin_2_0_0_redis_redis_result_free(fermyon_spin_2_0_0_redis_redis_result_t *ptr) { + switch ((int32_t) ptr->tag) { + case 1: { + http_trigger_string_free(&ptr->val.status); + break; + } + case 2: { + break; + } + case 3: { + fermyon_spin_2_0_0_redis_payload_free(&ptr->val.binary); + break; + } + } +} + +void fermyon_spin_2_0_0_redis_result_own_connection_error_free(fermyon_spin_2_0_0_redis_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_result_void_error_free(fermyon_spin_2_0_0_redis_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void http_trigger_option_payload_free(http_trigger_option_payload_t *ptr) { + if (ptr->is_some) { + fermyon_spin_2_0_0_redis_payload_free(&ptr->val); + } +} + +void fermyon_spin_2_0_0_redis_result_option_payload_error_free(fermyon_spin_2_0_0_redis_result_option_payload_error_t *ptr) { + if (!ptr->is_err) { + http_trigger_option_payload_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_result_s64_error_free(fermyon_spin_2_0_0_redis_result_s64_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_result_u32_error_free(fermyon_spin_2_0_0_redis_result_u32_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_result_list_string_error_free(fermyon_spin_2_0_0_redis_result_list_string_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_redis_list_redis_parameter_free(fermyon_spin_2_0_0_redis_list_redis_parameter_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_redis_redis_parameter_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_redis_redis_parameter_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_redis_list_redis_result_free(fermyon_spin_2_0_0_redis_list_redis_result_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_redis_redis_result_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_redis_redis_result_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_redis_result_list_redis_result_error_free(fermyon_spin_2_0_0_redis_result_list_redis_result_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_redis_list_redis_result_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_redis_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_mqtt_error_free(fermyon_spin_2_0_0_mqtt_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 2: { + http_trigger_string_free(&ptr->val.connection_failed); + break; + } + case 3: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +__attribute__((__import_module__("fermyon:spin/mqtt@2.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_fermyon_spin_2_0_0_mqtt_connection_drop(int32_t handle); + +void fermyon_spin_2_0_0_mqtt_connection_drop_own(fermyon_spin_2_0_0_mqtt_own_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_mqtt_connection_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_mqtt_connection_drop_borrow(fermyon_spin_2_0_0_mqtt_borrow_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_mqtt_connection_drop(handle.__handle); +} + +fermyon_spin_2_0_0_mqtt_borrow_connection_t fermyon_spin_2_0_0_mqtt_borrow_connection(fermyon_spin_2_0_0_mqtt_own_connection_t arg) { + return (fermyon_spin_2_0_0_mqtt_borrow_connection_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_mqtt_payload_free(fermyon_spin_2_0_0_mqtt_payload_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + uint8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_mqtt_result_own_connection_error_free(fermyon_spin_2_0_0_mqtt_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_mqtt_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_mqtt_result_void_error_free(fermyon_spin_2_0_0_mqtt_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_mqtt_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_rdbms_types_error_free(fermyon_spin_2_0_0_rdbms_types_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.connection_failed); + break; + } + case 1: { + http_trigger_string_free(&ptr->val.bad_parameter); + break; + } + case 2: { + http_trigger_string_free(&ptr->val.query_failed); + break; + } + case 3: { + http_trigger_string_free(&ptr->val.value_conversion_failed); + break; + } + case 4: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void fermyon_spin_2_0_0_rdbms_types_db_value_free(fermyon_spin_2_0_0_rdbms_types_db_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 12: { + break; + } + } +} + +void fermyon_spin_2_0_0_rdbms_types_parameter_value_free(fermyon_spin_2_0_0_rdbms_types_parameter_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + http_trigger_string_free(&ptr->val.str); + break; + } + case 12: { + break; + } + } +} + +void fermyon_spin_2_0_0_rdbms_types_column_free(fermyon_spin_2_0_0_rdbms_types_column_t *ptr) { + http_trigger_string_free(&ptr->name); +} + +void fermyon_spin_2_0_0_rdbms_types_row_free(fermyon_spin_2_0_0_rdbms_types_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_rdbms_types_db_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_rdbms_types_db_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_rdbms_types_list_column_free(fermyon_spin_2_0_0_rdbms_types_list_column_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_rdbms_types_column_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_rdbms_types_column_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_rdbms_types_list_row_free(fermyon_spin_2_0_0_rdbms_types_list_row_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_rdbms_types_row_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_rdbms_types_row_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_rdbms_types_row_set_free(fermyon_spin_2_0_0_rdbms_types_row_set_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_list_column_free(&ptr->columns); + fermyon_spin_2_0_0_rdbms_types_list_row_free(&ptr->rows); +} + +void fermyon_spin_2_0_0_postgres_parameter_value_free(fermyon_spin_2_0_0_postgres_parameter_value_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_parameter_value_free(ptr); +} + +void fermyon_spin_2_0_0_postgres_row_set_free(fermyon_spin_2_0_0_postgres_row_set_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_row_set_free(ptr); +} + +void fermyon_spin_2_0_0_postgres_error_free(fermyon_spin_2_0_0_postgres_error_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_error_free(ptr); +} + +__attribute__((__import_module__("fermyon:spin/postgres@2.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_fermyon_spin_2_0_0_postgres_connection_drop(int32_t handle); + +void fermyon_spin_2_0_0_postgres_connection_drop_own(fermyon_spin_2_0_0_postgres_own_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_postgres_connection_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_postgres_connection_drop_borrow(fermyon_spin_2_0_0_postgres_borrow_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_postgres_connection_drop(handle.__handle); +} + +fermyon_spin_2_0_0_postgres_borrow_connection_t fermyon_spin_2_0_0_postgres_borrow_connection(fermyon_spin_2_0_0_postgres_own_connection_t arg) { + return (fermyon_spin_2_0_0_postgres_borrow_connection_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_postgres_result_own_connection_error_free(fermyon_spin_2_0_0_postgres_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_postgres_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_postgres_list_parameter_value_free(fermyon_spin_2_0_0_postgres_list_parameter_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_postgres_parameter_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_postgres_parameter_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_postgres_result_row_set_error_free(fermyon_spin_2_0_0_postgres_result_row_set_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_postgres_row_set_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_postgres_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_postgres_result_u64_error_free(fermyon_spin_2_0_0_postgres_result_u64_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_postgres_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_mysql_parameter_value_free(fermyon_spin_2_0_0_mysql_parameter_value_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_parameter_value_free(ptr); +} + +void fermyon_spin_2_0_0_mysql_row_set_free(fermyon_spin_2_0_0_mysql_row_set_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_row_set_free(ptr); +} + +void fermyon_spin_2_0_0_mysql_error_free(fermyon_spin_2_0_0_mysql_error_t *ptr) { + fermyon_spin_2_0_0_rdbms_types_error_free(ptr); +} + +__attribute__((__import_module__("fermyon:spin/mysql@2.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_fermyon_spin_2_0_0_mysql_connection_drop(int32_t handle); + +void fermyon_spin_2_0_0_mysql_connection_drop_own(fermyon_spin_2_0_0_mysql_own_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_mysql_connection_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_mysql_connection_drop_borrow(fermyon_spin_2_0_0_mysql_borrow_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_mysql_connection_drop(handle.__handle); +} + +fermyon_spin_2_0_0_mysql_borrow_connection_t fermyon_spin_2_0_0_mysql_borrow_connection(fermyon_spin_2_0_0_mysql_own_connection_t arg) { + return (fermyon_spin_2_0_0_mysql_borrow_connection_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_mysql_result_own_connection_error_free(fermyon_spin_2_0_0_mysql_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_mysql_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_mysql_list_parameter_value_free(fermyon_spin_2_0_0_mysql_list_parameter_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_mysql_parameter_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_mysql_parameter_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_mysql_result_row_set_error_free(fermyon_spin_2_0_0_mysql_result_row_set_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_mysql_row_set_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_mysql_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_mysql_result_void_error_free(fermyon_spin_2_0_0_mysql_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_mysql_error_free(&ptr->val.err); + } +} + +__attribute__((__import_module__("fermyon:spin/sqlite@2.0.0"), __import_name__("[resource-drop]connection"))) +extern void __wasm_import_fermyon_spin_2_0_0_sqlite_connection_drop(int32_t handle); + +void fermyon_spin_2_0_0_sqlite_connection_drop_own(fermyon_spin_2_0_0_sqlite_own_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_sqlite_connection_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_sqlite_connection_drop_borrow(fermyon_spin_2_0_0_sqlite_borrow_connection_t handle) { + __wasm_import_fermyon_spin_2_0_0_sqlite_connection_drop(handle.__handle); +} + +fermyon_spin_2_0_0_sqlite_borrow_connection_t fermyon_spin_2_0_0_sqlite_borrow_connection(fermyon_spin_2_0_0_sqlite_own_connection_t arg) { + return (fermyon_spin_2_0_0_sqlite_borrow_connection_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_sqlite_error_free(fermyon_spin_2_0_0_sqlite_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 4: { + http_trigger_string_free(&ptr->val.io); + break; + } + } +} + +void fermyon_spin_2_0_0_sqlite_value_free(fermyon_spin_2_0_0_sqlite_value_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + http_trigger_string_free(&ptr->val.text); + break; + } + case 3: { + break; + } + } +} + +void fermyon_spin_2_0_0_sqlite_list_value_free(fermyon_spin_2_0_0_sqlite_list_value_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_sqlite_value_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_sqlite_value_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_sqlite_row_result_free(fermyon_spin_2_0_0_sqlite_row_result_t *ptr) { + fermyon_spin_2_0_0_sqlite_list_value_free(&ptr->values); +} + +void fermyon_spin_2_0_0_sqlite_list_row_result_free(fermyon_spin_2_0_0_sqlite_list_row_result_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + fermyon_spin_2_0_0_sqlite_row_result_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + fermyon_spin_2_0_0_sqlite_row_result_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void fermyon_spin_2_0_0_sqlite_query_result_free(fermyon_spin_2_0_0_sqlite_query_result_t *ptr) { + fermyon_spin_2_0_0_sqlite_list_row_result_free(&ptr->rows); +} + +void fermyon_spin_2_0_0_sqlite_result_own_connection_error_free(fermyon_spin_2_0_0_sqlite_result_own_connection_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_sqlite_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_sqlite_result_query_result_error_free(fermyon_spin_2_0_0_sqlite_result_query_result_error_t *ptr) { + if (!ptr->is_err) { + fermyon_spin_2_0_0_sqlite_query_result_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_sqlite_error_free(&ptr->val.err); + } +} + +__attribute__((__import_module__("fermyon:spin/key-value@2.0.0"), __import_name__("[resource-drop]store"))) +extern void __wasm_import_fermyon_spin_2_0_0_key_value_store_drop(int32_t handle); + +void fermyon_spin_2_0_0_key_value_store_drop_own(fermyon_spin_2_0_0_key_value_own_store_t handle) { + __wasm_import_fermyon_spin_2_0_0_key_value_store_drop(handle.__handle); +} + +void fermyon_spin_2_0_0_key_value_store_drop_borrow(fermyon_spin_2_0_0_key_value_borrow_store_t handle) { + __wasm_import_fermyon_spin_2_0_0_key_value_store_drop(handle.__handle); +} + +fermyon_spin_2_0_0_key_value_borrow_store_t fermyon_spin_2_0_0_key_value_borrow_store(fermyon_spin_2_0_0_key_value_own_store_t arg) { + return (fermyon_spin_2_0_0_key_value_borrow_store_t) { arg.__handle }; +} + +void fermyon_spin_2_0_0_key_value_error_free(fermyon_spin_2_0_0_key_value_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 3: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void fermyon_spin_2_0_0_key_value_result_own_store_error_free(fermyon_spin_2_0_0_key_value_result_own_store_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_key_value_error_free(&ptr->val.err); + } +} + +void http_trigger_option_list_u8_free(http_trigger_option_list_u8_t *ptr) { + if (ptr->is_some) { + } +} + +void fermyon_spin_2_0_0_key_value_result_option_list_u8_error_free(fermyon_spin_2_0_0_key_value_result_option_list_u8_error_t *ptr) { + if (!ptr->is_err) { + http_trigger_option_list_u8_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_key_value_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_key_value_result_void_error_free(fermyon_spin_2_0_0_key_value_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_key_value_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_key_value_result_bool_error_free(fermyon_spin_2_0_0_key_value_result_bool_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_key_value_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_key_value_result_list_string_error_free(fermyon_spin_2_0_0_key_value_result_list_string_error_t *ptr) { + if (!ptr->is_err) { + } else { + fermyon_spin_2_0_0_key_value_error_free(&ptr->val.err); + } +} + +void fermyon_spin_2_0_0_variables_error_free(fermyon_spin_2_0_0_variables_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + http_trigger_string_free(&ptr->val.invalid_name); + break; + } + case 1: { + http_trigger_string_free(&ptr->val.undefined); + break; + } + case 2: { + http_trigger_string_free(&ptr->val.provider); + break; + } + case 3: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +void fermyon_spin_2_0_0_variables_result_string_error_free(fermyon_spin_2_0_0_variables_result_string_error_t *ptr) { + if (!ptr->is_err) { + http_trigger_string_free(&ptr->val.ok); + } else { + fermyon_spin_2_0_0_variables_error_free(&ptr->val.err); + } +} + +void wasi_cli_0_2_0_exit_result_void_void_free(wasi_cli_0_2_0_exit_result_void_void_t *ptr) { + if (!ptr->is_err) { + } +} + +__attribute__((__import_module__("wasi:cli/terminal-input@0.2.0"), __import_name__("[resource-drop]terminal-input"))) +extern void __wasm_import_wasi_cli_0_2_0_terminal_input_terminal_input_drop(int32_t handle); + +void wasi_cli_0_2_0_terminal_input_terminal_input_drop_own(wasi_cli_0_2_0_terminal_input_own_terminal_input_t handle) { + __wasm_import_wasi_cli_0_2_0_terminal_input_terminal_input_drop(handle.__handle); +} + +void wasi_cli_0_2_0_terminal_input_terminal_input_drop_borrow(wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t handle) { + __wasm_import_wasi_cli_0_2_0_terminal_input_terminal_input_drop(handle.__handle); +} + +wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t wasi_cli_0_2_0_terminal_input_borrow_terminal_input(wasi_cli_0_2_0_terminal_input_own_terminal_input_t arg) { + return (wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:cli/terminal-output@0.2.0"), __import_name__("[resource-drop]terminal-output"))) +extern void __wasm_import_wasi_cli_0_2_0_terminal_output_terminal_output_drop(int32_t handle); + +void wasi_cli_0_2_0_terminal_output_terminal_output_drop_own(wasi_cli_0_2_0_terminal_output_own_terminal_output_t handle) { + __wasm_import_wasi_cli_0_2_0_terminal_output_terminal_output_drop(handle.__handle); +} + +void wasi_cli_0_2_0_terminal_output_terminal_output_drop_borrow(wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t handle) { + __wasm_import_wasi_cli_0_2_0_terminal_output_terminal_output_drop(handle.__handle); +} + +wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t wasi_cli_0_2_0_terminal_output_borrow_terminal_output(wasi_cli_0_2_0_terminal_output_own_terminal_output_t arg) { + return (wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t) { arg.__handle }; +} + +void wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_free(wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_free(wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_free(wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_filesystem_0_2_0_types_option_datetime_free(wasi_filesystem_0_2_0_types_option_datetime_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_filesystem_0_2_0_types_descriptor_stat_free(wasi_filesystem_0_2_0_types_descriptor_stat_t *ptr) { + wasi_filesystem_0_2_0_types_option_datetime_free(&ptr->data_access_timestamp); + wasi_filesystem_0_2_0_types_option_datetime_free(&ptr->data_modification_timestamp); + wasi_filesystem_0_2_0_types_option_datetime_free(&ptr->status_change_timestamp); +} + +void wasi_filesystem_0_2_0_types_new_timestamp_free(wasi_filesystem_0_2_0_types_new_timestamp_t *ptr) { + switch ((int32_t) ptr->tag) { + case 2: { + break; + } + } +} + +void wasi_filesystem_0_2_0_types_directory_entry_free(wasi_filesystem_0_2_0_types_directory_entry_t *ptr) { + http_trigger_string_free(&ptr->name); +} + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]descriptor"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_descriptor_drop(int32_t handle); + +void wasi_filesystem_0_2_0_types_descriptor_drop_own(wasi_filesystem_0_2_0_types_own_descriptor_t handle) { + __wasm_import_wasi_filesystem_0_2_0_types_descriptor_drop(handle.__handle); +} + +void wasi_filesystem_0_2_0_types_descriptor_drop_borrow(wasi_filesystem_0_2_0_types_borrow_descriptor_t handle) { + __wasm_import_wasi_filesystem_0_2_0_types_descriptor_drop(handle.__handle); +} + +wasi_filesystem_0_2_0_types_borrow_descriptor_t wasi_filesystem_0_2_0_types_borrow_descriptor(wasi_filesystem_0_2_0_types_own_descriptor_t arg) { + return (wasi_filesystem_0_2_0_types_borrow_descriptor_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]directory-entry-stream"))) +extern void __wasm_import_wasi_filesystem_0_2_0_types_directory_entry_stream_drop(int32_t handle); + +void wasi_filesystem_0_2_0_types_directory_entry_stream_drop_own(wasi_filesystem_0_2_0_types_own_directory_entry_stream_t handle) { + __wasm_import_wasi_filesystem_0_2_0_types_directory_entry_stream_drop(handle.__handle); +} + +void wasi_filesystem_0_2_0_types_directory_entry_stream_drop_borrow(wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t handle) { + __wasm_import_wasi_filesystem_0_2_0_types_directory_entry_stream_drop(handle.__handle); +} + +wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t wasi_filesystem_0_2_0_types_borrow_directory_entry_stream(wasi_filesystem_0_2_0_types_own_directory_entry_stream_t arg) { + return (wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t) { arg.__handle }; +} + +void wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_void_error_code_free(wasi_filesystem_0_2_0_types_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_filesize_error_code_free(wasi_filesystem_0_2_0_types_result_filesize_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_filesystem_0_2_0_types_descriptor_stat_free(&ptr->val.ok); + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_free(wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_string_error_code_free(wasi_filesystem_0_2_0_types_result_string_error_code_t *ptr) { + if (!ptr->is_err) { + http_trigger_string_free(&ptr->val.ok); + } else { + } +} + +void wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_free(wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_filesystem_0_2_0_types_option_directory_entry_free(wasi_filesystem_0_2_0_types_option_directory_entry_t *ptr) { + if (ptr->is_some) { + wasi_filesystem_0_2_0_types_directory_entry_free(&ptr->val); + } +} + +void wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_free(wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_filesystem_0_2_0_types_option_directory_entry_free(&ptr->val.ok); + } else { + } +} + +void wasi_filesystem_0_2_0_types_option_error_code_free(wasi_filesystem_0_2_0_types_option_error_code_t *ptr) { + if (ptr->is_some) { + } +} + +void wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t *ptr) { + http_trigger_string_free(&ptr->f1); +} + +void wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +__attribute__((__import_module__("wasi:sockets/network@0.2.0"), __import_name__("[resource-drop]network"))) +extern void __wasm_import_wasi_sockets_0_2_0_network_network_drop(int32_t handle); + +void wasi_sockets_0_2_0_network_network_drop_own(wasi_sockets_0_2_0_network_own_network_t handle) { + __wasm_import_wasi_sockets_0_2_0_network_network_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_network_network_drop_borrow(wasi_sockets_0_2_0_network_borrow_network_t handle) { + __wasm_import_wasi_sockets_0_2_0_network_network_drop(handle.__handle); +} + +wasi_sockets_0_2_0_network_borrow_network_t wasi_sockets_0_2_0_network_borrow_network(wasi_sockets_0_2_0_network_own_network_t arg) { + return (wasi_sockets_0_2_0_network_borrow_network_t) { arg.__handle }; +} + +void wasi_sockets_0_2_0_network_ip_address_free(wasi_sockets_0_2_0_network_ip_address_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + } +} + +void wasi_sockets_0_2_0_network_ip_socket_address_free(wasi_sockets_0_2_0_network_ip_socket_address_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + break; + } + case 1: { + break; + } + } +} + +void wasi_sockets_0_2_0_udp_ip_socket_address_free(wasi_sockets_0_2_0_udp_ip_socket_address_t *ptr) { + wasi_sockets_0_2_0_network_ip_socket_address_free(ptr); +} + +void wasi_sockets_0_2_0_udp_incoming_datagram_free(wasi_sockets_0_2_0_udp_incoming_datagram_t *ptr) { + wasi_sockets_0_2_0_udp_ip_socket_address_free(&ptr->remote_address); +} + +void wasi_sockets_0_2_0_udp_option_ip_socket_address_free(wasi_sockets_0_2_0_udp_option_ip_socket_address_t *ptr) { + if (ptr->is_some) { + wasi_sockets_0_2_0_udp_ip_socket_address_free(&ptr->val); + } +} + +void wasi_sockets_0_2_0_udp_outgoing_datagram_free(wasi_sockets_0_2_0_udp_outgoing_datagram_t *ptr) { + wasi_sockets_0_2_0_udp_option_ip_socket_address_free(&ptr->remote_address); +} + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]udp-socket"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_udp_socket_drop(int32_t handle); + +void wasi_sockets_0_2_0_udp_udp_socket_drop_own(wasi_sockets_0_2_0_udp_own_udp_socket_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_udp_socket_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_udp_udp_socket_drop_borrow(wasi_sockets_0_2_0_udp_borrow_udp_socket_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_udp_socket_drop(handle.__handle); +} + +wasi_sockets_0_2_0_udp_borrow_udp_socket_t wasi_sockets_0_2_0_udp_borrow_udp_socket(wasi_sockets_0_2_0_udp_own_udp_socket_t arg) { + return (wasi_sockets_0_2_0_udp_borrow_udp_socket_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]incoming-datagram-stream"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop(int32_t handle); + +void wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop_own(wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop(handle.__handle); +} + +wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream(wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t arg) { + return (wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t) { arg.__handle }; +} + +__attribute__((__import_module__("wasi:sockets/udp@0.2.0"), __import_name__("[resource-drop]outgoing-datagram-stream"))) +extern void __wasm_import_wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop(int32_t handle); + +void wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop_own(wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop(handle.__handle); +} + +wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream(wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t arg) { + return (wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t) { arg.__handle }; +} + +void wasi_sockets_0_2_0_udp_result_void_error_code_free(wasi_sockets_0_2_0_udp_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_sockets_0_2_0_udp_ip_socket_address_free(&ptr->val.ok); + } else { + } +} + +void wasi_sockets_0_2_0_udp_result_u8_error_code_free(wasi_sockets_0_2_0_udp_result_u8_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_udp_result_u64_error_code_free(wasi_sockets_0_2_0_udp_result_u64_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_udp_list_incoming_datagram_free(wasi_sockets_0_2_0_udp_list_incoming_datagram_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_sockets_0_2_0_udp_incoming_datagram_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + wasi_sockets_0_2_0_udp_incoming_datagram_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_sockets_0_2_0_udp_list_incoming_datagram_free(&ptr->val.ok); + } else { + } +} + +void wasi_sockets_0_2_0_udp_list_outgoing_datagram_free(wasi_sockets_0_2_0_udp_list_outgoing_datagram_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + wasi_sockets_0_2_0_udp_outgoing_datagram_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + wasi_sockets_0_2_0_udp_outgoing_datagram_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_ip_socket_address_free(wasi_sockets_0_2_0_tcp_ip_socket_address_t *ptr) { + wasi_sockets_0_2_0_network_ip_socket_address_free(ptr); +} + +__attribute__((__import_module__("wasi:sockets/tcp@0.2.0"), __import_name__("[resource-drop]tcp-socket"))) +extern void __wasm_import_wasi_sockets_0_2_0_tcp_tcp_socket_drop(int32_t handle); + +void wasi_sockets_0_2_0_tcp_tcp_socket_drop_own(wasi_sockets_0_2_0_tcp_own_tcp_socket_t handle) { + __wasm_import_wasi_sockets_0_2_0_tcp_tcp_socket_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_tcp_tcp_socket_drop_borrow(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t handle) { + __wasm_import_wasi_sockets_0_2_0_tcp_tcp_socket_drop(handle.__handle); +} + +wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t wasi_sockets_0_2_0_tcp_borrow_tcp_socket(wasi_sockets_0_2_0_tcp_own_tcp_socket_t arg) { + return (wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t) { arg.__handle }; +} + +void wasi_sockets_0_2_0_tcp_result_void_error_code_free(wasi_sockets_0_2_0_tcp_result_void_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_sockets_0_2_0_tcp_ip_socket_address_free(&ptr->val.ok); + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_bool_error_code_free(wasi_sockets_0_2_0_tcp_result_bool_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_duration_error_code_free(wasi_sockets_0_2_0_tcp_result_duration_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_u32_error_code_free(wasi_sockets_0_2_0_tcp_result_u32_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_u8_error_code_free(wasi_sockets_0_2_0_tcp_result_u8_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_result_u64_error_code_free(wasi_sockets_0_2_0_tcp_result_u64_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_ip_name_lookup_ip_address_free(wasi_sockets_0_2_0_ip_name_lookup_ip_address_t *ptr) { + wasi_sockets_0_2_0_network_ip_address_free(ptr); +} + +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0"), __import_name__("[resource-drop]resolve-address-stream"))) +extern void __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop(int32_t handle); + +void wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop(handle.__handle); +} + +void wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t handle) { + __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop(handle.__handle); +} + +wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t arg) { + return (wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t) { arg.__handle }; +} + +void wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr) { + if (!ptr->is_err) { + } else { + } +} + +void wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_free(wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t *ptr) { + if (ptr->is_some) { + wasi_sockets_0_2_0_ip_name_lookup_ip_address_free(&ptr->val); + } +} + +void wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_t *ptr) { + if (!ptr->is_err) { + wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_free(&ptr->val.ok); + } else { + } +} + +void wasi_keyvalue_store_error_free(wasi_keyvalue_store_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 2: { + http_trigger_string_free(&ptr->val.other); + break; + } + } +} + +__attribute__((__import_module__("wasi:keyvalue/store@0.2.0-draft2"), __import_name__("[resource-drop]bucket"))) +extern void __wasm_import_wasi_keyvalue_store_bucket_drop(int32_t handle); + +void wasi_keyvalue_store_bucket_drop_own(wasi_keyvalue_store_own_bucket_t handle) { + __wasm_import_wasi_keyvalue_store_bucket_drop(handle.__handle); +} + +void wasi_keyvalue_store_bucket_drop_borrow(wasi_keyvalue_store_borrow_bucket_t handle) { + __wasm_import_wasi_keyvalue_store_bucket_drop(handle.__handle); +} + +wasi_keyvalue_store_borrow_bucket_t wasi_keyvalue_store_borrow_bucket(wasi_keyvalue_store_own_bucket_t arg) { + return (wasi_keyvalue_store_borrow_bucket_t) { arg.__handle }; +} + +void wasi_keyvalue_store_result_own_bucket_error_free(wasi_keyvalue_store_result_own_bucket_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_store_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_store_result_option_list_u8_error_free(wasi_keyvalue_store_result_option_list_u8_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_store_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_store_result_void_error_free(wasi_keyvalue_store_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_store_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_store_result_bool_error_free(wasi_keyvalue_store_result_bool_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_store_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_store_result_key_response_error_free(wasi_keyvalue_store_result_key_response_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_store_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_atomics_error_free(wasi_keyvalue_atomics_error_t *ptr) { + wasi_keyvalue_store_error_free(ptr); +} + +__attribute__((__import_module__("wasi:keyvalue/atomics@0.2.0-draft2"), __import_name__("[resource-drop]cas"))) +extern void __wasm_import_wasi_keyvalue_atomics_cas_drop(int32_t handle); + +void wasi_keyvalue_atomics_cas_drop_own(wasi_keyvalue_atomics_own_cas_t handle) { + __wasm_import_wasi_keyvalue_atomics_cas_drop(handle.__handle); +} + +void wasi_keyvalue_atomics_cas_drop_borrow(wasi_keyvalue_atomics_borrow_cas_t handle) { + __wasm_import_wasi_keyvalue_atomics_cas_drop(handle.__handle); +} + +wasi_keyvalue_atomics_borrow_cas_t wasi_keyvalue_atomics_borrow_cas(wasi_keyvalue_atomics_own_cas_t arg) { + return (wasi_keyvalue_atomics_borrow_cas_t) { arg.__handle }; +} + +void wasi_keyvalue_atomics_cas_error_free(wasi_keyvalue_atomics_cas_error_t *ptr) { + switch ((int32_t) ptr->tag) { + case 0: { + wasi_keyvalue_atomics_error_free(&ptr->val.store_error); + break; + } + case 1: { + break; + } + } +} + +void wasi_keyvalue_atomics_result_own_cas_error_free(wasi_keyvalue_atomics_result_own_cas_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_atomics_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_atomics_result_option_list_u8_error_free(wasi_keyvalue_atomics_result_option_list_u8_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_atomics_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_atomics_result_s64_error_free(wasi_keyvalue_atomics_result_s64_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_atomics_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_atomics_result_void_cas_error_free(wasi_keyvalue_atomics_result_void_cas_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_atomics_cas_error_free(&ptr->val.err); + } +} + +void wasi_keyvalue_batch_error_free(wasi_keyvalue_batch_error_t *ptr) { + wasi_keyvalue_store_error_free(ptr); +} + +void http_trigger_tuple2_string_option_list_u8_free(http_trigger_tuple2_string_option_list_u8_t *ptr) { + http_trigger_string_free(&ptr->f0); +} + +void http_trigger_list_tuple2_string_option_list_u8_free(http_trigger_list_tuple2_string_option_list_u8_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_tuple2_string_option_list_u8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_tuple2_string_option_list_u8_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_free(wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_t *ptr) { + if (!ptr->is_err) { + http_trigger_list_tuple2_string_option_list_u8_free(&ptr->val.ok); + } else { + wasi_keyvalue_batch_error_free(&ptr->val.err); + } +} + +void http_trigger_tuple2_string_list_u8_free(http_trigger_tuple2_string_list_u8_t *ptr) { + http_trigger_string_free(&ptr->f0); +} + +void http_trigger_list_tuple2_string_list_u8_free(http_trigger_list_tuple2_string_list_u8_t *ptr) { + size_t list_len = ptr->len; + if (list_len > 0) { + http_trigger_tuple2_string_list_u8_t *list_ptr = ptr->ptr; + for (size_t i = 0; i < list_len; i++) { + http_trigger_tuple2_string_list_u8_free(&list_ptr[i]); + } + free(list_ptr); + } +} + +void wasi_keyvalue_batch_result_void_error_free(wasi_keyvalue_batch_result_void_error_t *ptr) { + if (!ptr->is_err) { + } else { + wasi_keyvalue_batch_error_free(&ptr->val.err); + } +} + +void http_trigger_string_set(http_trigger_string_t *ret, const char*s) { + ret->ptr = (uint8_t*) s; + ret->len = strlen(s); +} + +void http_trigger_string_dup(http_trigger_string_t *ret, const char*s) { + ret->len = strlen(s); + ret->ptr = (uint8_t*) cabi_realloc(NULL, 0, 1, ret->len * 1); + memcpy(ret->ptr, s, ret->len * 1); +} + +void http_trigger_string_dup_n(http_trigger_string_t *ret, const char*s, size_t len) { + ret->len = len; + ret->ptr = (uint8_t*) cabi_realloc(NULL, 0, 1, ret->len * 1); + memcpy(ret->ptr, s, ret->len * 1); +} + +void http_trigger_string_free(http_trigger_string_t *ret) { + if (ret->len > 0) { + free(ret->ptr); + } + ret->ptr = NULL; + ret->len = 0; +} + +// Component Adapters + +bool spin_postgres_3_0_0_postgres_static_connection_open(http_trigger_string_t *address, spin_postgres_3_0_0_postgres_own_connection_t *ret, spin_postgres_3_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_3_0_0_postgres_static_connection_open((uint8_t *) (*address).ptr, (*address).len, ptr); + spin_postgres_3_0_0_postgres_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_postgres_3_0_0_postgres_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + spin_postgres_3_0_0_postgres_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_postgres_3_0_0_postgres_method_connection_query(spin_postgres_3_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_3_0_0_postgres_list_parameter_value_t *params, spin_postgres_3_0_0_postgres_row_set_t *ret, spin_postgres_3_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_3_0_0_postgres_method_connection_query((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + spin_postgres_3_0_0_postgres_result_row_set_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_postgres_3_0_0_postgres_row_set_t) { + (spin_postgres_3_0_0_postgres_list_column_t) (spin_postgres_3_0_0_postgres_list_column_t) { (spin_postgres_3_0_0_postgres_column_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (spin_postgres_3_0_0_postgres_list_row_t) (spin_postgres_3_0_0_postgres_list_row_t) { (spin_postgres_3_0_0_postgres_row_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + spin_postgres_3_0_0_postgres_error_t variant13; + variant13.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant13.tag) { + case 0: { + variant13.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant13.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant13.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant13.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant13.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant13; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_postgres_3_0_0_postgres_method_connection_execute(spin_postgres_3_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_3_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, spin_postgres_3_0_0_postgres_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(16+2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_3_0_0_postgres_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + spin_postgres_3_0_0_postgres_result_u64_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + spin_postgres_3_0_0_postgres_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_postgres_4_0_0_postgres_static_connection_open(http_trigger_string_t *address, spin_postgres_4_0_0_postgres_own_connection_t *ret, spin_postgres_4_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(16*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_4_0_0_postgres_static_connection_open((uint8_t *) (*address).ptr, (*address).len, ptr); + spin_postgres_4_0_0_postgres_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_postgres_4_0_0_postgres_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + spin_postgres_4_0_0_postgres_error_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + variant0.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant0.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + spin_postgres_4_0_0_postgres_query_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.text = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + case 1: { + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (11*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (12*sizeof(void*))))), (*((size_t*) (ptr + (13*sizeof(void*))))) }; + break; + } + } + variant.val.db_error = (spin_postgres_4_0_0_postgres_db_error_t) { + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (5*sizeof(void*))))), (*((size_t*) (ptr + (6*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (7*sizeof(void*))))), (*((size_t*) (ptr + (8*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (9*sizeof(void*))))), (*((size_t*) (ptr + (10*sizeof(void*))))) }, + (http_trigger_option_string_t) option, + (http_trigger_list_tuple2_string_string_t) (http_trigger_list_tuple2_string_string_t) { (http_trigger_tuple2_string_string_t*)(*((uint8_t **) (ptr + (14*sizeof(void*))))), (*((size_t*) (ptr + (15*sizeof(void*))))) }, + }; + break; + } + } + variant0.val.query_failed = variant; + break; + } + case 3: { + variant0.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant0.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant0; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_postgres_4_0_0_postgres_method_connection_query(spin_postgres_4_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_4_0_0_postgres_list_parameter_value_t *params, spin_postgres_4_0_0_postgres_row_set_t *ret, spin_postgres_4_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(16*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_4_0_0_postgres_method_connection_query((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + spin_postgres_4_0_0_postgres_result_row_set_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_postgres_4_0_0_postgres_row_set_t) { + (spin_postgres_4_0_0_postgres_list_column_t) (spin_postgres_4_0_0_postgres_list_column_t) { (spin_postgres_4_0_0_postgres_column_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (spin_postgres_4_0_0_postgres_list_row_t) (spin_postgres_4_0_0_postgres_list_row_t) { (spin_postgres_4_0_0_postgres_row_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + spin_postgres_4_0_0_postgres_error_t variant56; + variant56.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant56.tag) { + case 0: { + variant56.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant56.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + spin_postgres_4_0_0_postgres_query_error_t variant55; + variant55.tag = (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))); + switch ((int32_t) variant55.tag) { + case 0: { + variant55.val.text = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + case 1: { + http_trigger_option_string_t option54; + switch ((int32_t) *((uint8_t*) (ptr + (11*sizeof(void*))))) { + case 0: { + option54.is_some = false; + break; + } + case 1: { + option54.is_some = true; + option54.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (12*sizeof(void*))))), (*((size_t*) (ptr + (13*sizeof(void*))))) }; + break; + } + } + variant55.val.db_error = (spin_postgres_4_0_0_postgres_db_error_t) { + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (5*sizeof(void*))))), (*((size_t*) (ptr + (6*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (7*sizeof(void*))))), (*((size_t*) (ptr + (8*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (9*sizeof(void*))))), (*((size_t*) (ptr + (10*sizeof(void*))))) }, + (http_trigger_option_string_t) option54, + (http_trigger_list_tuple2_string_string_t) (http_trigger_list_tuple2_string_string_t) { (http_trigger_tuple2_string_string_t*)(*((uint8_t **) (ptr + (14*sizeof(void*))))), (*((size_t*) (ptr + (15*sizeof(void*))))) }, + }; + break; + } + } + variant56.val.query_failed = variant55; + break; + } + case 3: { + variant56.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant56.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant56; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_postgres_4_0_0_postgres_method_connection_execute(spin_postgres_4_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_4_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, spin_postgres_4_0_0_postgres_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(16+14*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_postgres_4_0_0_postgres_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + spin_postgres_4_0_0_postgres_result_u64_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + spin_postgres_4_0_0_postgres_error_t variant44; + variant44.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant44.tag) { + case 0: { + variant44.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 1: { + variant44.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 2: { + spin_postgres_4_0_0_postgres_query_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + (8+1*sizeof(void*)))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.text = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }; + break; + } + case 1: { + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + (8+10*sizeof(void*))))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+11*sizeof(void*))))), (*((size_t*) (ptr + (8+12*sizeof(void*))))) }; + break; + } + } + variant.val.db_error = (spin_postgres_4_0_0_postgres_db_error_t) { + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+2*sizeof(void*))))), (*((size_t*) (ptr + (8+3*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+4*sizeof(void*))))), (*((size_t*) (ptr + (8+5*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+6*sizeof(void*))))), (*((size_t*) (ptr + (8+7*sizeof(void*))))) }, + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+8*sizeof(void*))))), (*((size_t*) (ptr + (8+9*sizeof(void*))))) }, + (http_trigger_option_string_t) option, + (http_trigger_list_tuple2_string_string_t) (http_trigger_list_tuple2_string_string_t) { (http_trigger_tuple2_string_string_t*)(*((uint8_t **) (ptr + (8+13*sizeof(void*))))), (*((size_t*) (ptr + (8+14*sizeof(void*))))) }, + }; + break; + } + } + variant44.val.query_failed = variant; + break; + } + case 3: { + variant44.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 4: { + variant44.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant44; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_sqlite_sqlite_static_connection_open(http_trigger_string_t *database, spin_sqlite_sqlite_own_connection_t *ret, spin_sqlite_sqlite_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_sqlite_sqlite_static_connection_open((uint8_t *) (*database).ptr, (*database).len, ptr); + spin_sqlite_sqlite_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_sqlite_sqlite_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + spin_sqlite_sqlite_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + variant.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool spin_sqlite_sqlite_method_connection_execute(spin_sqlite_sqlite_borrow_connection_t self, http_trigger_string_t *statement, spin_sqlite_sqlite_list_value_t *parameters, spin_sqlite_sqlite_query_result_t *ret, spin_sqlite_sqlite_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_spin_sqlite_sqlite_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*parameters).ptr, (*parameters).len, ptr); + spin_sqlite_sqlite_result_query_result_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (spin_sqlite_sqlite_query_result_t) { + (http_trigger_list_string_t) (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (spin_sqlite_sqlite_list_row_result_t) (spin_sqlite_sqlite_list_row_result_t) { (spin_sqlite_sqlite_row_result_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + spin_sqlite_sqlite_error_t variant4; + variant4.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant4.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + variant4.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant4; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +int64_t spin_sqlite_sqlite_method_connection_last_insert_rowid(spin_sqlite_sqlite_borrow_connection_t self) { + int64_t ret = __wasm_import_spin_sqlite_sqlite_method_connection_last_insert_rowid((self).__handle); + return ret; +} + +uint64_t spin_sqlite_sqlite_method_connection_changes(spin_sqlite_sqlite_borrow_connection_t self) { + int64_t ret = __wasm_import_spin_sqlite_sqlite_method_connection_changes((self).__handle); + return (uint64_t) (ret); +} + +bool wasi_config_store_get(http_trigger_string_t *key, http_trigger_option_string_t *ret, wasi_config_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_config_store_get((uint8_t *) (*key).ptr, (*key).len, ptr); + wasi_config_store_result_option_string_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + wasi_config_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.upstream = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_config_store_get_all(http_trigger_list_tuple2_string_string_t *ret, wasi_config_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_config_store_get_all(ptr); + wasi_config_store_result_list_tuple2_string_string_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_tuple2_string_string_t) { (http_trigger_tuple2_string_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + wasi_config_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.upstream = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_poll_method_pollable_ready(wasi_io_0_2_0_poll_borrow_pollable_t self) { + int32_t ret = __wasm_import_wasi_io_0_2_0_poll_method_pollable_ready((self).__handle); + return ret; +} + +void wasi_io_0_2_0_poll_method_pollable_block(wasi_io_0_2_0_poll_borrow_pollable_t self) { + __wasm_import_wasi_io_0_2_0_poll_method_pollable_block((self).__handle); +} + +void wasi_io_0_2_0_poll_poll(wasi_io_0_2_0_poll_list_borrow_pollable_t *in, http_trigger_list_u32_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_poll_poll((uint8_t *) (*in).ptr, (*in).len, ptr); + *ret = (http_trigger_list_u32_t) { (uint32_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +wasi_clocks_0_2_0_monotonic_clock_instant_t wasi_clocks_0_2_0_monotonic_clock_now(void) { + int64_t ret = __wasm_import_wasi_clocks_0_2_0_monotonic_clock_now(); + return (uint64_t) (ret); +} + +wasi_clocks_0_2_0_monotonic_clock_duration_t wasi_clocks_0_2_0_monotonic_clock_resolution(void) { + int64_t ret = __wasm_import_wasi_clocks_0_2_0_monotonic_clock_resolution(); + return (uint64_t) (ret); +} + +wasi_clocks_0_2_0_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_monotonic_clock_subscribe_instant(wasi_clocks_0_2_0_monotonic_clock_instant_t when) { + int32_t ret = __wasm_import_wasi_clocks_0_2_0_monotonic_clock_subscribe_instant((int64_t) (when)); + return (wasi_clocks_0_2_0_monotonic_clock_own_pollable_t) { ret }; +} + +wasi_clocks_0_2_0_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_monotonic_clock_subscribe_duration(wasi_clocks_0_2_0_monotonic_clock_duration_t when) { + int32_t ret = __wasm_import_wasi_clocks_0_2_0_monotonic_clock_subscribe_duration((int64_t) (when)); + return (wasi_clocks_0_2_0_monotonic_clock_own_pollable_t) { ret }; +} + +void wasi_io_0_2_0_error_method_error_to_debug_string(wasi_io_0_2_0_error_borrow_error_t self, http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_error_method_error_to_debug_string((self).__handle, ptr); + *ret = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +bool wasi_io_0_2_0_streams_method_input_stream_read(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, http_trigger_list_u8_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_input_stream_read((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_list_u8_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_input_stream_blocking_read(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, http_trigger_list_u8_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_input_stream_blocking_read((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_list_u8_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + (4+1*sizeof(void*)))) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_input_stream_skip(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_input_stream_skip((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_u64_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_input_stream_blocking_skip(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_input_stream_blocking_skip((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_u64_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_io_0_2_0_streams_own_pollable_t wasi_io_0_2_0_streams_method_input_stream_subscribe(wasi_io_0_2_0_streams_borrow_input_stream_t self) { + int32_t ret = __wasm_import_wasi_io_0_2_0_streams_method_input_stream_subscribe((self).__handle); + return (wasi_io_0_2_0_streams_own_pollable_t) { ret }; +} + +bool wasi_io_0_2_0_streams_method_output_stream_check_write(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_check_write((self).__handle, ptr); + wasi_io_0_2_0_streams_result_u64_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_write(wasi_io_0_2_0_streams_borrow_output_stream_t self, http_trigger_list_u8_t *contents, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_write((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, http_trigger_list_u8_t *contents, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush((self).__handle, (uint8_t *) (*contents).ptr, (*contents).len, ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_flush((self).__handle, ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_blocking_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_flush((self).__handle, ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_io_0_2_0_streams_own_pollable_t wasi_io_0_2_0_streams_method_output_stream_subscribe(wasi_io_0_2_0_streams_borrow_output_stream_t self) { + int32_t ret = __wasm_import_wasi_io_0_2_0_streams_method_output_stream_subscribe((self).__handle); + return (wasi_io_0_2_0_streams_own_pollable_t) { ret }; +} + +bool wasi_io_0_2_0_streams_method_output_stream_write_zeroes(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_write_zeroes((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_write_zeroes_and_flush((self).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_void_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_splice(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_u64_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_io_0_2_0_streams_method_output_stream_blocking_splice(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_io_0_2_0_streams_method_output_stream_blocking_splice((self).__handle, (src).__handle, (int64_t) (len), ptr); + wasi_io_0_2_0_streams_result_u64_stream_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + wasi_io_0_2_0_streams_stream_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.last_operation_failed = (wasi_io_0_2_0_streams_own_error_t) { *((int32_t*) (ptr + 12)) }; + break; + } + case 1: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_http_0_2_0_types_http_error_code(wasi_http_0_2_0_types_borrow_io_error_t err_, wasi_http_0_2_0_types_error_code_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(24+4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_http_error_code((err_).__handle, ptr); + wasi_http_0_2_0_types_option_error_code_t option21; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option21.is_some = false; + break; + } + case 1: { + option21.is_some = true; + wasi_http_0_2_0_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u16_t option0; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option0.is_some = false; + break; + } + case 1: { + option0.is_some = true; + option0.val = (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+3*sizeof(void*))))); + break; + } + } + variant.val.dns_error = (wasi_http_0_2_0_types_dns_error_payload_t) { + (http_trigger_option_string_t) option, + (http_trigger_option_u16_t) option0, + }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + http_trigger_option_u8_t option1; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option1.is_some = false; + break; + } + case 1: { + option1.is_some = true; + option1.val = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 17))); + break; + } + } + http_trigger_option_string_t option2; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option2.is_some = false; + break; + } + case 1: { + option2.is_some = true; + option2.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + variant.val.tls_alert_received = (wasi_http_0_2_0_types_tls_alert_received_payload_t) { + (http_trigger_option_u8_t) option1, + (http_trigger_option_string_t) option2, + }; + break; + } + case 15: { + break; + } + case 16: { + break; + } + case 17: { + http_trigger_option_u64_t option3; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_request_body_size = option3; + break; + } + case 18: { + break; + } + case 19: { + break; + } + case 20: { + break; + } + case 21: { + http_trigger_option_u32_t option4; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option4.is_some = false; + break; + } + case 1: { + option4.is_some = true; + option4.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_header_section_size = option4; + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_t option7; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option7.is_some = false; + break; + } + case 1: { + option7.is_some = true; + http_trigger_option_string_t option5; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option5.is_some = false; + break; + } + case 1: { + option5.is_some = true; + option5.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option6; + switch ((int32_t) *((uint8_t*) (ptr + (16+4*sizeof(void*))))) { + case 0: { + option6.is_some = false; + break; + } + case 1: { + option6.is_some = true; + option6.val = (uint32_t) (*((int32_t*) (ptr + (20+4*sizeof(void*))))); + break; + } + } + + option7.val = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option5, + (http_trigger_option_u32_t) option6, + }; + break; + } + } + variant.val.http_request_header_size = option7; + break; + } + case 23: { + http_trigger_option_u32_t option8; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option8.is_some = false; + break; + } + case 1: { + option8.is_some = true; + option8.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_trailer_section_size = option8; + break; + } + case 24: { + http_trigger_option_string_t option9; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option9.is_some = false; + break; + } + case 1: { + option9.is_some = true; + option9.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option10; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option10.is_some = false; + break; + } + case 1: { + option10.is_some = true; + option10.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_request_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option9, + (http_trigger_option_u32_t) option10, + }; + break; + } + case 25: { + break; + } + case 26: { + http_trigger_option_u32_t option11; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option11.is_some = false; + break; + } + case 1: { + option11.is_some = true; + option11.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_header_section_size = option11; + break; + } + case 27: { + http_trigger_option_string_t option12; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option12.is_some = false; + break; + } + case 1: { + option12.is_some = true; + option12.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option13; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option13.is_some = false; + break; + } + case 1: { + option13.is_some = true; + option13.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_header_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option12, + (http_trigger_option_u32_t) option13, + }; + break; + } + case 28: { + http_trigger_option_u64_t option14; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option14.is_some = false; + break; + } + case 1: { + option14.is_some = true; + option14.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_response_body_size = option14; + break; + } + case 29: { + http_trigger_option_u32_t option15; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option15.is_some = false; + break; + } + case 1: { + option15.is_some = true; + option15.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_trailer_section_size = option15; + break; + } + case 30: { + http_trigger_option_string_t option16; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option16.is_some = false; + break; + } + case 1: { + option16.is_some = true; + option16.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option17; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option17.is_some = false; + break; + } + case 1: { + option17.is_some = true; + option17.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option16, + (http_trigger_option_u32_t) option17, + }; + break; + } + case 31: { + http_trigger_option_string_t option18; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option18.is_some = false; + break; + } + case 1: { + option18.is_some = true; + option18.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_transfer_coding = option18; + break; + } + case 32: { + http_trigger_option_string_t option19; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option19.is_some = false; + break; + } + case 1: { + option19.is_some = true; + option19.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_content_coding = option19; + break; + } + case 33: { + break; + } + case 34: { + break; + } + case 35: { + break; + } + case 36: { + break; + } + case 37: { + break; + } + case 38: { + http_trigger_option_string_t option20; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option20.is_some = false; + break; + } + case 1: { + option20.is_some = true; + option20.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.internal_error = option20; + break; + } + } + + option21.val = variant; + break; + } + } + *ret = option21.val; + return option21.is_some; +} + +wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_constructor_fields(void) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_constructor_fields(); + return (wasi_http_0_2_0_types_own_fields_t) { ret }; +} + +bool wasi_http_0_2_0_types_static_fields_from_list(http_trigger_list_tuple2_field_key_field_value_t *entries, wasi_http_0_2_0_types_own_fields_t *ret, wasi_http_0_2_0_types_header_error_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_static_fields_from_list((uint8_t *) (*entries).ptr, (*entries).len, ptr); + wasi_http_0_2_0_types_result_own_fields_header_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_fields_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_header_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +void wasi_http_0_2_0_types_method_fields_get(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, http_trigger_list_field_value_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_fields_get((self).__handle, (uint8_t *) (*name).ptr, (*name).len, ptr); + *ret = (http_trigger_list_field_value_t) { (wasi_http_0_2_0_types_field_value_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +bool wasi_http_0_2_0_types_method_fields_has(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_fields_has((self).__handle, (uint8_t *) (*name).ptr, (*name).len); + return ret; +} + +bool wasi_http_0_2_0_types_method_fields_set(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, http_trigger_list_field_value_t *value, wasi_http_0_2_0_types_header_error_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_fields_set((self).__handle, (uint8_t *) (*name).ptr, (*name).len, (uint8_t *) (*value).ptr, (*value).len, ptr); + wasi_http_0_2_0_types_result_void_header_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_header_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 1)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_http_0_2_0_types_method_fields_delete(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, wasi_http_0_2_0_types_header_error_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_fields_delete((self).__handle, (uint8_t *) (*name).ptr, (*name).len, ptr); + wasi_http_0_2_0_types_result_void_header_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_header_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 1)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_http_0_2_0_types_method_fields_append(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, wasi_http_0_2_0_types_field_value_t *value, wasi_http_0_2_0_types_header_error_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_fields_append((self).__handle, (uint8_t *) (*name).ptr, (*name).len, (uint8_t *) (*value).ptr, (*value).len, ptr); + wasi_http_0_2_0_types_result_void_header_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_header_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 1)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +void wasi_http_0_2_0_types_method_fields_entries(wasi_http_0_2_0_types_borrow_fields_t self, http_trigger_list_tuple2_field_key_field_value_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_fields_entries((self).__handle, ptr); + *ret = (http_trigger_list_tuple2_field_key_field_value_t) { (http_trigger_tuple2_field_key_field_value_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_method_fields_clone(wasi_http_0_2_0_types_borrow_fields_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_fields_clone((self).__handle); + return (wasi_http_0_2_0_types_own_fields_t) { ret }; +} + +void wasi_http_0_2_0_types_method_incoming_request_method(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_method_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_request_method((self).__handle, ptr); + wasi_http_0_2_0_types_method_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 0)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = variant; +} + +bool wasi_http_0_2_0_types_method_incoming_request_path_with_query(wasi_http_0_2_0_types_borrow_incoming_request_t self, http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_request_path_with_query((self).__handle, ptr); + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_incoming_request_scheme(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_scheme_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_request_scheme((self).__handle, ptr); + wasi_http_0_2_0_types_option_scheme_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + wasi_http_0_2_0_types_scheme_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + option.val = variant; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_incoming_request_authority(wasi_http_0_2_0_types_borrow_incoming_request_t self, http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_request_authority((self).__handle, ptr); + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_incoming_request_headers(wasi_http_0_2_0_types_borrow_incoming_request_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_incoming_request_headers((self).__handle); + return (wasi_http_0_2_0_types_own_headers_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_incoming_request_consume(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_own_incoming_body_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_request_consume((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_incoming_body_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_incoming_body_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +wasi_http_0_2_0_types_own_outgoing_request_t wasi_http_0_2_0_types_constructor_outgoing_request(wasi_http_0_2_0_types_own_headers_t headers) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_constructor_outgoing_request((headers).__handle); + return (wasi_http_0_2_0_types_own_outgoing_request_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_outgoing_request_body(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_own_outgoing_body_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_body((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_outgoing_body_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_outgoing_body_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +void wasi_http_0_2_0_types_method_outgoing_request_method(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_method_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_method((self).__handle, ptr); + wasi_http_0_2_0_types_method_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 0)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = variant; +} + +bool wasi_http_0_2_0_types_method_outgoing_request_set_method(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_method_t *method) { + int32_t variant; + uint8_t * variant9; + size_t variant10; + switch ((int32_t) (*method).tag) { + case 0: { + variant = 0; + variant9 = 0; + variant10 = 0; + break; + } + case 1: { + variant = 1; + variant9 = 0; + variant10 = 0; + break; + } + case 2: { + variant = 2; + variant9 = 0; + variant10 = 0; + break; + } + case 3: { + variant = 3; + variant9 = 0; + variant10 = 0; + break; + } + case 4: { + variant = 4; + variant9 = 0; + variant10 = 0; + break; + } + case 5: { + variant = 5; + variant9 = 0; + variant10 = 0; + break; + } + case 6: { + variant = 6; + variant9 = 0; + variant10 = 0; + break; + } + case 7: { + variant = 7; + variant9 = 0; + variant10 = 0; + break; + } + case 8: { + variant = 8; + variant9 = 0; + variant10 = 0; + break; + } + case 9: { + const http_trigger_string_t *payload8 = &(*method).val.other; + variant = 9; + variant9 = (uint8_t *) (*payload8).ptr; + variant10 = (*payload8).len; + break; + } + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_method((self).__handle, variant, variant9, variant10); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_outgoing_request_path_with_query(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_path_with_query((self).__handle, ptr); + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_outgoing_request_set_path_with_query(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *maybe_path_with_query) { + http_trigger_option_string_t path_with_query; + path_with_query.is_some = maybe_path_with_query != NULL;if (maybe_path_with_query) { + path_with_query.val = *maybe_path_with_query; + } + int32_t option; + uint8_t * option1; + size_t option2; + if ((path_with_query).is_some) { + const http_trigger_string_t *payload0 = &(path_with_query).val; + option = 1; + option1 = (uint8_t *) (*payload0).ptr; + option2 = (*payload0).len; + } else { + option = 0; + option1 = 0; + option2 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_path_with_query((self).__handle, option, option1, option2); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_outgoing_request_scheme(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_scheme_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_scheme((self).__handle, ptr); + wasi_http_0_2_0_types_option_scheme_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + wasi_http_0_2_0_types_scheme_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + option.val = variant; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_outgoing_request_set_scheme(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_scheme_t *maybe_scheme) { + wasi_http_0_2_0_types_option_scheme_t scheme; + scheme.is_some = maybe_scheme != NULL;if (maybe_scheme) { + scheme.val = *maybe_scheme; + } + int32_t option; + int32_t option6; + uint8_t * option7; + size_t option8; + if ((scheme).is_some) { + const wasi_http_0_2_0_types_scheme_t *payload0 = &(scheme).val; + int32_t variant; + uint8_t * variant4; + size_t variant5; + switch ((int32_t) (*payload0).tag) { + case 0: { + variant = 0; + variant4 = 0; + variant5 = 0; + break; + } + case 1: { + variant = 1; + variant4 = 0; + variant5 = 0; + break; + } + case 2: { + const http_trigger_string_t *payload3 = &(*payload0).val.other; + variant = 2; + variant4 = (uint8_t *) (*payload3).ptr; + variant5 = (*payload3).len; + break; + } + } + option = 1; + option6 = variant; + option7 = variant4; + option8 = variant5; + } else { + option = 0; + option6 = 0; + option7 = 0; + option8 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_scheme((self).__handle, option, option6, option7, option8); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_outgoing_request_authority(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_authority((self).__handle, ptr); + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_outgoing_request_set_authority(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *maybe_authority) { + http_trigger_option_string_t authority; + authority.is_some = maybe_authority != NULL;if (maybe_authority) { + authority.val = *maybe_authority; + } + int32_t option; + uint8_t * option1; + size_t option2; + if ((authority).is_some) { + const http_trigger_string_t *payload0 = &(authority).val; + option = 1; + option1 = (uint8_t *) (*payload0).ptr; + option2 = (*payload0).len; + } else { + option = 0; + option1 = 0; + option2 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_set_authority((self).__handle, option, option1, option2); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_outgoing_request_headers(wasi_http_0_2_0_types_borrow_outgoing_request_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_request_headers((self).__handle); + return (wasi_http_0_2_0_types_own_headers_t) { ret }; +} + +wasi_http_0_2_0_types_own_request_options_t wasi_http_0_2_0_types_constructor_request_options(void) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_constructor_request_options(); + return (wasi_http_0_2_0_types_own_request_options_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_request_options_connect_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_request_options_connect_timeout((self).__handle, ptr); + http_trigger_option_duration_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_request_options_set_connect_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration) { + http_trigger_option_duration_t duration; + duration.is_some = maybe_duration != NULL;if (maybe_duration) { + duration.val = *maybe_duration; + } + int32_t option; + int64_t option1; + if ((duration).is_some) { + const wasi_http_0_2_0_types_duration_t *payload0 = &(duration).val; + option = 1; + option1 = (int64_t) (*payload0); + } else { + option = 0; + option1 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_request_options_set_connect_timeout((self).__handle, option, option1); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_request_options_first_byte_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_request_options_first_byte_timeout((self).__handle, ptr); + http_trigger_option_duration_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_request_options_set_first_byte_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration) { + http_trigger_option_duration_t duration; + duration.is_some = maybe_duration != NULL;if (maybe_duration) { + duration.val = *maybe_duration; + } + int32_t option; + int64_t option1; + if ((duration).is_some) { + const wasi_http_0_2_0_types_duration_t *payload0 = &(duration).val; + option = 1; + option1 = (int64_t) (*payload0); + } else { + option = 0; + option1 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_request_options_set_first_byte_timeout((self).__handle, option, option1); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_request_options_between_bytes_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_request_options_between_bytes_timeout((self).__handle, ptr); + http_trigger_option_duration_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_http_0_2_0_types_method_request_options_set_between_bytes_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration) { + http_trigger_option_duration_t duration; + duration.is_some = maybe_duration != NULL;if (maybe_duration) { + duration.val = *maybe_duration; + } + int32_t option; + int64_t option1; + if ((duration).is_some) { + const wasi_http_0_2_0_types_duration_t *payload0 = &(duration).val; + option = 1; + option1 = (int64_t) (*payload0); + } else { + option = 0; + option1 = 0; + } + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_request_options_set_between_bytes_timeout((self).__handle, option, option1); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +void wasi_http_0_2_0_types_static_response_outparam_set(wasi_http_0_2_0_types_own_response_outparam_t param, wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t *response) { + int32_t result; + int32_t result146; + int32_t result147; + int64_t result148; + uint8_t * result149; + uint8_t * result150; + size_t result151; + int32_t result152; + if ((*response).is_err) { + const wasi_http_0_2_0_types_error_code_t *payload0 = &(*response).val.err;int32_t variant; + int32_t variant140; + int64_t variant141; + uint8_t * variant142; + uint8_t * variant143; + size_t variant144; + int32_t variant145; + switch ((int32_t) (*payload0).tag) { + case 0: { + variant = 0; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 1: { + const wasi_http_0_2_0_types_dns_error_payload_t *payload2 = &(*payload0).val.dns_error; + int32_t option; + uint8_t * option5; + size_t option6; + if (((*payload2).rcode).is_some) { + const http_trigger_string_t *payload4 = &((*payload2).rcode).val; + option = 1; + option5 = (uint8_t *) (*payload4).ptr; + option6 = (*payload4).len; + } else { + option = 0; + option5 = 0; + option6 = 0; + } + int32_t option9; + int32_t option10; + if (((*payload2).info_code).is_some) { + const uint16_t *payload8 = &((*payload2).info_code).val; + option9 = 1; + option10 = (int32_t) (*payload8); + } else { + option9 = 0; + option10 = 0; + } + variant = 1; + variant140 = option; + variant141 = (int64_t) option5; + variant142 = (uint8_t *) option6; + variant143 = (uint8_t *) option9; + variant144 = option10; + variant145 = 0; + break; + } + case 2: { + variant = 2; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 3: { + variant = 3; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 4: { + variant = 4; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 5: { + variant = 5; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 6: { + variant = 6; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 7: { + variant = 7; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 8: { + variant = 8; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 9: { + variant = 9; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 10: { + variant = 10; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 11: { + variant = 11; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 12: { + variant = 12; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 13: { + variant = 13; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 14: { + const wasi_http_0_2_0_types_tls_alert_received_payload_t *payload23 = &(*payload0).val.tls_alert_received; + int32_t option26; + int32_t option27; + if (((*payload23).alert_id).is_some) { + const uint8_t *payload25 = &((*payload23).alert_id).val; + option26 = 1; + option27 = (int32_t) (*payload25); + } else { + option26 = 0; + option27 = 0; + } + int32_t option30; + uint8_t * option31; + size_t option32; + if (((*payload23).alert_message).is_some) { + const http_trigger_string_t *payload29 = &((*payload23).alert_message).val; + option30 = 1; + option31 = (uint8_t *) (*payload29).ptr; + option32 = (*payload29).len; + } else { + option30 = 0; + option31 = 0; + option32 = 0; + } + variant = 14; + variant140 = option26; + variant141 = (int64_t) option27; + variant142 = (uint8_t *) option30; + variant143 = option31; + variant144 = option32; + variant145 = 0; + break; + } + case 15: { + variant = 15; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 16: { + variant = 16; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 17: { + const http_trigger_option_u64_t *payload35 = &(*payload0).val.http_request_body_size; + int32_t option38; + int64_t option39; + if ((*payload35).is_some) { + const uint64_t *payload37 = &(*payload35).val; + option38 = 1; + option39 = (int64_t) (*payload37); + } else { + option38 = 0; + option39 = 0; + } + variant = 17; + variant140 = option38; + variant141 = option39; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 18: { + variant = 18; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 19: { + variant = 19; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 20: { + variant = 20; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 21: { + const http_trigger_option_u32_t *payload43 = &(*payload0).val.http_request_header_section_size; + int32_t option46; + int32_t option47; + if ((*payload43).is_some) { + const uint32_t *payload45 = &(*payload43).val; + option46 = 1; + option47 = (int32_t) (*payload45); + } else { + option46 = 0; + option47 = 0; + } + variant = 21; + variant140 = option46; + variant141 = (int64_t) option47; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 22: { + const wasi_http_0_2_0_types_option_field_size_payload_t *payload48 = &(*payload0).val.http_request_header_size; + int32_t option60; + int32_t option61; + uint8_t * option62; + size_t option63; + int32_t option64; + int32_t option65; + if ((*payload48).is_some) { + const wasi_http_0_2_0_types_field_size_payload_t *payload50 = &(*payload48).val; + int32_t option53; + uint8_t * option54; + size_t option55; + if (((*payload50).field_name).is_some) { + const http_trigger_string_t *payload52 = &((*payload50).field_name).val; + option53 = 1; + option54 = (uint8_t *) (*payload52).ptr; + option55 = (*payload52).len; + } else { + option53 = 0; + option54 = 0; + option55 = 0; + } + int32_t option58; + int32_t option59; + if (((*payload50).field_size).is_some) { + const uint32_t *payload57 = &((*payload50).field_size).val; + option58 = 1; + option59 = (int32_t) (*payload57); + } else { + option58 = 0; + option59 = 0; + } + option60 = 1; + option61 = option53; + option62 = option54; + option63 = option55; + option64 = option58; + option65 = option59; + } else { + option60 = 0; + option61 = 0; + option62 = 0; + option63 = 0; + option64 = 0; + option65 = 0; + } + variant = 22; + variant140 = option60; + variant141 = (int64_t) option61; + variant142 = option62; + variant143 = (uint8_t *) option63; + variant144 = option64; + variant145 = option65; + break; + } + case 23: { + const http_trigger_option_u32_t *payload66 = &(*payload0).val.http_request_trailer_section_size; + int32_t option69; + int32_t option70; + if ((*payload66).is_some) { + const uint32_t *payload68 = &(*payload66).val; + option69 = 1; + option70 = (int32_t) (*payload68); + } else { + option69 = 0; + option70 = 0; + } + variant = 23; + variant140 = option69; + variant141 = (int64_t) option70; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 24: { + const wasi_http_0_2_0_types_field_size_payload_t *payload71 = &(*payload0).val.http_request_trailer_size; + int32_t option74; + uint8_t * option75; + size_t option76; + if (((*payload71).field_name).is_some) { + const http_trigger_string_t *payload73 = &((*payload71).field_name).val; + option74 = 1; + option75 = (uint8_t *) (*payload73).ptr; + option76 = (*payload73).len; + } else { + option74 = 0; + option75 = 0; + option76 = 0; + } + int32_t option79; + int32_t option80; + if (((*payload71).field_size).is_some) { + const uint32_t *payload78 = &((*payload71).field_size).val; + option79 = 1; + option80 = (int32_t) (*payload78); + } else { + option79 = 0; + option80 = 0; + } + variant = 24; + variant140 = option74; + variant141 = (int64_t) option75; + variant142 = (uint8_t *) option76; + variant143 = (uint8_t *) option79; + variant144 = option80; + variant145 = 0; + break; + } + case 25: { + variant = 25; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 26: { + const http_trigger_option_u32_t *payload82 = &(*payload0).val.http_response_header_section_size; + int32_t option85; + int32_t option86; + if ((*payload82).is_some) { + const uint32_t *payload84 = &(*payload82).val; + option85 = 1; + option86 = (int32_t) (*payload84); + } else { + option85 = 0; + option86 = 0; + } + variant = 26; + variant140 = option85; + variant141 = (int64_t) option86; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 27: { + const wasi_http_0_2_0_types_field_size_payload_t *payload87 = &(*payload0).val.http_response_header_size; + int32_t option90; + uint8_t * option91; + size_t option92; + if (((*payload87).field_name).is_some) { + const http_trigger_string_t *payload89 = &((*payload87).field_name).val; + option90 = 1; + option91 = (uint8_t *) (*payload89).ptr; + option92 = (*payload89).len; + } else { + option90 = 0; + option91 = 0; + option92 = 0; + } + int32_t option95; + int32_t option96; + if (((*payload87).field_size).is_some) { + const uint32_t *payload94 = &((*payload87).field_size).val; + option95 = 1; + option96 = (int32_t) (*payload94); + } else { + option95 = 0; + option96 = 0; + } + variant = 27; + variant140 = option90; + variant141 = (int64_t) option91; + variant142 = (uint8_t *) option92; + variant143 = (uint8_t *) option95; + variant144 = option96; + variant145 = 0; + break; + } + case 28: { + const http_trigger_option_u64_t *payload97 = &(*payload0).val.http_response_body_size; + int32_t option100; + int64_t option101; + if ((*payload97).is_some) { + const uint64_t *payload99 = &(*payload97).val; + option100 = 1; + option101 = (int64_t) (*payload99); + } else { + option100 = 0; + option101 = 0; + } + variant = 28; + variant140 = option100; + variant141 = option101; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 29: { + const http_trigger_option_u32_t *payload102 = &(*payload0).val.http_response_trailer_section_size; + int32_t option105; + int32_t option106; + if ((*payload102).is_some) { + const uint32_t *payload104 = &(*payload102).val; + option105 = 1; + option106 = (int32_t) (*payload104); + } else { + option105 = 0; + option106 = 0; + } + variant = 29; + variant140 = option105; + variant141 = (int64_t) option106; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 30: { + const wasi_http_0_2_0_types_field_size_payload_t *payload107 = &(*payload0).val.http_response_trailer_size; + int32_t option110; + uint8_t * option111; + size_t option112; + if (((*payload107).field_name).is_some) { + const http_trigger_string_t *payload109 = &((*payload107).field_name).val; + option110 = 1; + option111 = (uint8_t *) (*payload109).ptr; + option112 = (*payload109).len; + } else { + option110 = 0; + option111 = 0; + option112 = 0; + } + int32_t option115; + int32_t option116; + if (((*payload107).field_size).is_some) { + const uint32_t *payload114 = &((*payload107).field_size).val; + option115 = 1; + option116 = (int32_t) (*payload114); + } else { + option115 = 0; + option116 = 0; + } + variant = 30; + variant140 = option110; + variant141 = (int64_t) option111; + variant142 = (uint8_t *) option112; + variant143 = (uint8_t *) option115; + variant144 = option116; + variant145 = 0; + break; + } + case 31: { + const http_trigger_option_string_t *payload117 = &(*payload0).val.http_response_transfer_coding; + int32_t option120; + uint8_t * option121; + size_t option122; + if ((*payload117).is_some) { + const http_trigger_string_t *payload119 = &(*payload117).val; + option120 = 1; + option121 = (uint8_t *) (*payload119).ptr; + option122 = (*payload119).len; + } else { + option120 = 0; + option121 = 0; + option122 = 0; + } + variant = 31; + variant140 = option120; + variant141 = (int64_t) option121; + variant142 = (uint8_t *) option122; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 32: { + const http_trigger_option_string_t *payload123 = &(*payload0).val.http_response_content_coding; + int32_t option126; + uint8_t * option127; + size_t option128; + if ((*payload123).is_some) { + const http_trigger_string_t *payload125 = &(*payload123).val; + option126 = 1; + option127 = (uint8_t *) (*payload125).ptr; + option128 = (*payload125).len; + } else { + option126 = 0; + option127 = 0; + option128 = 0; + } + variant = 32; + variant140 = option126; + variant141 = (int64_t) option127; + variant142 = (uint8_t *) option128; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 33: { + variant = 33; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 34: { + variant = 34; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 35: { + variant = 35; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 36: { + variant = 36; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 37: { + variant = 37; + variant140 = 0; + variant141 = 0; + variant142 = 0; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + case 38: { + const http_trigger_option_string_t *payload134 = &(*payload0).val.internal_error; + int32_t option137; + uint8_t * option138; + size_t option139; + if ((*payload134).is_some) { + const http_trigger_string_t *payload136 = &(*payload134).val; + option137 = 1; + option138 = (uint8_t *) (*payload136).ptr; + option139 = (*payload136).len; + } else { + option137 = 0; + option138 = 0; + option139 = 0; + } + variant = 38; + variant140 = option137; + variant141 = (int64_t) option138; + variant142 = (uint8_t *) option139; + variant143 = 0; + variant144 = 0; + variant145 = 0; + break; + } + } + result = 1; + result146 = variant; + result147 = variant140; + result148 = variant141; + result149 = variant142; + result150 = variant143; + result151 = variant144; + result152 = variant145; + } else { + const wasi_http_0_2_0_types_own_outgoing_response_t *payload = &(*response).val.ok;result = 0; + result146 = (*payload).__handle; + result147 = 0; + result148 = 0; + result149 = 0; + result150 = 0; + result151 = 0; + result152 = 0; + } + __wasm_import_wasi_http_0_2_0_types_static_response_outparam_set((param).__handle, result, result146, result147, result148, result149, result150, result151, result152); +} + +wasi_http_0_2_0_types_status_code_t wasi_http_0_2_0_types_method_incoming_response_status(wasi_http_0_2_0_types_borrow_incoming_response_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_incoming_response_status((self).__handle); + return (uint16_t) (ret); +} + +wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_incoming_response_headers(wasi_http_0_2_0_types_borrow_incoming_response_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_incoming_response_headers((self).__handle); + return (wasi_http_0_2_0_types_own_headers_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_incoming_response_consume(wasi_http_0_2_0_types_borrow_incoming_response_t self, wasi_http_0_2_0_types_own_incoming_body_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_response_consume((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_incoming_body_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_incoming_body_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_incoming_body_stream(wasi_http_0_2_0_types_borrow_incoming_body_t self, wasi_http_0_2_0_types_own_input_stream_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_incoming_body_stream((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_input_stream_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_input_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +wasi_http_0_2_0_types_own_future_trailers_t wasi_http_0_2_0_types_static_incoming_body_finish(wasi_http_0_2_0_types_own_incoming_body_t this_) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_static_incoming_body_finish((this_).__handle); + return (wasi_http_0_2_0_types_own_future_trailers_t) { ret }; +} + +wasi_http_0_2_0_types_own_pollable_t wasi_http_0_2_0_types_method_future_trailers_subscribe(wasi_http_0_2_0_types_borrow_future_trailers_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_future_trailers_subscribe((self).__handle); + return (wasi_http_0_2_0_types_own_pollable_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_future_trailers_get(wasi_http_0_2_0_types_borrow_future_trailers_t self, wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(40+4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_future_trailers_get((self).__handle, ptr); + wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_t option23; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option23.is_some = false; + break; + } + case 1: { + option23.is_some = true; + wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t result22; + switch ((int32_t) *((uint8_t*) (ptr + 8))) { + case 0: { + result22.is_err = false; + wasi_http_0_2_0_types_result_option_own_trailers_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + result.is_err = false; + wasi_http_0_2_0_types_option_own_trailers_t option; + switch ((int32_t) *((uint8_t*) (ptr + 24))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_http_0_2_0_types_own_trailers_t) { *((int32_t*) (ptr + 28)) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 24)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + http_trigger_option_string_t option0; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option0.is_some = false; + break; + } + case 1: { + option0.is_some = true; + option0.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u16_t option1; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option1.is_some = false; + break; + } + case 1: { + option1.is_some = true; + option1.val = (uint16_t) ((int32_t) *((uint16_t*) (ptr + (34+3*sizeof(void*))))); + break; + } + } + variant.val.dns_error = (wasi_http_0_2_0_types_dns_error_payload_t) { + (http_trigger_option_string_t) option0, + (http_trigger_option_u16_t) option1, + }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + http_trigger_option_u8_t option2; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option2.is_some = false; + break; + } + case 1: { + option2.is_some = true; + option2.val = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 33))); + break; + } + } + http_trigger_option_string_t option3; + switch ((int32_t) *((uint8_t*) (ptr + (32+1*sizeof(void*))))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+2*sizeof(void*))))), (*((size_t*) (ptr + (32+3*sizeof(void*))))) }; + break; + } + } + variant.val.tls_alert_received = (wasi_http_0_2_0_types_tls_alert_received_payload_t) { + (http_trigger_option_u8_t) option2, + (http_trigger_option_string_t) option3, + }; + break; + } + case 15: { + break; + } + case 16: { + break; + } + case 17: { + http_trigger_option_u64_t option4; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option4.is_some = false; + break; + } + case 1: { + option4.is_some = true; + option4.val = (uint64_t) (*((int64_t*) (ptr + 40))); + break; + } + } + variant.val.http_request_body_size = option4; + break; + } + case 18: { + break; + } + case 19: { + break; + } + case 20: { + break; + } + case 21: { + http_trigger_option_u32_t option5; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option5.is_some = false; + break; + } + case 1: { + option5.is_some = true; + option5.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_request_header_section_size = option5; + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_t option8; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option8.is_some = false; + break; + } + case 1: { + option8.is_some = true; + http_trigger_option_string_t option6; + switch ((int32_t) *((uint8_t*) (ptr + (32+1*sizeof(void*))))) { + case 0: { + option6.is_some = false; + break; + } + case 1: { + option6.is_some = true; + option6.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+2*sizeof(void*))))), (*((size_t*) (ptr + (32+3*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option7; + switch ((int32_t) *((uint8_t*) (ptr + (32+4*sizeof(void*))))) { + case 0: { + option7.is_some = false; + break; + } + case 1: { + option7.is_some = true; + option7.val = (uint32_t) (*((int32_t*) (ptr + (36+4*sizeof(void*))))); + break; + } + } + + option8.val = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option6, + (http_trigger_option_u32_t) option7, + }; + break; + } + } + variant.val.http_request_header_size = option8; + break; + } + case 23: { + http_trigger_option_u32_t option9; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option9.is_some = false; + break; + } + case 1: { + option9.is_some = true; + option9.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_request_trailer_section_size = option9; + break; + } + case 24: { + http_trigger_option_string_t option10; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option10.is_some = false; + break; + } + case 1: { + option10.is_some = true; + option10.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option11; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option11.is_some = false; + break; + } + case 1: { + option11.is_some = true; + option11.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_request_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option10, + (http_trigger_option_u32_t) option11, + }; + break; + } + case 25: { + break; + } + case 26: { + http_trigger_option_u32_t option12; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option12.is_some = false; + break; + } + case 1: { + option12.is_some = true; + option12.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_response_header_section_size = option12; + break; + } + case 27: { + http_trigger_option_string_t option13; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option13.is_some = false; + break; + } + case 1: { + option13.is_some = true; + option13.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option14; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option14.is_some = false; + break; + } + case 1: { + option14.is_some = true; + option14.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_header_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option13, + (http_trigger_option_u32_t) option14, + }; + break; + } + case 28: { + http_trigger_option_u64_t option15; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option15.is_some = false; + break; + } + case 1: { + option15.is_some = true; + option15.val = (uint64_t) (*((int64_t*) (ptr + 40))); + break; + } + } + variant.val.http_response_body_size = option15; + break; + } + case 29: { + http_trigger_option_u32_t option16; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option16.is_some = false; + break; + } + case 1: { + option16.is_some = true; + option16.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_response_trailer_section_size = option16; + break; + } + case 30: { + http_trigger_option_string_t option17; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option17.is_some = false; + break; + } + case 1: { + option17.is_some = true; + option17.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option18; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option18.is_some = false; + break; + } + case 1: { + option18.is_some = true; + option18.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option17, + (http_trigger_option_u32_t) option18, + }; + break; + } + case 31: { + http_trigger_option_string_t option19; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option19.is_some = false; + break; + } + case 1: { + option19.is_some = true; + option19.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_transfer_coding = option19; + break; + } + case 32: { + http_trigger_option_string_t option20; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option20.is_some = false; + break; + } + case 1: { + option20.is_some = true; + option20.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_content_coding = option20; + break; + } + case 33: { + break; + } + case 34: { + break; + } + case 35: { + break; + } + case 36: { + break; + } + case 37: { + break; + } + case 38: { + http_trigger_option_string_t option21; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option21.is_some = false; + break; + } + case 1: { + option21.is_some = true; + option21.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.internal_error = option21; + break; + } + } + + result.val.err = variant; + break; + } + } + + result22.val.ok = result; + break; + } + case 1: { + result22.is_err = true; + break; + } + } + + option23.val = result22; + break; + } + } + *ret = option23.val; + return option23.is_some; +} + +wasi_http_0_2_0_types_own_outgoing_response_t wasi_http_0_2_0_types_constructor_outgoing_response(wasi_http_0_2_0_types_own_headers_t headers) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_constructor_outgoing_response((headers).__handle); + return (wasi_http_0_2_0_types_own_outgoing_response_t) { ret }; +} + +wasi_http_0_2_0_types_status_code_t wasi_http_0_2_0_types_method_outgoing_response_status_code(wasi_http_0_2_0_types_borrow_outgoing_response_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_status_code((self).__handle); + return (uint16_t) (ret); +} + +bool wasi_http_0_2_0_types_method_outgoing_response_set_status_code(wasi_http_0_2_0_types_borrow_outgoing_response_t self, wasi_http_0_2_0_types_status_code_t status_code) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_set_status_code((self).__handle, (int32_t) (status_code)); + wasi_http_0_2_0_types_result_void_void_t result; + switch (ret) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + return 1; + } else { + return 0; + } +} + +wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_outgoing_response_headers(wasi_http_0_2_0_types_borrow_outgoing_response_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_headers((self).__handle); + return (wasi_http_0_2_0_types_own_headers_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_outgoing_response_body(wasi_http_0_2_0_types_borrow_outgoing_response_t self, wasi_http_0_2_0_types_own_outgoing_body_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_response_body((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_outgoing_body_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_outgoing_body_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_method_outgoing_body_write(wasi_http_0_2_0_types_borrow_outgoing_body_t self, wasi_http_0_2_0_types_own_output_stream_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_outgoing_body_write((self).__handle, ptr); + wasi_http_0_2_0_types_result_own_output_stream_void_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + return 0; + } +} + +bool wasi_http_0_2_0_types_static_outgoing_body_finish(wasi_http_0_2_0_types_own_outgoing_body_t this_, wasi_http_0_2_0_types_own_trailers_t *maybe_trailers, wasi_http_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(24+4*sizeof(void*))]; + wasi_http_0_2_0_types_option_own_trailers_t trailers; + trailers.is_some = maybe_trailers != NULL;if (maybe_trailers) { + trailers.val = *maybe_trailers; + } + int32_t option; + int32_t option1; + if ((trailers).is_some) { + const wasi_http_0_2_0_types_own_trailers_t *payload0 = &(trailers).val; + option = 1; + option1 = (*payload0).__handle; + } else { + option = 0; + option1 = 0; + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_static_outgoing_body_finish((this_).__handle, option, option1, ptr); + wasi_http_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + http_trigger_option_string_t option2; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option2.is_some = false; + break; + } + case 1: { + option2.is_some = true; + option2.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u16_t option3; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+3*sizeof(void*))))); + break; + } + } + variant.val.dns_error = (wasi_http_0_2_0_types_dns_error_payload_t) { + (http_trigger_option_string_t) option2, + (http_trigger_option_u16_t) option3, + }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + http_trigger_option_u8_t option4; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option4.is_some = false; + break; + } + case 1: { + option4.is_some = true; + option4.val = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 17))); + break; + } + } + http_trigger_option_string_t option5; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option5.is_some = false; + break; + } + case 1: { + option5.is_some = true; + option5.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + variant.val.tls_alert_received = (wasi_http_0_2_0_types_tls_alert_received_payload_t) { + (http_trigger_option_u8_t) option4, + (http_trigger_option_string_t) option5, + }; + break; + } + case 15: { + break; + } + case 16: { + break; + } + case 17: { + http_trigger_option_u64_t option6; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option6.is_some = false; + break; + } + case 1: { + option6.is_some = true; + option6.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_request_body_size = option6; + break; + } + case 18: { + break; + } + case 19: { + break; + } + case 20: { + break; + } + case 21: { + http_trigger_option_u32_t option7; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option7.is_some = false; + break; + } + case 1: { + option7.is_some = true; + option7.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_header_section_size = option7; + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_t option10; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option10.is_some = false; + break; + } + case 1: { + option10.is_some = true; + http_trigger_option_string_t option8; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option8.is_some = false; + break; + } + case 1: { + option8.is_some = true; + option8.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option9; + switch ((int32_t) *((uint8_t*) (ptr + (16+4*sizeof(void*))))) { + case 0: { + option9.is_some = false; + break; + } + case 1: { + option9.is_some = true; + option9.val = (uint32_t) (*((int32_t*) (ptr + (20+4*sizeof(void*))))); + break; + } + } + + option10.val = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option8, + (http_trigger_option_u32_t) option9, + }; + break; + } + } + variant.val.http_request_header_size = option10; + break; + } + case 23: { + http_trigger_option_u32_t option11; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option11.is_some = false; + break; + } + case 1: { + option11.is_some = true; + option11.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_trailer_section_size = option11; + break; + } + case 24: { + http_trigger_option_string_t option12; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option12.is_some = false; + break; + } + case 1: { + option12.is_some = true; + option12.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option13; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option13.is_some = false; + break; + } + case 1: { + option13.is_some = true; + option13.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_request_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option12, + (http_trigger_option_u32_t) option13, + }; + break; + } + case 25: { + break; + } + case 26: { + http_trigger_option_u32_t option14; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option14.is_some = false; + break; + } + case 1: { + option14.is_some = true; + option14.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_header_section_size = option14; + break; + } + case 27: { + http_trigger_option_string_t option15; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option15.is_some = false; + break; + } + case 1: { + option15.is_some = true; + option15.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option16; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option16.is_some = false; + break; + } + case 1: { + option16.is_some = true; + option16.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_header_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option15, + (http_trigger_option_u32_t) option16, + }; + break; + } + case 28: { + http_trigger_option_u64_t option17; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option17.is_some = false; + break; + } + case 1: { + option17.is_some = true; + option17.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_response_body_size = option17; + break; + } + case 29: { + http_trigger_option_u32_t option18; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option18.is_some = false; + break; + } + case 1: { + option18.is_some = true; + option18.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_trailer_section_size = option18; + break; + } + case 30: { + http_trigger_option_string_t option19; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option19.is_some = false; + break; + } + case 1: { + option19.is_some = true; + option19.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option20; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option20.is_some = false; + break; + } + case 1: { + option20.is_some = true; + option20.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option19, + (http_trigger_option_u32_t) option20, + }; + break; + } + case 31: { + http_trigger_option_string_t option21; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option21.is_some = false; + break; + } + case 1: { + option21.is_some = true; + option21.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_transfer_coding = option21; + break; + } + case 32: { + http_trigger_option_string_t option22; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option22.is_some = false; + break; + } + case 1: { + option22.is_some = true; + option22.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_content_coding = option22; + break; + } + case 33: { + break; + } + case 34: { + break; + } + case 35: { + break; + } + case 36: { + break; + } + case 37: { + break; + } + case 38: { + http_trigger_option_string_t option23; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option23.is_some = false; + break; + } + case 1: { + option23.is_some = true; + option23.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.internal_error = option23; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_http_0_2_0_types_own_pollable_t wasi_http_0_2_0_types_method_future_incoming_response_subscribe(wasi_http_0_2_0_types_borrow_future_incoming_response_t self) { + int32_t ret = __wasm_import_wasi_http_0_2_0_types_method_future_incoming_response_subscribe((self).__handle); + return (wasi_http_0_2_0_types_own_pollable_t) { ret }; +} + +bool wasi_http_0_2_0_types_method_future_incoming_response_get(wasi_http_0_2_0_types_borrow_future_incoming_response_t self, wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(40+4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_types_method_future_incoming_response_get((self).__handle, ptr); + wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_t option22; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option22.is_some = false; + break; + } + case 1: { + option22.is_some = true; + wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t result21; + switch ((int32_t) *((uint8_t*) (ptr + 8))) { + case 0: { + result21.is_err = false; + wasi_http_0_2_0_types_result_own_incoming_response_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_types_own_incoming_response_t) { *((int32_t*) (ptr + 24)) }; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 24)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u16_t option0; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option0.is_some = false; + break; + } + case 1: { + option0.is_some = true; + option0.val = (uint16_t) ((int32_t) *((uint16_t*) (ptr + (34+3*sizeof(void*))))); + break; + } + } + variant.val.dns_error = (wasi_http_0_2_0_types_dns_error_payload_t) { + (http_trigger_option_string_t) option, + (http_trigger_option_u16_t) option0, + }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + http_trigger_option_u8_t option1; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option1.is_some = false; + break; + } + case 1: { + option1.is_some = true; + option1.val = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 33))); + break; + } + } + http_trigger_option_string_t option2; + switch ((int32_t) *((uint8_t*) (ptr + (32+1*sizeof(void*))))) { + case 0: { + option2.is_some = false; + break; + } + case 1: { + option2.is_some = true; + option2.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+2*sizeof(void*))))), (*((size_t*) (ptr + (32+3*sizeof(void*))))) }; + break; + } + } + variant.val.tls_alert_received = (wasi_http_0_2_0_types_tls_alert_received_payload_t) { + (http_trigger_option_u8_t) option1, + (http_trigger_option_string_t) option2, + }; + break; + } + case 15: { + break; + } + case 16: { + break; + } + case 17: { + http_trigger_option_u64_t option3; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (uint64_t) (*((int64_t*) (ptr + 40))); + break; + } + } + variant.val.http_request_body_size = option3; + break; + } + case 18: { + break; + } + case 19: { + break; + } + case 20: { + break; + } + case 21: { + http_trigger_option_u32_t option4; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option4.is_some = false; + break; + } + case 1: { + option4.is_some = true; + option4.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_request_header_section_size = option4; + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_t option7; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option7.is_some = false; + break; + } + case 1: { + option7.is_some = true; + http_trigger_option_string_t option5; + switch ((int32_t) *((uint8_t*) (ptr + (32+1*sizeof(void*))))) { + case 0: { + option5.is_some = false; + break; + } + case 1: { + option5.is_some = true; + option5.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+2*sizeof(void*))))), (*((size_t*) (ptr + (32+3*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option6; + switch ((int32_t) *((uint8_t*) (ptr + (32+4*sizeof(void*))))) { + case 0: { + option6.is_some = false; + break; + } + case 1: { + option6.is_some = true; + option6.val = (uint32_t) (*((int32_t*) (ptr + (36+4*sizeof(void*))))); + break; + } + } + + option7.val = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option5, + (http_trigger_option_u32_t) option6, + }; + break; + } + } + variant.val.http_request_header_size = option7; + break; + } + case 23: { + http_trigger_option_u32_t option8; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option8.is_some = false; + break; + } + case 1: { + option8.is_some = true; + option8.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_request_trailer_section_size = option8; + break; + } + case 24: { + http_trigger_option_string_t option9; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option9.is_some = false; + break; + } + case 1: { + option9.is_some = true; + option9.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option10; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option10.is_some = false; + break; + } + case 1: { + option10.is_some = true; + option10.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_request_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option9, + (http_trigger_option_u32_t) option10, + }; + break; + } + case 25: { + break; + } + case 26: { + http_trigger_option_u32_t option11; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option11.is_some = false; + break; + } + case 1: { + option11.is_some = true; + option11.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_response_header_section_size = option11; + break; + } + case 27: { + http_trigger_option_string_t option12; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option12.is_some = false; + break; + } + case 1: { + option12.is_some = true; + option12.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option13; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option13.is_some = false; + break; + } + case 1: { + option13.is_some = true; + option13.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_header_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option12, + (http_trigger_option_u32_t) option13, + }; + break; + } + case 28: { + http_trigger_option_u64_t option14; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option14.is_some = false; + break; + } + case 1: { + option14.is_some = true; + option14.val = (uint64_t) (*((int64_t*) (ptr + 40))); + break; + } + } + variant.val.http_response_body_size = option14; + break; + } + case 29: { + http_trigger_option_u32_t option15; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option15.is_some = false; + break; + } + case 1: { + option15.is_some = true; + option15.val = (uint32_t) (*((int32_t*) (ptr + 36))); + break; + } + } + variant.val.http_response_trailer_section_size = option15; + break; + } + case 30: { + http_trigger_option_string_t option16; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option16.is_some = false; + break; + } + case 1: { + option16.is_some = true; + option16.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option17; + switch ((int32_t) *((uint8_t*) (ptr + (32+3*sizeof(void*))))) { + case 0: { + option17.is_some = false; + break; + } + case 1: { + option17.is_some = true; + option17.val = (uint32_t) (*((int32_t*) (ptr + (36+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option16, + (http_trigger_option_u32_t) option17, + }; + break; + } + case 31: { + http_trigger_option_string_t option18; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option18.is_some = false; + break; + } + case 1: { + option18.is_some = true; + option18.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_transfer_coding = option18; + break; + } + case 32: { + http_trigger_option_string_t option19; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option19.is_some = false; + break; + } + case 1: { + option19.is_some = true; + option19.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_content_coding = option19; + break; + } + case 33: { + break; + } + case 34: { + break; + } + case 35: { + break; + } + case 36: { + break; + } + case 37: { + break; + } + case 38: { + http_trigger_option_string_t option20; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option20.is_some = false; + break; + } + case 1: { + option20.is_some = true; + option20.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (32+1*sizeof(void*))))), (*((size_t*) (ptr + (32+2*sizeof(void*))))) }; + break; + } + } + variant.val.internal_error = option20; + break; + } + } + + result.val.err = variant; + break; + } + } + + result21.val.ok = result; + break; + } + case 1: { + result21.is_err = true; + break; + } + } + + option22.val = result21; + break; + } + } + *ret = option22.val; + return option22.is_some; +} + +bool wasi_http_0_2_0_outgoing_handler_handle(wasi_http_0_2_0_outgoing_handler_own_outgoing_request_t request, wasi_http_0_2_0_outgoing_handler_own_request_options_t *maybe_options, wasi_http_0_2_0_outgoing_handler_own_future_incoming_response_t *ret, wasi_http_0_2_0_outgoing_handler_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(24+4*sizeof(void*))]; + wasi_http_0_2_0_outgoing_handler_option_own_request_options_t options; + options.is_some = maybe_options != NULL;if (maybe_options) { + options.val = *maybe_options; + } + int32_t option; + int32_t option1; + if ((options).is_some) { + const wasi_http_0_2_0_outgoing_handler_own_request_options_t *payload0 = &(options).val; + option = 1; + option1 = (*payload0).__handle; + } else { + option = 0; + option1 = 0; + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_http_0_2_0_outgoing_handler_handle((request).__handle, option, option1, ptr); + wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_http_0_2_0_outgoing_handler_own_future_incoming_response_t) { *((int32_t*) (ptr + 8)) }; + break; + } + case 1: { + result.is_err = true; + wasi_http_0_2_0_types_error_code_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + http_trigger_option_string_t option2; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option2.is_some = false; + break; + } + case 1: { + option2.is_some = true; + option2.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u16_t option3; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (uint16_t) ((int32_t) *((uint16_t*) (ptr + (18+3*sizeof(void*))))); + break; + } + } + variant.val.dns_error = (wasi_http_0_2_0_types_dns_error_payload_t) { + (http_trigger_option_string_t) option2, + (http_trigger_option_u16_t) option3, + }; + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + break; + } + case 5: { + break; + } + case 6: { + break; + } + case 7: { + break; + } + case 8: { + break; + } + case 9: { + break; + } + case 10: { + break; + } + case 11: { + break; + } + case 12: { + break; + } + case 13: { + break; + } + case 14: { + http_trigger_option_u8_t option4; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option4.is_some = false; + break; + } + case 1: { + option4.is_some = true; + option4.val = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 17))); + break; + } + } + http_trigger_option_string_t option5; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option5.is_some = false; + break; + } + case 1: { + option5.is_some = true; + option5.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + variant.val.tls_alert_received = (wasi_http_0_2_0_types_tls_alert_received_payload_t) { + (http_trigger_option_u8_t) option4, + (http_trigger_option_string_t) option5, + }; + break; + } + case 15: { + break; + } + case 16: { + break; + } + case 17: { + http_trigger_option_u64_t option6; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option6.is_some = false; + break; + } + case 1: { + option6.is_some = true; + option6.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_request_body_size = option6; + break; + } + case 18: { + break; + } + case 19: { + break; + } + case 20: { + break; + } + case 21: { + http_trigger_option_u32_t option7; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option7.is_some = false; + break; + } + case 1: { + option7.is_some = true; + option7.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_header_section_size = option7; + break; + } + case 22: { + wasi_http_0_2_0_types_option_field_size_payload_t option10; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option10.is_some = false; + break; + } + case 1: { + option10.is_some = true; + http_trigger_option_string_t option8; + switch ((int32_t) *((uint8_t*) (ptr + (16+1*sizeof(void*))))) { + case 0: { + option8.is_some = false; + break; + } + case 1: { + option8.is_some = true; + option8.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+2*sizeof(void*))))), (*((size_t*) (ptr + (16+3*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option9; + switch ((int32_t) *((uint8_t*) (ptr + (16+4*sizeof(void*))))) { + case 0: { + option9.is_some = false; + break; + } + case 1: { + option9.is_some = true; + option9.val = (uint32_t) (*((int32_t*) (ptr + (20+4*sizeof(void*))))); + break; + } + } + + option10.val = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option8, + (http_trigger_option_u32_t) option9, + }; + break; + } + } + variant.val.http_request_header_size = option10; + break; + } + case 23: { + http_trigger_option_u32_t option11; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option11.is_some = false; + break; + } + case 1: { + option11.is_some = true; + option11.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_request_trailer_section_size = option11; + break; + } + case 24: { + http_trigger_option_string_t option12; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option12.is_some = false; + break; + } + case 1: { + option12.is_some = true; + option12.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option13; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option13.is_some = false; + break; + } + case 1: { + option13.is_some = true; + option13.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_request_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option12, + (http_trigger_option_u32_t) option13, + }; + break; + } + case 25: { + break; + } + case 26: { + http_trigger_option_u32_t option14; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option14.is_some = false; + break; + } + case 1: { + option14.is_some = true; + option14.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_header_section_size = option14; + break; + } + case 27: { + http_trigger_option_string_t option15; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option15.is_some = false; + break; + } + case 1: { + option15.is_some = true; + option15.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option16; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option16.is_some = false; + break; + } + case 1: { + option16.is_some = true; + option16.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_header_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option15, + (http_trigger_option_u32_t) option16, + }; + break; + } + case 28: { + http_trigger_option_u64_t option17; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option17.is_some = false; + break; + } + case 1: { + option17.is_some = true; + option17.val = (uint64_t) (*((int64_t*) (ptr + 24))); + break; + } + } + variant.val.http_response_body_size = option17; + break; + } + case 29: { + http_trigger_option_u32_t option18; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option18.is_some = false; + break; + } + case 1: { + option18.is_some = true; + option18.val = (uint32_t) (*((int32_t*) (ptr + 20))); + break; + } + } + variant.val.http_response_trailer_section_size = option18; + break; + } + case 30: { + http_trigger_option_string_t option19; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option19.is_some = false; + break; + } + case 1: { + option19.is_some = true; + option19.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + http_trigger_option_u32_t option20; + switch ((int32_t) *((uint8_t*) (ptr + (16+3*sizeof(void*))))) { + case 0: { + option20.is_some = false; + break; + } + case 1: { + option20.is_some = true; + option20.val = (uint32_t) (*((int32_t*) (ptr + (20+3*sizeof(void*))))); + break; + } + } + variant.val.http_response_trailer_size = (wasi_http_0_2_0_types_field_size_payload_t) { + (http_trigger_option_string_t) option19, + (http_trigger_option_u32_t) option20, + }; + break; + } + case 31: { + http_trigger_option_string_t option21; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option21.is_some = false; + break; + } + case 1: { + option21.is_some = true; + option21.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_transfer_coding = option21; + break; + } + case 32: { + http_trigger_option_string_t option22; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option22.is_some = false; + break; + } + case 1: { + option22.is_some = true; + option22.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.http_response_content_coding = option22; + break; + } + case 33: { + break; + } + case 34: { + break; + } + case 35: { + break; + } + case 36: { + break; + } + case 37: { + break; + } + case 38: { + http_trigger_option_string_t option23; + switch ((int32_t) *((uint8_t*) (ptr + 16))) { + case 0: { + option23.is_some = false; + break; + } + case 1: { + option23.is_some = true; + option23.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (16+1*sizeof(void*))))), (*((size_t*) (ptr + (16+2*sizeof(void*))))) }; + break; + } + } + variant.val.internal_error = option23; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_llm_infer(fermyon_spin_2_0_0_llm_inferencing_model_t *model, http_trigger_string_t *prompt, fermyon_spin_2_0_0_llm_inferencing_params_t *maybe_params, fermyon_spin_2_0_0_llm_inferencing_result_t *ret, fermyon_spin_2_0_0_llm_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(8+3*sizeof(void*))]; + fermyon_spin_2_0_0_llm_option_inferencing_params_t params; + params.is_some = maybe_params != NULL;if (maybe_params) { + params.val = *maybe_params; + } + int32_t option; + int32_t option1; + float option2; + int32_t option3; + float option4; + int32_t option5; + float option6; + if ((params).is_some) { + const fermyon_spin_2_0_0_llm_inferencing_params_t *payload0 = &(params).val; + option = 1; + option1 = (int32_t) ((*payload0).max_tokens); + option2 = (*payload0).repeat_penalty; + option3 = (int32_t) ((*payload0).repeat_penalty_last_n_token_count); + option4 = (*payload0).temperature; + option5 = (int32_t) ((*payload0).top_k); + option6 = (*payload0).top_p; + } else { + option = 0; + option1 = 0; + option2 = 0; + option3 = 0; + option4 = 0; + option5 = 0; + option6 = 0; + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_llm_infer((uint8_t *) (*model).ptr, (*model).len, (uint8_t *) (*prompt).ptr, (*prompt).len, option, option1, option2, option3, option4, option5, option6, ptr); + fermyon_spin_2_0_0_llm_result_inferencing_result_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_llm_inferencing_result_t) { + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (fermyon_spin_2_0_0_llm_inferencing_usage_t) (fermyon_spin_2_0_0_llm_inferencing_usage_t) { + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (3*sizeof(void*))))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (4+3*sizeof(void*))))), + }, + }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_llm_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + variant.val.runtime_error = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.invalid_input = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_llm_generate_embeddings(fermyon_spin_2_0_0_llm_embedding_model_t *model, http_trigger_list_string_t *text, fermyon_spin_2_0_0_llm_embeddings_result_t *ret, fermyon_spin_2_0_0_llm_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_llm_generate_embeddings((uint8_t *) (*model).ptr, (*model).len, (uint8_t *) (*text).ptr, (*text).len, ptr); + fermyon_spin_2_0_0_llm_result_embeddings_result_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_llm_embeddings_result_t) { + (http_trigger_list_list_f32_t) (http_trigger_list_list_f32_t) { (http_trigger_list_f32_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (fermyon_spin_2_0_0_llm_embeddings_usage_t) (fermyon_spin_2_0_0_llm_embeddings_usage_t) { + (uint32_t) (uint32_t) (*((int32_t*) (ptr + (3*sizeof(void*))))), + }, + }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_llm_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + variant.val.runtime_error = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.invalid_input = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_redis_own_connection_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_static_connection_open((uint8_t *) (*address).ptr, (*address).len, ptr); + fermyon_spin_2_0_0_redis_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_redis_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_publish(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *channel, fermyon_spin_2_0_0_redis_payload_t *payload, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_publish((self).__handle, (uint8_t *) (*channel).ptr, (*channel).len, (uint8_t *) (*payload).ptr, (*payload).len, ptr); + fermyon_spin_2_0_0_redis_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_get(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_option_payload_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_get((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_redis_result_option_payload_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_payload_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (fermyon_spin_2_0_0_redis_payload_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_set(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, fermyon_spin_2_0_0_redis_payload_t *value, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_set((self).__handle, (uint8_t *) (*key).ptr, (*key).len, (uint8_t *) (*value).ptr, (*value).len, ptr); + fermyon_spin_2_0_0_redis_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_incr(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, int64_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(16+2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_incr((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_redis_result_s64_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = *((int64_t*) (ptr + 8)); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_del(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_list_string_t *keys, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_del((self).__handle, (uint8_t *) (*keys).ptr, (*keys).len, ptr); + fermyon_spin_2_0_0_redis_result_u32_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + sizeof(void*)))); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_sadd(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *values, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_sadd((self).__handle, (uint8_t *) (*key).ptr, (*key).len, (uint8_t *) (*values).ptr, (*values).len, ptr); + fermyon_spin_2_0_0_redis_result_u32_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + sizeof(void*)))); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_smembers(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_smembers((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_redis_result_list_string_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_srem(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *values, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_srem((self).__handle, (uint8_t *) (*key).ptr, (*key).len, (uint8_t *) (*values).ptr, (*values).len, ptr); + fermyon_spin_2_0_0_redis_result_u32_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + sizeof(void*)))); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_redis_method_connection_execute(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *command, fermyon_spin_2_0_0_redis_list_redis_parameter_t *arguments, fermyon_spin_2_0_0_redis_list_redis_result_t *ret, fermyon_spin_2_0_0_redis_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_redis_method_connection_execute((self).__handle, (uint8_t *) (*command).ptr, (*command).len, (uint8_t *) (*arguments).ptr, (*arguments).len, ptr); + fermyon_spin_2_0_0_redis_result_list_redis_result_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_redis_list_redis_result_t) { (fermyon_spin_2_0_0_redis_redis_result_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_redis_error_t variant1; + variant1.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant1.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant1.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant1; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_mqtt_static_connection_open(http_trigger_string_t *address, http_trigger_string_t *username, http_trigger_string_t *password, uint64_t keep_alive_interval_in_secs, fermyon_spin_2_0_0_mqtt_own_connection_t *ret, fermyon_spin_2_0_0_mqtt_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_mqtt_static_connection_open((uint8_t *) (*address).ptr, (*address).len, (uint8_t *) (*username).ptr, (*username).len, (uint8_t *) (*password).ptr, (*password).len, (int64_t) (keep_alive_interval_in_secs), ptr); + fermyon_spin_2_0_0_mqtt_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_mqtt_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_mqtt_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_mqtt_method_connection_publish(fermyon_spin_2_0_0_mqtt_borrow_connection_t self, http_trigger_string_t *topic, fermyon_spin_2_0_0_mqtt_payload_t *payload, fermyon_spin_2_0_0_mqtt_qos_t qos, fermyon_spin_2_0_0_mqtt_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_mqtt_method_connection_publish((self).__handle, (uint8_t *) (*topic).ptr, (*topic).len, (uint8_t *) (*payload).ptr, (*payload).len, (int32_t) qos, ptr); + fermyon_spin_2_0_0_mqtt_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_mqtt_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_postgres_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_postgres_own_connection_t *ret, fermyon_spin_2_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_postgres_static_connection_open((uint8_t *) (*address).ptr, (*address).len, ptr); + fermyon_spin_2_0_0_postgres_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_postgres_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_postgres_method_connection_query(fermyon_spin_2_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_postgres_list_parameter_value_t *params, fermyon_spin_2_0_0_postgres_row_set_t *ret, fermyon_spin_2_0_0_postgres_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_postgres_method_connection_query((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + fermyon_spin_2_0_0_postgres_result_row_set_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_rdbms_types_row_set_t) { + (fermyon_spin_2_0_0_rdbms_types_list_column_t) (fermyon_spin_2_0_0_rdbms_types_list_column_t) { (fermyon_spin_2_0_0_rdbms_types_column_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (fermyon_spin_2_0_0_rdbms_types_list_row_t) (fermyon_spin_2_0_0_rdbms_types_list_row_t) { (fermyon_spin_2_0_0_rdbms_types_row_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant13; + variant13.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant13.tag) { + case 0: { + variant13.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant13.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant13.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant13.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant13.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant13; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_postgres_method_connection_execute(fermyon_spin_2_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, fermyon_spin_2_0_0_postgres_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(16+2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_postgres_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + fermyon_spin_2_0_0_postgres_result_u64_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_mysql_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_mysql_own_connection_t *ret, fermyon_spin_2_0_0_mysql_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_mysql_static_connection_open((uint8_t *) (*address).ptr, (*address).len, ptr); + fermyon_spin_2_0_0_mysql_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_mysql_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_mysql_method_connection_query(fermyon_spin_2_0_0_mysql_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_mysql_list_parameter_value_t *params, fermyon_spin_2_0_0_mysql_row_set_t *ret, fermyon_spin_2_0_0_mysql_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_mysql_method_connection_query((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + fermyon_spin_2_0_0_mysql_result_row_set_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_rdbms_types_row_set_t) { + (fermyon_spin_2_0_0_rdbms_types_list_column_t) (fermyon_spin_2_0_0_rdbms_types_list_column_t) { (fermyon_spin_2_0_0_rdbms_types_column_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (fermyon_spin_2_0_0_rdbms_types_list_row_t) (fermyon_spin_2_0_0_rdbms_types_list_row_t) { (fermyon_spin_2_0_0_rdbms_types_row_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant13; + variant13.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant13.tag) { + case 0: { + variant13.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant13.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant13.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant13.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant13.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant13; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_mysql_method_connection_execute(fermyon_spin_2_0_0_mysql_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_mysql_list_parameter_value_t *params, fermyon_spin_2_0_0_mysql_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_mysql_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*params).ptr, (*params).len, ptr); + fermyon_spin_2_0_0_mysql_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_rdbms_types_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.connection_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.bad_parameter = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.query_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.value_conversion_failed = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 4: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_sqlite_static_connection_open(http_trigger_string_t *database, fermyon_spin_2_0_0_sqlite_own_connection_t *ret, fermyon_spin_2_0_0_sqlite_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_sqlite_static_connection_open((uint8_t *) (*database).ptr, (*database).len, ptr); + fermyon_spin_2_0_0_sqlite_result_own_connection_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_sqlite_own_connection_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_sqlite_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + variant.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_sqlite_method_connection_execute(fermyon_spin_2_0_0_sqlite_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_sqlite_list_value_t *parameters, fermyon_spin_2_0_0_sqlite_query_result_t *ret, fermyon_spin_2_0_0_sqlite_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_sqlite_method_connection_execute((self).__handle, (uint8_t *) (*statement).ptr, (*statement).len, (uint8_t *) (*parameters).ptr, (*parameters).len, ptr); + fermyon_spin_2_0_0_sqlite_result_query_result_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_sqlite_query_result_t) { + (http_trigger_list_string_t) (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (fermyon_spin_2_0_0_sqlite_list_row_result_t) (fermyon_spin_2_0_0_sqlite_list_row_result_t) { (fermyon_spin_2_0_0_sqlite_row_result_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_sqlite_error_t variant4; + variant4.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant4.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + break; + } + case 4: { + variant4.val.io = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant4; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_static_store_open(http_trigger_string_t *label, fermyon_spin_2_0_0_key_value_own_store_t *ret, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_static_store_open((uint8_t *) (*label).ptr, (*label).len, ptr); + fermyon_spin_2_0_0_key_value_result_own_store_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (fermyon_spin_2_0_0_key_value_own_store_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_method_store_get(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, http_trigger_option_list_u8_t *ret, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_method_store_get((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_key_value_result_option_list_u8_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_list_u8_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_method_store_set(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, http_trigger_list_u8_t *value, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_method_store_set((self).__handle, (uint8_t *) (*key).ptr, (*key).len, (uint8_t *) (*value).ptr, (*value).len, ptr); + fermyon_spin_2_0_0_key_value_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_method_store_delete(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_method_store_delete((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_key_value_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_method_store_exists(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, bool *ret, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_method_store_exists((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + fermyon_spin_2_0_0_key_value_result_bool_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_key_value_method_store_get_keys(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_list_string_t *ret, fermyon_spin_2_0_0_key_value_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_key_value_method_store_get_keys((self).__handle, ptr); + fermyon_spin_2_0_0_key_value_result_list_string_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_key_value_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool fermyon_spin_2_0_0_variables_get(http_trigger_string_t *name, http_trigger_string_t *ret, fermyon_spin_2_0_0_variables_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_fermyon_spin_2_0_0_variables_get((uint8_t *) (*name).ptr, (*name).len, ptr); + fermyon_spin_2_0_0_variables_result_string_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + fermyon_spin_2_0_0_variables_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.invalid_name = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 1: { + variant.val.undefined = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 2: { + variant.val.provider = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + case 3: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +void wasi_cli_0_2_0_environment_get_environment(http_trigger_list_tuple2_string_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_environment_get_environment(ptr); + *ret = (http_trigger_list_tuple2_string_string_t) { (http_trigger_tuple2_string_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +void wasi_cli_0_2_0_environment_get_arguments(http_trigger_list_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_environment_get_arguments(ptr); + *ret = (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +bool wasi_cli_0_2_0_environment_initial_cwd(http_trigger_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_environment_initial_cwd(ptr); + http_trigger_option_string_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +void wasi_cli_0_2_0_exit_exit(wasi_cli_0_2_0_exit_result_void_void_t *status) { + int32_t result; + if ((*status).is_err) { + result = 1; + } else { + result = 0; + } + __wasm_import_wasi_cli_0_2_0_exit_exit(result); +} + +wasi_cli_0_2_0_stdin_own_input_stream_t wasi_cli_0_2_0_stdin_get_stdin(void) { + int32_t ret = __wasm_import_wasi_cli_0_2_0_stdin_get_stdin(); + return (wasi_cli_0_2_0_stdin_own_input_stream_t) { ret }; +} + +wasi_cli_0_2_0_stdout_own_output_stream_t wasi_cli_0_2_0_stdout_get_stdout(void) { + int32_t ret = __wasm_import_wasi_cli_0_2_0_stdout_get_stdout(); + return (wasi_cli_0_2_0_stdout_own_output_stream_t) { ret }; +} + +wasi_cli_0_2_0_stderr_own_output_stream_t wasi_cli_0_2_0_stderr_get_stderr(void) { + int32_t ret = __wasm_import_wasi_cli_0_2_0_stderr_get_stderr(); + return (wasi_cli_0_2_0_stderr_own_output_stream_t) { ret }; +} + +bool wasi_cli_0_2_0_terminal_stdin_get_terminal_stdin(wasi_cli_0_2_0_terminal_stdin_own_terminal_input_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_terminal_stdin_get_terminal_stdin(ptr); + wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_cli_0_2_0_terminal_stdin_own_terminal_input_t) { *((int32_t*) (ptr + 4)) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_cli_0_2_0_terminal_stdout_get_terminal_stdout(wasi_cli_0_2_0_terminal_stdout_own_terminal_output_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_terminal_stdout_get_terminal_stdout(ptr); + wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_cli_0_2_0_terminal_stdout_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +bool wasi_cli_0_2_0_terminal_stderr_get_terminal_stderr(wasi_cli_0_2_0_terminal_stderr_own_terminal_output_t *ret) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_cli_0_2_0_terminal_stderr_get_terminal_stderr(ptr); + wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_cli_0_2_0_terminal_stderr_own_terminal_output_t) { *((int32_t*) (ptr + 4)) }; + break; + } + } + *ret = option.val; + return option.is_some; +} + +void wasi_clocks_0_2_0_wall_clock_now(wasi_clocks_0_2_0_wall_clock_datetime_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_clocks_0_2_0_wall_clock_now(ptr); + *ret = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), + }; +} + +void wasi_clocks_0_2_0_wall_clock_resolution(wasi_clocks_0_2_0_wall_clock_datetime_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_clocks_0_2_0_wall_clock_resolution(ptr); + *ret = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 8))), + }; +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_read_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_own_input_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read_via_stream((self).__handle, (int64_t) (offset), ptr); + wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_own_input_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_write_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_write_via_stream((self).__handle, (int64_t) (offset), ptr); + wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_append_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_append_via_stream((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_own_output_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_advise(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_filesize_t length, wasi_filesystem_0_2_0_types_advice_t advice, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_advise((self).__handle, (int64_t) (offset), (int64_t) (length), (int32_t) advice, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_sync_data(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_sync_data((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_get_flags(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_flags_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_get_flags((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_get_type(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_type_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_get_type((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_set_size(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t size, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_size((self).__handle, (int64_t) (size), ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_set_times(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + int32_t variant; + int64_t variant2; + int32_t variant3; + switch ((int32_t) (*data_access_timestamp).tag) { + case 0: { + variant = 0; + variant2 = 0; + variant3 = 0; + break; + } + case 1: { + variant = 1; + variant2 = 0; + variant3 = 0; + break; + } + case 2: { + const wasi_filesystem_0_2_0_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; + variant = 2; + variant2 = (int64_t) ((*payload1).seconds); + variant3 = (int32_t) ((*payload1).nanoseconds); + break; + } + } + int32_t variant7; + int64_t variant8; + int32_t variant9; + switch ((int32_t) (*data_modification_timestamp).tag) { + case 0: { + variant7 = 0; + variant8 = 0; + variant9 = 0; + break; + } + case 1: { + variant7 = 1; + variant8 = 0; + variant9 = 0; + break; + } + case 2: { + const wasi_filesystem_0_2_0_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; + variant7 = 2; + variant8 = (int64_t) ((*payload6).seconds); + variant9 = (int32_t) ((*payload6).nanoseconds); + break; + } + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_times((self).__handle, variant, variant2, variant3, variant7, variant8, variant9, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_read(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t length, wasi_filesystem_0_2_0_types_filesize_t offset, http_trigger_tuple2_list_u8_bool_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read((self).__handle, (int64_t) (length), (int64_t) (offset), ptr); + wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_tuple2_list_u8_bool_t) { + (http_trigger_list_u8_t) (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (bool) (int32_t) *((uint8_t*) (ptr + (3*sizeof(void*)))), + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_write(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_list_u8_t *buffer, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_filesize_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_write((self).__handle, (uint8_t *) (*buffer).ptr, (*buffer).len, (int64_t) (offset), ptr); + wasi_filesystem_0_2_0_types_result_filesize_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_read_directory(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_own_directory_entry_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_read_directory((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_own_directory_entry_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_sync(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_sync((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_create_directory_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_create_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_stat(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[104]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_stat((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_filesystem_0_2_0_types_option_datetime_t option; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), + }; + break; + } + } + wasi_filesystem_0_2_0_types_option_datetime_t option0; + switch ((int32_t) *((uint8_t*) (ptr + 56))) { + case 0: { + option0.is_some = false; + break; + } + case 1: { + option0.is_some = true; + option0.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), + }; + break; + } + } + wasi_filesystem_0_2_0_types_option_datetime_t option1; + switch ((int32_t) *((uint8_t*) (ptr + 80))) { + case 0: { + option1.is_some = false; + break; + } + case 1: { + option1.is_some = true; + option1.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), + }; + break; + } + } + + result.val.ok = (wasi_filesystem_0_2_0_types_descriptor_stat_t) { + (wasi_filesystem_0_2_0_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), + (wasi_filesystem_0_2_0_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), + (wasi_filesystem_0_2_0_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), + (wasi_filesystem_0_2_0_types_option_datetime_t) option, + (wasi_filesystem_0_2_0_types_option_datetime_t) option0, + (wasi_filesystem_0_2_0_types_option_datetime_t) option1, + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_stat_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[104]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_stat_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_filesystem_0_2_0_types_option_datetime_t option; + switch ((int32_t) *((uint8_t*) (ptr + 32))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 40))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 48))), + }; + break; + } + } + wasi_filesystem_0_2_0_types_option_datetime_t option0; + switch ((int32_t) *((uint8_t*) (ptr + 56))) { + case 0: { + option0.is_some = false; + break; + } + case 1: { + option0.is_some = true; + option0.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 64))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 72))), + }; + break; + } + } + wasi_filesystem_0_2_0_types_option_datetime_t option1; + switch ((int32_t) *((uint8_t*) (ptr + 80))) { + case 0: { + option1.is_some = false; + break; + } + case 1: { + option1.is_some = true; + option1.val = (wasi_clocks_0_2_0_wall_clock_datetime_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 88))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 96))), + }; + break; + } + } + + result.val.ok = (wasi_filesystem_0_2_0_types_descriptor_stat_t) { + (wasi_filesystem_0_2_0_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + 8)), + (wasi_filesystem_0_2_0_types_link_count_t) (uint64_t) (*((int64_t*) (ptr + 16))), + (wasi_filesystem_0_2_0_types_filesize_t) (uint64_t) (*((int64_t*) (ptr + 24))), + (wasi_filesystem_0_2_0_types_option_datetime_t) option, + (wasi_filesystem_0_2_0_types_option_datetime_t) option0, + (wasi_filesystem_0_2_0_types_option_datetime_t) option1, + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_set_times_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + int32_t variant; + int64_t variant2; + int32_t variant3; + switch ((int32_t) (*data_access_timestamp).tag) { + case 0: { + variant = 0; + variant2 = 0; + variant3 = 0; + break; + } + case 1: { + variant = 1; + variant2 = 0; + variant3 = 0; + break; + } + case 2: { + const wasi_filesystem_0_2_0_types_datetime_t *payload1 = &(*data_access_timestamp).val.timestamp; + variant = 2; + variant2 = (int64_t) ((*payload1).seconds); + variant3 = (int32_t) ((*payload1).nanoseconds); + break; + } + } + int32_t variant7; + int64_t variant8; + int32_t variant9; + switch ((int32_t) (*data_modification_timestamp).tag) { + case 0: { + variant7 = 0; + variant8 = 0; + variant9 = 0; + break; + } + case 1: { + variant7 = 1; + variant8 = 0; + variant9 = 0; + break; + } + case 2: { + const wasi_filesystem_0_2_0_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp; + variant7 = 2; + variant8 = (int64_t) ((*payload6).seconds); + variant9 = (int32_t) ((*payload6).nanoseconds); + break; + } + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_set_times_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, variant, variant2, variant3, variant7, variant8, variant9, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_link_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t old_path_flags, http_trigger_string_t *old_path, wasi_filesystem_0_2_0_types_borrow_descriptor_t new_descriptor, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_link_at((self).__handle, old_path_flags, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_open_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_open_flags_t open_flags, wasi_filesystem_0_2_0_types_descriptor_flags_t flags, wasi_filesystem_0_2_0_types_own_descriptor_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_open_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, open_flags, flags, ptr); + wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_own_descriptor_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_readlink_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, http_trigger_string_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_readlink_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_string_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_remove_directory_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_remove_directory_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_rename_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *old_path, wasi_filesystem_0_2_0_types_borrow_descriptor_t new_descriptor, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_rename_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (new_descriptor).__handle, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_symlink_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *old_path, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_symlink_at((self).__handle, (uint8_t *) (*old_path).ptr, (*old_path).len, (uint8_t *) (*new_path).ptr, (*new_path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_unlink_file_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_unlink_file_at((self).__handle, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_is_same_object(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_borrow_descriptor_t other) { + int32_t ret = __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_is_same_object((self).__handle, (other).__handle); + return ret; +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[24]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_metadata_hash_value_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[24]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash_at((self).__handle, path_flags, (uint8_t *) (*path).ptr, (*path).len, ptr); + wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_filesystem_0_2_0_types_metadata_hash_value_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 16))), + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t self, wasi_filesystem_0_2_0_types_option_directory_entry_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_method_directory_entry_stream_read_directory_entry((self).__handle, ptr); + wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_filesystem_0_2_0_types_option_directory_entry_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (wasi_filesystem_0_2_0_types_directory_entry_t) { + (wasi_filesystem_0_2_0_types_descriptor_type_t) (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))), + (http_trigger_string_t) (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }, + }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_filesystem_0_2_0_types_filesystem_error_code(wasi_filesystem_0_2_0_types_borrow_error_t err_, wasi_filesystem_0_2_0_types_error_code_t *ret) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_types_filesystem_error_code((err_).__handle, ptr); + wasi_filesystem_0_2_0_types_option_error_code_t option; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + *ret = option.val; + return option.is_some; +} + +void wasi_filesystem_0_2_0_preopens_get_directories(wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_filesystem_0_2_0_preopens_get_directories(ptr); + *ret = (wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t) { (wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +wasi_sockets_0_2_0_instance_network_own_network_t wasi_sockets_0_2_0_instance_network_instance_network(void) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_instance_network_instance_network(); + return (wasi_sockets_0_2_0_instance_network_own_network_t) { ret }; +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_start_bind(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_borrow_network_t network, wasi_sockets_0_2_0_udp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + int32_t variant; + int32_t variant1; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + switch ((int32_t) (*local_address).tag) { + case 0: { + const wasi_sockets_0_2_0_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; + variant = 0; + variant1 = (int32_t) ((*payload).port); + variant2 = (int32_t) (((*payload).address).f0); + variant3 = (int32_t) (((*payload).address).f1); + variant4 = (int32_t) (((*payload).address).f2); + variant5 = (int32_t) (((*payload).address).f3); + variant6 = 0; + variant7 = 0; + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; + break; + } + case 1: { + const wasi_sockets_0_2_0_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; + variant = 1; + variant1 = (int32_t) ((*payload0).port); + variant2 = (int32_t) ((*payload0).flow_info); + variant3 = (int32_t) (((*payload0).address).f0); + variant4 = (int32_t) (((*payload0).address).f1); + variant5 = (int32_t) (((*payload0).address).f2); + variant6 = (int32_t) (((*payload0).address).f3); + variant7 = (int32_t) (((*payload0).address).f4); + variant8 = (int32_t) (((*payload0).address).f5); + variant9 = (int32_t) (((*payload0).address).f6); + variant10 = (int32_t) (((*payload0).address).f7); + variant11 = (int32_t) ((*payload0).scope_id); + break; + } + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_0_2_0_udp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_finish_bind(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_finish_bind((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_stream(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_0_2_0_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + wasi_sockets_0_2_0_udp_option_ip_socket_address_t remote_address; + remote_address.is_some = maybe_remote_address != NULL;if (maybe_remote_address) { + remote_address.val = *maybe_remote_address; + } + int32_t option; + int32_t option14; + int32_t option15; + int32_t option16; + int32_t option17; + int32_t option18; + int32_t option19; + int32_t option20; + int32_t option21; + int32_t option22; + int32_t option23; + int32_t option24; + int32_t option25; + if ((remote_address).is_some) { + const wasi_sockets_0_2_0_udp_ip_socket_address_t *payload0 = &(remote_address).val; + int32_t variant; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + int32_t variant12; + int32_t variant13; + switch ((int32_t) (*payload0).tag) { + case 0: { + const wasi_sockets_0_2_0_network_ipv4_socket_address_t *payload1 = &(*payload0).val.ipv4; + variant = 0; + variant3 = (int32_t) ((*payload1).port); + variant4 = (int32_t) (((*payload1).address).f0); + variant5 = (int32_t) (((*payload1).address).f1); + variant6 = (int32_t) (((*payload1).address).f2); + variant7 = (int32_t) (((*payload1).address).f3); + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; + variant12 = 0; + variant13 = 0; + break; + } + case 1: { + const wasi_sockets_0_2_0_network_ipv6_socket_address_t *payload2 = &(*payload0).val.ipv6; + variant = 1; + variant3 = (int32_t) ((*payload2).port); + variant4 = (int32_t) ((*payload2).flow_info); + variant5 = (int32_t) (((*payload2).address).f0); + variant6 = (int32_t) (((*payload2).address).f1); + variant7 = (int32_t) (((*payload2).address).f2); + variant8 = (int32_t) (((*payload2).address).f3); + variant9 = (int32_t) (((*payload2).address).f4); + variant10 = (int32_t) (((*payload2).address).f5); + variant11 = (int32_t) (((*payload2).address).f6); + variant12 = (int32_t) (((*payload2).address).f7); + variant13 = (int32_t) ((*payload2).scope_id); + break; + } + } + option = 1; + option14 = variant; + option15 = variant3; + option16 = variant4; + option17 = variant5; + option18 = variant6; + option19 = variant7; + option20 = variant8; + option21 = variant9; + option22 = variant10; + option23 = variant11; + option24 = variant12; + option25 = variant13; + } else { + option = 0; + option14 = 0; + option15 = 0; + option16 = 0; + option17 = 0; + option18 = 0; + option19 = 0; + option20 = 0; + option21 = 0; + option22 = 0; + option23 = 0; + option24 = 0; + option25 = 0; + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_stream((self).__handle, option, option14, option15, option16, option17, option18, option19, option20, option21, option22, option23, option24, option25, ptr); + wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t) { + (wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t) (wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t) { *((int32_t*) (ptr + 4)) }, + (wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t) (wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t) { *((int32_t*) (ptr + 8)) }, + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_local_address(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[36]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_local_address((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_sockets_0_2_0_network_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_0_2_0_network_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (wasi_sockets_0_2_0_network_ipv4_address_t) (wasi_sockets_0_2_0_network_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_0_2_0_network_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), + (wasi_sockets_0_2_0_network_ipv6_address_t) (wasi_sockets_0_2_0_network_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + }; + break; + } + } + + result.val.ok = variant; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_remote_address(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[36]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_remote_address((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_sockets_0_2_0_network_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_0_2_0_network_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (wasi_sockets_0_2_0_network_ipv4_address_t) (wasi_sockets_0_2_0_network_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_0_2_0_network_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), + (wasi_sockets_0_2_0_network_ipv6_address_t) (wasi_sockets_0_2_0_network_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + }; + break; + } + } + + result.val.ok = variant; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_udp_ip_address_family_t wasi_sockets_0_2_0_udp_method_udp_socket_address_family(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_address_family((self).__handle); + return ret; +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_unicast_hop_limit((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_u8_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_unicast_hop_limit((self).__handle, (int32_t) (value), ptr); + wasi_sockets_0_2_0_udp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_receive_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_receive_buffer_size((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_udp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_send_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_send_buffer_size((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_udp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_udp_socket_subscribe(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_udp_method_udp_socket_subscribe((self).__handle); + return (wasi_sockets_0_2_0_udp_own_pollable_t) { ret }; +} + +bool wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_receive(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_0_2_0_udp_list_incoming_datagram_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(3*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_receive((self).__handle, (int64_t) (max_results), ptr); + wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_udp_list_incoming_datagram_t) { (wasi_sockets_0_2_0_udp_incoming_datagram_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_subscribe((self).__handle); + return (wasi_sockets_0_2_0_udp_own_pollable_t) { ret }; +} + +bool wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_check_send((self).__handle, ptr); + wasi_sockets_0_2_0_udp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_send(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_0_2_0_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_send((self).__handle, (uint8_t *) (*datagrams).ptr, (*datagrams).len, ptr); + wasi_sockets_0_2_0_udp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_subscribe((self).__handle); + return (wasi_sockets_0_2_0_udp_own_pollable_t) { ret }; +} + +bool wasi_sockets_0_2_0_udp_create_socket_create_udp_socket(wasi_sockets_0_2_0_udp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_0_2_0_udp_create_socket_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_udp_create_socket_create_udp_socket((int32_t) address_family, ptr); + wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_udp_create_socket_own_udp_socket_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_bind(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_borrow_network_t network, wasi_sockets_0_2_0_tcp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + int32_t variant; + int32_t variant1; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + switch ((int32_t) (*local_address).tag) { + case 0: { + const wasi_sockets_0_2_0_network_ipv4_socket_address_t *payload = &(*local_address).val.ipv4; + variant = 0; + variant1 = (int32_t) ((*payload).port); + variant2 = (int32_t) (((*payload).address).f0); + variant3 = (int32_t) (((*payload).address).f1); + variant4 = (int32_t) (((*payload).address).f2); + variant5 = (int32_t) (((*payload).address).f3); + variant6 = 0; + variant7 = 0; + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; + break; + } + case 1: { + const wasi_sockets_0_2_0_network_ipv6_socket_address_t *payload0 = &(*local_address).val.ipv6; + variant = 1; + variant1 = (int32_t) ((*payload0).port); + variant2 = (int32_t) ((*payload0).flow_info); + variant3 = (int32_t) (((*payload0).address).f0); + variant4 = (int32_t) (((*payload0).address).f1); + variant5 = (int32_t) (((*payload0).address).f2); + variant6 = (int32_t) (((*payload0).address).f3); + variant7 = (int32_t) (((*payload0).address).f4); + variant8 = (int32_t) (((*payload0).address).f5); + variant9 = (int32_t) (((*payload0).address).f6); + variant10 = (int32_t) (((*payload0).address).f7); + variant11 = (int32_t) ((*payload0).scope_id); + break; + } + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_bind((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_bind(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_bind((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_connect(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_borrow_network_t network, wasi_sockets_0_2_0_tcp_ip_socket_address_t *remote_address, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + int32_t variant; + int32_t variant1; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + switch ((int32_t) (*remote_address).tag) { + case 0: { + const wasi_sockets_0_2_0_network_ipv4_socket_address_t *payload = &(*remote_address).val.ipv4; + variant = 0; + variant1 = (int32_t) ((*payload).port); + variant2 = (int32_t) (((*payload).address).f0); + variant3 = (int32_t) (((*payload).address).f1); + variant4 = (int32_t) (((*payload).address).f2); + variant5 = (int32_t) (((*payload).address).f3); + variant6 = 0; + variant7 = 0; + variant8 = 0; + variant9 = 0; + variant10 = 0; + variant11 = 0; + break; + } + case 1: { + const wasi_sockets_0_2_0_network_ipv6_socket_address_t *payload0 = &(*remote_address).val.ipv6; + variant = 1; + variant1 = (int32_t) ((*payload0).port); + variant2 = (int32_t) ((*payload0).flow_info); + variant3 = (int32_t) (((*payload0).address).f0); + variant4 = (int32_t) (((*payload0).address).f1); + variant5 = (int32_t) (((*payload0).address).f2); + variant6 = (int32_t) (((*payload0).address).f3); + variant7 = (int32_t) (((*payload0).address).f4); + variant8 = (int32_t) (((*payload0).address).f5); + variant9 = (int32_t) (((*payload0).address).f6); + variant10 = (int32_t) (((*payload0).address).f7); + variant11 = (int32_t) ((*payload0).scope_id); + break; + } + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_connect((self).__handle, (network).__handle, variant, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9, variant10, variant11, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_connect(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[12]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_connect((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_tcp_tuple2_own_input_stream_own_output_stream_t) { + (wasi_sockets_0_2_0_tcp_own_input_stream_t) (wasi_sockets_0_2_0_tcp_own_input_stream_t) { *((int32_t*) (ptr + 4)) }, + (wasi_sockets_0_2_0_tcp_own_output_stream_t) (wasi_sockets_0_2_0_tcp_own_output_stream_t) { *((int32_t*) (ptr + 8)) }, + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_listen(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_start_listen((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_listen(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_listen((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_accept(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_accept((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t) { + (wasi_sockets_0_2_0_tcp_own_tcp_socket_t) (wasi_sockets_0_2_0_tcp_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }, + (wasi_sockets_0_2_0_tcp_own_input_stream_t) (wasi_sockets_0_2_0_tcp_own_input_stream_t) { *((int32_t*) (ptr + 8)) }, + (wasi_sockets_0_2_0_tcp_own_output_stream_t) (wasi_sockets_0_2_0_tcp_own_output_stream_t) { *((int32_t*) (ptr + 12)) }, + }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_local_address(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[36]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_local_address((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_sockets_0_2_0_network_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_0_2_0_network_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (wasi_sockets_0_2_0_network_ipv4_address_t) (wasi_sockets_0_2_0_network_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_0_2_0_network_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), + (wasi_sockets_0_2_0_network_ipv6_address_t) (wasi_sockets_0_2_0_network_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + }; + break; + } + } + + result.val.ok = variant; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_remote_address(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[36]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_remote_address((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_sockets_0_2_0_network_ip_socket_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_0_2_0_network_ipv4_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (wasi_sockets_0_2_0_network_ipv4_address_t) (wasi_sockets_0_2_0_network_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 10))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 11))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 12))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 13))), + }, + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_0_2_0_network_ipv6_socket_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 12))), + (wasi_sockets_0_2_0_network_ipv6_address_t) (wasi_sockets_0_2_0_network_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 22))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 24))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 26))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 28))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 30))), + }, + (uint32_t) (uint32_t) (*((int32_t*) (ptr + 32))), + }; + break; + } + } + + result.val.ok = variant; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_is_listening(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_is_listening((self).__handle); + return ret; +} + +wasi_sockets_0_2_0_tcp_ip_address_family_t wasi_sockets_0_2_0_tcp_method_tcp_socket_address_family(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_address_family((self).__handle); + return ret; +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_listen_backlog_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_enabled((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_bool_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_enabled((self).__handle, value, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_idle_time((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_duration_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_idle_time((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_interval((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_duration_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_interval((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_count((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_u32_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint32_t) (*((int32_t*) (ptr + 4))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_count((self).__handle, (int32_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_hop_limit(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_hop_limit((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_u8_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint8_t) ((int32_t) *((uint8_t*) (ptr + 1))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_hop_limit((self).__handle, (int32_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_receive_buffer_size((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_send_buffer_size((self).__handle, ptr); + wasi_sockets_0_2_0_tcp_result_u64_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (uint64_t) (*((int64_t*) (ptr + 8))); + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 8)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_tcp_own_pollable_t wasi_sockets_0_2_0_tcp_method_tcp_socket_subscribe(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_subscribe((self).__handle); + return (wasi_sockets_0_2_0_tcp_own_pollable_t) { ret }; +} + +bool wasi_sockets_0_2_0_tcp_method_tcp_socket_shutdown(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_shutdown_type_t shutdown_type, wasi_sockets_0_2_0_tcp_error_code_t *err) { + __attribute__((__aligned__(1))) + uint8_t ret_area[2]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_method_tcp_socket_shutdown((self).__handle, (int32_t) shutdown_type, ptr); + wasi_sockets_0_2_0_tcp_result_void_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 1)); + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_tcp_create_socket_create_tcp_socket(wasi_sockets_0_2_0_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_0_2_0_tcp_create_socket_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_tcp_create_socket_create_tcp_socket((int32_t) address_family, ptr); + wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_tcp_create_socket_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_ip_name_lookup_resolve_addresses(wasi_sockets_0_2_0_ip_name_lookup_borrow_network_t network, http_trigger_string_t *name, wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_0_2_0_ip_name_lookup_error_code_t *err) { + __attribute__((__aligned__(4))) + uint8_t ret_area[8]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_resolve_addresses((network).__handle, (uint8_t *) (*name).ptr, (*name).len, ptr); + wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t) { *((int32_t*) (ptr + 4)) }; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 4)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_0_2_0_ip_name_lookup_error_code_t *err) { + __attribute__((__aligned__(2))) + uint8_t ret_area[22]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_resolve_next_address((self).__handle, ptr); + wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t option; + switch ((int32_t) *((uint8_t*) (ptr + 2))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + wasi_sockets_0_2_0_network_ip_address_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 4)); + switch ((int32_t) variant.tag) { + case 0: { + variant.val.ipv4 = (wasi_sockets_0_2_0_network_ipv4_address_t) { + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 6))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 7))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 8))), + (uint8_t) (uint8_t) ((int32_t) *((uint8_t*) (ptr + 9))), + }; + break; + } + case 1: { + variant.val.ipv6 = (wasi_sockets_0_2_0_network_ipv6_address_t) { + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 6))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 8))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 10))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 12))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 14))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 16))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 18))), + (uint16_t) (uint16_t) ((int32_t) *((uint16_t*) (ptr + 20))), + }; + break; + } + } + + option.val = variant; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + result.val.err = (int32_t) *((uint8_t*) (ptr + 2)); + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +wasi_sockets_0_2_0_ip_name_lookup_own_pollable_t wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t self) { + int32_t ret = __wasm_import_wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_subscribe((self).__handle); + return (wasi_sockets_0_2_0_ip_name_lookup_own_pollable_t) { ret }; +} + +void wasi_random_0_2_0_random_get_random_bytes(uint64_t len, http_trigger_list_u8_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_random_0_2_0_random_get_random_bytes((int64_t) (len), ptr); + *ret = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +uint64_t wasi_random_0_2_0_random_get_random_u64(void) { + int64_t ret = __wasm_import_wasi_random_0_2_0_random_get_random_u64(); + return (uint64_t) (ret); +} + +void wasi_random_0_2_0_insecure_get_insecure_random_bytes(uint64_t len, http_trigger_list_u8_t *ret) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_random_0_2_0_insecure_get_insecure_random_bytes((int64_t) (len), ptr); + *ret = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + 0))), (*((size_t*) (ptr + sizeof(void*)))) }; +} + +uint64_t wasi_random_0_2_0_insecure_get_insecure_random_u64(void) { + int64_t ret = __wasm_import_wasi_random_0_2_0_insecure_get_insecure_random_u64(); + return (uint64_t) (ret); +} + +void wasi_random_0_2_0_insecure_seed_insecure_seed(http_trigger_tuple2_u64_u64_t *ret) { + __attribute__((__aligned__(8))) + uint8_t ret_area[16]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_random_0_2_0_insecure_seed_insecure_seed(ptr); + *ret = (http_trigger_tuple2_u64_u64_t) { + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 0))), + (uint64_t) (uint64_t) (*((int64_t*) (ptr + 8))), + }; +} + +bool wasi_keyvalue_store_open(http_trigger_string_t *identifier, wasi_keyvalue_store_own_bucket_t *ret, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_open((uint8_t *) (*identifier).ptr, (*identifier).len, ptr); + wasi_keyvalue_store_result_own_bucket_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_keyvalue_store_own_bucket_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_store_method_bucket_get(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, http_trigger_option_list_u8_t *ret, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_method_bucket_get((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + wasi_keyvalue_store_result_option_list_u8_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_list_u8_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_store_method_bucket_set(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, http_trigger_list_u8_t *value, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_method_bucket_set((self).__handle, (uint8_t *) (*key).ptr, (*key).len, (uint8_t *) (*value).ptr, (*value).len, ptr); + wasi_keyvalue_store_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_store_method_bucket_delete(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_method_bucket_delete((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + wasi_keyvalue_store_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_store_method_bucket_exists(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, bool *ret, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_method_bucket_exists((self).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + wasi_keyvalue_store_result_bool_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_store_method_bucket_list_keys(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *maybe_cursor, wasi_keyvalue_store_key_response_t *ret, wasi_keyvalue_store_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(6*sizeof(void*))]; + http_trigger_option_string_t cursor; + cursor.is_some = maybe_cursor != NULL;if (maybe_cursor) { + cursor.val = *maybe_cursor; + } + int32_t option; + uint8_t * option1; + size_t option2; + if ((cursor).is_some) { + const http_trigger_string_t *payload0 = &(cursor).val; + option = 1; + option1 = (uint8_t *) (*payload0).ptr; + option2 = (*payload0).len; + } else { + option = 0; + option1 = 0; + option2 = 0; + } + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_store_method_bucket_list_keys((self).__handle, option, option1, option2, ptr); + wasi_keyvalue_store_result_key_response_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_string_t option3; + switch ((int32_t) *((uint8_t*) (ptr + (3*sizeof(void*))))) { + case 0: { + option3.is_some = false; + break; + } + case 1: { + option3.is_some = true; + option3.val = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (4*sizeof(void*))))), (*((size_t*) (ptr + (5*sizeof(void*))))) }; + break; + } + } + + result.val.ok = (wasi_keyvalue_store_key_response_t) { + (http_trigger_list_string_t) (http_trigger_list_string_t) { (http_trigger_string_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }, + (http_trigger_option_string_t) option3, + }; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_atomics_static_cas_new(wasi_keyvalue_atomics_borrow_bucket_t bucket, http_trigger_string_t *key, wasi_keyvalue_atomics_own_cas_t *ret, wasi_keyvalue_atomics_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_atomics_static_cas_new((bucket).__handle, (uint8_t *) (*key).ptr, (*key).len, ptr); + wasi_keyvalue_atomics_result_own_cas_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (wasi_keyvalue_atomics_own_cas_t) { *((int32_t*) (ptr + sizeof(void*))) }; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_atomics_method_cas_current(wasi_keyvalue_atomics_borrow_cas_t self, http_trigger_option_list_u8_t *ret, wasi_keyvalue_atomics_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_atomics_method_cas_current((self).__handle, ptr); + wasi_keyvalue_atomics_result_option_list_u8_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + http_trigger_option_list_u8_t option; + switch ((int32_t) *((uint8_t*) (ptr + sizeof(void*)))) { + case 0: { + option.is_some = false; + break; + } + case 1: { + option.is_some = true; + option.val = (http_trigger_list_u8_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.ok = option; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_atomics_increment(wasi_keyvalue_atomics_borrow_bucket_t bucket, http_trigger_string_t *key, int64_t delta, int64_t *ret, wasi_keyvalue_atomics_error_t *err) { + __attribute__((__aligned__(8))) + uint8_t ret_area[(16+2*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_atomics_increment((bucket).__handle, (uint8_t *) (*key).ptr, (*key).len, delta, ptr); + wasi_keyvalue_atomics_result_s64_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = *((int64_t*) (ptr + 8)); + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + 8)); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (8+1*sizeof(void*))))), (*((size_t*) (ptr + (8+2*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_atomics_swap(wasi_keyvalue_atomics_own_cas_t cas, http_trigger_list_u8_t *value, wasi_keyvalue_atomics_cas_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(5*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_atomics_swap((cas).__handle, (uint8_t *) (*value).ptr, (*value).len, ptr); + wasi_keyvalue_atomics_result_void_cas_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_atomics_cas_error_t variant0; + variant0.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant0.tag) { + case 0: { + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + (2*sizeof(void*)))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (3*sizeof(void*))))), (*((size_t*) (ptr + (4*sizeof(void*))))) }; + break; + } + } + variant0.val.store_error = variant; + break; + } + case 1: { + variant0.val.cas_failed = (wasi_keyvalue_atomics_own_cas_t) { *((int32_t*) (ptr + (2*sizeof(void*)))) }; + break; + } + } + + result.val.err = variant0; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_batch_get_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_string_t *keys, http_trigger_list_tuple2_string_option_list_u8_t *ret, wasi_keyvalue_batch_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_batch_get_many((bucket).__handle, (uint8_t *) (*keys).ptr, (*keys).len, ptr); + wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + result.val.ok = (http_trigger_list_tuple2_string_option_list_u8_t) { (http_trigger_tuple2_string_option_list_u8_t*)(*((uint8_t **) (ptr + sizeof(void*)))), (*((size_t*) (ptr + (2*sizeof(void*))))) }; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + *ret = result.val.ok; + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_batch_set_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_tuple2_string_list_u8_t *key_values, wasi_keyvalue_batch_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_batch_set_many((bucket).__handle, (uint8_t *) (*key_values).ptr, (*key_values).len, ptr); + wasi_keyvalue_batch_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +bool wasi_keyvalue_batch_delete_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_string_t *keys, wasi_keyvalue_batch_error_t *err) { + __attribute__((__aligned__(sizeof(void*)))) + uint8_t ret_area[(4*sizeof(void*))]; + uint8_t *ptr = (uint8_t *) &ret_area; + __wasm_import_wasi_keyvalue_batch_delete_many((bucket).__handle, (uint8_t *) (*keys).ptr, (*keys).len, ptr); + wasi_keyvalue_batch_result_void_error_t result; + switch ((int32_t) *((uint8_t*) (ptr + 0))) { + case 0: { + result.is_err = false; + break; + } + case 1: { + result.is_err = true; + wasi_keyvalue_store_error_t variant; + variant.tag = (int32_t) *((uint8_t*) (ptr + sizeof(void*))); + switch ((int32_t) variant.tag) { + case 0: { + break; + } + case 1: { + break; + } + case 2: { + variant.val.other = (http_trigger_string_t) { (uint8_t*)(*((uint8_t **) (ptr + (2*sizeof(void*))))), (*((size_t*) (ptr + (3*sizeof(void*))))) }; + break; + } + } + + result.val.err = variant; + break; + } + } + if (!result.is_err) { + return 1; + } else { + *err = result.val.err; + return 0; + } +} + +__attribute__((__export_name__("wasi:http/incoming-handler@0.2.0#handle"))) +void __wasm_export_exports_wasi_http_0_2_0_incoming_handler_handle(int32_t arg, int32_t arg0) { + exports_wasi_http_0_2_0_incoming_handler_handle((exports_wasi_http_0_2_0_incoming_handler_own_incoming_request_t) { arg }, (exports_wasi_http_0_2_0_incoming_handler_own_response_outparam_t) { arg0 }); +} + +// Ensure that the *_component_type.o object is linked in + +extern void __component_type_object_force_link_http_trigger(void); +__attribute__((used)) +void __component_type_object_force_link_http_trigger_public_use_in_this_compilation_unit(void) { + __component_type_object_force_link_http_trigger(); +} diff --git a/templates/http-c/content/bindings/http_trigger.h b/templates/http-c/content/bindings/http_trigger.h new file mode 100644 index 0000000000..9e3caf9105 --- /dev/null +++ b/templates/http-c/content/bindings/http_trigger.h @@ -0,0 +1,5498 @@ +// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT! +#ifndef __BINDINGS_HTTP_TRIGGER_H +#define __BINDINGS_HTTP_TRIGGER_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +typedef struct http_trigger_string_t { + uint8_t*ptr; + size_t len; +} http_trigger_string_t; + +// Errors related to interacting with a database. +typedef struct spin_postgres_3_0_0_postgres_error_t { + uint8_t tag; + union { + http_trigger_string_t connection_failed; + http_trigger_string_t bad_parameter; + http_trigger_string_t query_failed; + http_trigger_string_t value_conversion_failed; + http_trigger_string_t other; + } val; +} spin_postgres_3_0_0_postgres_error_t; + +#define SPIN_POSTGRES_3_0_0_POSTGRES_ERROR_CONNECTION_FAILED 0 +#define SPIN_POSTGRES_3_0_0_POSTGRES_ERROR_BAD_PARAMETER 1 +#define SPIN_POSTGRES_3_0_0_POSTGRES_ERROR_QUERY_FAILED 2 +#define SPIN_POSTGRES_3_0_0_POSTGRES_ERROR_VALUE_CONVERSION_FAILED 3 +#define SPIN_POSTGRES_3_0_0_POSTGRES_ERROR_OTHER 4 + +// Data types for a database column +typedef uint8_t spin_postgres_3_0_0_postgres_db_data_type_t; + +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_BOOLEAN 0 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_INT8 1 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_INT16 2 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_INT32 3 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_INT64 4 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_FLOATING32 5 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_FLOATING64 6 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_STR 7 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_BINARY 8 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_DATE 9 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_TIME 10 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_DATETIME 11 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_TIMESTAMP 12 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_DATA_TYPE_OTHER 13 + +typedef struct { + uint8_t *ptr; + size_t len; +} http_trigger_list_u8_t; + +typedef struct { + int32_t f0; + uint8_t f1; + uint8_t f2; +} http_trigger_tuple3_s32_u8_u8_t; + +typedef struct { + uint8_t f0; + uint8_t f1; + uint8_t f2; + uint32_t f3; +} http_trigger_tuple4_u8_u8_u8_u32_t; + +typedef struct { + int32_t f0; + uint8_t f1; + uint8_t f2; + uint8_t f3; + uint8_t f4; + uint8_t f5; + uint32_t f6; +} http_trigger_tuple7_s32_u8_u8_u8_u8_u8_u32_t; + +// Database values +typedef struct spin_postgres_3_0_0_postgres_db_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + http_trigger_tuple3_s32_u8_u8_t date; + http_trigger_tuple4_u8_u8_u8_u32_t time; + http_trigger_tuple7_s32_u8_u8_u8_u8_u8_u32_t datetime; + int64_t timestamp; + } val; +} spin_postgres_3_0_0_postgres_db_value_t; + +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_BOOLEAN 0 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_INT8 1 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_INT16 2 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_INT32 3 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_INT64 4 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_FLOATING32 5 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_FLOATING64 6 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_STR 7 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_BINARY 8 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_DATE 9 +// (year, month, day) +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_TIME 10 +// (hour, minute, second, nanosecond) +// Date-time types are always treated as UTC (without timezone info). +// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_DATETIME 11 +// Unix timestamp (seconds since epoch) +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_TIMESTAMP 12 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_DB_NULL 13 +#define SPIN_POSTGRES_3_0_0_POSTGRES_DB_VALUE_UNSUPPORTED 14 + +// Values used in parameterized queries +typedef struct spin_postgres_3_0_0_postgres_parameter_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + http_trigger_tuple3_s32_u8_u8_t date; + http_trigger_tuple4_u8_u8_u8_u32_t time; + http_trigger_tuple7_s32_u8_u8_u8_u8_u8_u32_t datetime; + int64_t timestamp; + } val; +} spin_postgres_3_0_0_postgres_parameter_value_t; + +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_BOOLEAN 0 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_INT8 1 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_INT16 2 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_INT32 3 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_INT64 4 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_FLOATING32 5 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_FLOATING64 6 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_STR 7 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_BINARY 8 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_DATE 9 +// (year, month, day) +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_TIME 10 +// (hour, minute, second, nanosecond) +// Date-time types are always treated as UTC (without timezone info). +// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_DATETIME 11 +// Unix timestamp (seconds since epoch) +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_TIMESTAMP 12 +#define SPIN_POSTGRES_3_0_0_POSTGRES_PARAMETER_VALUE_DB_NULL 13 + +// A database column +typedef struct spin_postgres_3_0_0_postgres_column_t { + http_trigger_string_t name; + spin_postgres_3_0_0_postgres_db_data_type_t data_type; +} spin_postgres_3_0_0_postgres_column_t; + +// A database row +typedef struct spin_postgres_3_0_0_postgres_row_t { + spin_postgres_3_0_0_postgres_db_value_t *ptr; + size_t len; +} spin_postgres_3_0_0_postgres_row_t; + +typedef struct { + spin_postgres_3_0_0_postgres_column_t *ptr; + size_t len; +} spin_postgres_3_0_0_postgres_list_column_t; + +typedef struct { + spin_postgres_3_0_0_postgres_row_t *ptr; + size_t len; +} spin_postgres_3_0_0_postgres_list_row_t; + +// A set of database rows +typedef struct spin_postgres_3_0_0_postgres_row_set_t { + spin_postgres_3_0_0_postgres_list_column_t columns; + spin_postgres_3_0_0_postgres_list_row_t rows; +} spin_postgres_3_0_0_postgres_row_set_t; + +typedef struct spin_postgres_3_0_0_postgres_own_connection_t { + int32_t __handle; +} spin_postgres_3_0_0_postgres_own_connection_t; + +typedef struct spin_postgres_3_0_0_postgres_borrow_connection_t { + int32_t __handle; +} spin_postgres_3_0_0_postgres_borrow_connection_t; + +typedef struct { + bool is_err; + union { + spin_postgres_3_0_0_postgres_own_connection_t ok; + spin_postgres_3_0_0_postgres_error_t err; + } val; +} spin_postgres_3_0_0_postgres_result_own_connection_error_t; + +typedef struct { + spin_postgres_3_0_0_postgres_parameter_value_t *ptr; + size_t len; +} spin_postgres_3_0_0_postgres_list_parameter_value_t; + +typedef struct { + bool is_err; + union { + spin_postgres_3_0_0_postgres_row_set_t ok; + spin_postgres_3_0_0_postgres_error_t err; + } val; +} spin_postgres_3_0_0_postgres_result_row_set_error_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + spin_postgres_3_0_0_postgres_error_t err; + } val; +} spin_postgres_3_0_0_postgres_result_u64_error_t; + +typedef struct { + bool is_some; + http_trigger_string_t val; +} http_trigger_option_string_t; + +typedef struct { + http_trigger_string_t f0; + http_trigger_string_t f1; +} http_trigger_tuple2_string_string_t; + +typedef struct { + http_trigger_tuple2_string_string_t *ptr; + size_t len; +} http_trigger_list_tuple2_string_string_t; + +typedef struct spin_postgres_4_0_0_postgres_db_error_t { + // Stringised version of the error. This is primarily to facilitate migration of older code. + http_trigger_string_t as_text; + http_trigger_string_t severity; + http_trigger_string_t code; + http_trigger_string_t message; + http_trigger_option_string_t detail; + // Any error information provided by Postgres and not captured above. + http_trigger_list_tuple2_string_string_t extras; +} spin_postgres_4_0_0_postgres_db_error_t; + +typedef struct spin_postgres_4_0_0_postgres_query_error_t { + uint8_t tag; + union { + http_trigger_string_t text; + spin_postgres_4_0_0_postgres_db_error_t db_error; + } val; +} spin_postgres_4_0_0_postgres_query_error_t; + +// An error occurred but we do not have structured info for it +#define SPIN_POSTGRES_4_0_0_POSTGRES_QUERY_ERROR_TEXT 0 +// Postgres returned a structured database error +#define SPIN_POSTGRES_4_0_0_POSTGRES_QUERY_ERROR_DB_ERROR 1 + +// Errors related to interacting with a database. +typedef struct spin_postgres_4_0_0_postgres_error_t { + uint8_t tag; + union { + http_trigger_string_t connection_failed; + http_trigger_string_t bad_parameter; + spin_postgres_4_0_0_postgres_query_error_t query_failed; + http_trigger_string_t value_conversion_failed; + http_trigger_string_t other; + } val; +} spin_postgres_4_0_0_postgres_error_t; + +#define SPIN_POSTGRES_4_0_0_POSTGRES_ERROR_CONNECTION_FAILED 0 +#define SPIN_POSTGRES_4_0_0_POSTGRES_ERROR_BAD_PARAMETER 1 +#define SPIN_POSTGRES_4_0_0_POSTGRES_ERROR_QUERY_FAILED 2 +#define SPIN_POSTGRES_4_0_0_POSTGRES_ERROR_VALUE_CONVERSION_FAILED 3 +#define SPIN_POSTGRES_4_0_0_POSTGRES_ERROR_OTHER 4 + +// Data types for a database column +typedef struct spin_postgres_4_0_0_postgres_db_data_type_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} spin_postgres_4_0_0_postgres_db_data_type_t; + +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_BOOLEAN 0 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_INT8 1 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_INT16 2 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_INT32 3 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_INT64 4 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_FLOATING32 5 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_FLOATING64 6 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_STR 7 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_BINARY 8 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_DATE 9 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_TIME 10 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_DATETIME 11 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_TIMESTAMP 12 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_UUID 13 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_JSONB 14 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_DECIMAL 15 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_RANGE_INT32 16 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_RANGE_INT64 17 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_RANGE_DECIMAL 18 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_ARRAY_INT32 19 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_ARRAY_INT64 20 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_ARRAY_DECIMAL 21 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_ARRAY_STR 22 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_INTERVAL 23 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_DATA_TYPE_OTHER 24 + +typedef struct spin_postgres_4_0_0_postgres_interval_t { + int64_t micros; + int32_t days; + int32_t months; +} spin_postgres_4_0_0_postgres_interval_t; + +// A database column +typedef struct spin_postgres_4_0_0_postgres_column_t { + http_trigger_string_t name; + spin_postgres_4_0_0_postgres_db_data_type_t data_type; +} spin_postgres_4_0_0_postgres_column_t; + +// For range types, indicates if each bound is inclusive or exclusive +typedef uint8_t spin_postgres_4_0_0_postgres_range_bound_kind_t; + +#define SPIN_POSTGRES_4_0_0_POSTGRES_RANGE_BOUND_KIND_INCLUSIVE 0 +#define SPIN_POSTGRES_4_0_0_POSTGRES_RANGE_BOUND_KIND_EXCLUSIVE 1 + +typedef struct { + int32_t f0; + spin_postgres_4_0_0_postgres_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_s32_range_bound_kind_t; + +typedef struct { + bool is_some; + spin_postgres_4_0_0_postgres_tuple2_s32_range_bound_kind_t val; +} spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_t; + +typedef struct { + spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_t f0; + spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_t; + +typedef struct { + int64_t f0; + spin_postgres_4_0_0_postgres_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_s64_range_bound_kind_t; + +typedef struct { + bool is_some; + spin_postgres_4_0_0_postgres_tuple2_s64_range_bound_kind_t val; +} spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_t; + +typedef struct { + spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_t f0; + spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_t; + +typedef struct { + http_trigger_string_t f0; + spin_postgres_4_0_0_postgres_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_t; + +typedef struct { + bool is_some; + spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_t val; +} spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_t; + +typedef struct { + spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_t f0; + spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_t f1; +} spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_t; + +typedef struct { + bool is_some; + int32_t val; +} http_trigger_option_s32_t; + +typedef struct { + http_trigger_option_s32_t *ptr; + size_t len; +} http_trigger_list_option_s32_t; + +typedef struct { + bool is_some; + int64_t val; +} http_trigger_option_s64_t; + +typedef struct { + http_trigger_option_s64_t *ptr; + size_t len; +} http_trigger_list_option_s64_t; + +typedef struct { + http_trigger_option_string_t *ptr; + size_t len; +} http_trigger_list_option_string_t; + +// Database values +typedef struct spin_postgres_4_0_0_postgres_db_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + http_trigger_tuple3_s32_u8_u8_t date; + http_trigger_tuple4_u8_u8_u8_u32_t time; + http_trigger_tuple7_s32_u8_u8_u8_u8_u8_u32_t datetime; + int64_t timestamp; + http_trigger_string_t uuid; + http_trigger_list_u8_t jsonb; + http_trigger_string_t decimal; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_t range_int32; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_t range_int64; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_t range_decimal; + http_trigger_list_option_s32_t array_int32; + http_trigger_list_option_s64_t array_int64; + http_trigger_list_option_string_t array_decimal; + http_trigger_list_option_string_t array_str; + spin_postgres_4_0_0_postgres_interval_t interval; + http_trigger_list_u8_t unsupported; + } val; +} spin_postgres_4_0_0_postgres_db_value_t; + +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_BOOLEAN 0 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_INT8 1 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_INT16 2 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_INT32 3 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_INT64 4 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_FLOATING32 5 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_FLOATING64 6 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_STR 7 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_BINARY 8 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_DATE 9 +// (year, month, day) +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_TIME 10 +// (hour, minute, second, nanosecond) +// Date-time types are always treated as UTC (without timezone info). +// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_DATETIME 11 +// Unix timestamp (seconds since epoch) +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_TIMESTAMP 12 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_UUID 13 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_JSONB 14 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_DECIMAL 15 +// I admit defeat. Base 10 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_RANGE_INT32 16 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_RANGE_INT64 17 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_RANGE_DECIMAL 18 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_ARRAY_INT32 19 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_ARRAY_INT64 20 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_ARRAY_DECIMAL 21 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_ARRAY_STR 22 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_INTERVAL 23 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_DB_NULL 24 +#define SPIN_POSTGRES_4_0_0_POSTGRES_DB_VALUE_UNSUPPORTED 25 + +// Values used in parameterized queries +typedef struct spin_postgres_4_0_0_postgres_parameter_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + http_trigger_tuple3_s32_u8_u8_t date; + http_trigger_tuple4_u8_u8_u8_u32_t time; + http_trigger_tuple7_s32_u8_u8_u8_u8_u8_u32_t datetime; + int64_t timestamp; + http_trigger_string_t uuid; + http_trigger_list_u8_t jsonb; + http_trigger_string_t decimal; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_t range_int32; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_t range_int64; + spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_t range_decimal; + http_trigger_list_option_s32_t array_int32; + http_trigger_list_option_s64_t array_int64; + http_trigger_list_option_string_t array_decimal; + http_trigger_list_option_string_t array_str; + spin_postgres_4_0_0_postgres_interval_t interval; + } val; +} spin_postgres_4_0_0_postgres_parameter_value_t; + +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_BOOLEAN 0 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_INT8 1 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_INT16 2 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_INT32 3 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_INT64 4 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_FLOATING32 5 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_FLOATING64 6 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_STR 7 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_BINARY 8 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_DATE 9 +// (year, month, day) +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_TIME 10 +// (hour, minute, second, nanosecond) +// Date-time types are always treated as UTC (without timezone info). +// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_DATETIME 11 +// Unix timestamp (seconds since epoch) +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_TIMESTAMP 12 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_UUID 13 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_JSONB 14 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_DECIMAL 15 +// base 10 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_RANGE_INT32 16 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_RANGE_INT64 17 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_RANGE_DECIMAL 18 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_ARRAY_INT32 19 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_ARRAY_INT64 20 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_ARRAY_DECIMAL 21 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_ARRAY_STR 22 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_INTERVAL 23 +#define SPIN_POSTGRES_4_0_0_POSTGRES_PARAMETER_VALUE_DB_NULL 24 + +// A database row +typedef struct spin_postgres_4_0_0_postgres_row_t { + spin_postgres_4_0_0_postgres_db_value_t *ptr; + size_t len; +} spin_postgres_4_0_0_postgres_row_t; + +typedef struct { + spin_postgres_4_0_0_postgres_column_t *ptr; + size_t len; +} spin_postgres_4_0_0_postgres_list_column_t; + +typedef struct { + spin_postgres_4_0_0_postgres_row_t *ptr; + size_t len; +} spin_postgres_4_0_0_postgres_list_row_t; + +// A set of database rows +typedef struct spin_postgres_4_0_0_postgres_row_set_t { + spin_postgres_4_0_0_postgres_list_column_t columns; + spin_postgres_4_0_0_postgres_list_row_t rows; +} spin_postgres_4_0_0_postgres_row_set_t; + +typedef struct spin_postgres_4_0_0_postgres_own_connection_t { + int32_t __handle; +} spin_postgres_4_0_0_postgres_own_connection_t; + +typedef struct spin_postgres_4_0_0_postgres_borrow_connection_t { + int32_t __handle; +} spin_postgres_4_0_0_postgres_borrow_connection_t; + +typedef struct { + bool is_err; + union { + spin_postgres_4_0_0_postgres_own_connection_t ok; + spin_postgres_4_0_0_postgres_error_t err; + } val; +} spin_postgres_4_0_0_postgres_result_own_connection_error_t; + +typedef struct { + spin_postgres_4_0_0_postgres_parameter_value_t *ptr; + size_t len; +} spin_postgres_4_0_0_postgres_list_parameter_value_t; + +typedef struct { + bool is_err; + union { + spin_postgres_4_0_0_postgres_row_set_t ok; + spin_postgres_4_0_0_postgres_error_t err; + } val; +} spin_postgres_4_0_0_postgres_result_row_set_error_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + spin_postgres_4_0_0_postgres_error_t err; + } val; +} spin_postgres_4_0_0_postgres_result_u64_error_t; + +typedef struct spin_sqlite_sqlite_own_connection_t { + int32_t __handle; +} spin_sqlite_sqlite_own_connection_t; + +typedef struct spin_sqlite_sqlite_borrow_connection_t { + int32_t __handle; +} spin_sqlite_sqlite_borrow_connection_t; + +// The set of errors which may be raised by functions in this interface +typedef struct spin_sqlite_sqlite_error_t { + uint8_t tag; + union { + http_trigger_string_t io; + } val; +} spin_sqlite_sqlite_error_t; + +// The host does not recognize the database name requested. +#define SPIN_SQLITE_SQLITE_ERROR_NO_SUCH_DATABASE 0 +// The requesting component does not have access to the specified database (which may or may not exist). +#define SPIN_SQLITE_SQLITE_ERROR_ACCESS_DENIED 1 +// The provided connection is not valid +#define SPIN_SQLITE_SQLITE_ERROR_INVALID_CONNECTION 2 +// The database has reached its capacity +#define SPIN_SQLITE_SQLITE_ERROR_DATABASE_FULL 3 +// Some implementation-specific error has occurred (e.g. I/O) +#define SPIN_SQLITE_SQLITE_ERROR_IO 4 + +// A single column's result from a database query +typedef struct spin_sqlite_sqlite_value_t { + uint8_t tag; + union { + int64_t integer; + double real; + http_trigger_string_t text; + http_trigger_list_u8_t blob; + } val; +} spin_sqlite_sqlite_value_t; + +#define SPIN_SQLITE_SQLITE_VALUE_INTEGER 0 +#define SPIN_SQLITE_SQLITE_VALUE_REAL 1 +#define SPIN_SQLITE_SQLITE_VALUE_TEXT 2 +#define SPIN_SQLITE_SQLITE_VALUE_BLOB 3 +#define SPIN_SQLITE_SQLITE_VALUE_NULL 4 + +typedef struct { + spin_sqlite_sqlite_value_t *ptr; + size_t len; +} spin_sqlite_sqlite_list_value_t; + +// A set of values for each of the columns in a query-result +typedef struct spin_sqlite_sqlite_row_result_t { + spin_sqlite_sqlite_list_value_t values; +} spin_sqlite_sqlite_row_result_t; + +typedef struct { + http_trigger_string_t *ptr; + size_t len; +} http_trigger_list_string_t; + +typedef struct { + spin_sqlite_sqlite_row_result_t *ptr; + size_t len; +} spin_sqlite_sqlite_list_row_result_t; + +// A result of a query +typedef struct spin_sqlite_sqlite_query_result_t { + // The names of the columns retrieved in the query + http_trigger_list_string_t columns; + // the row results each containing the values for all the columns for a given row + spin_sqlite_sqlite_list_row_result_t rows; +} spin_sqlite_sqlite_query_result_t; + +typedef struct { + bool is_err; + union { + spin_sqlite_sqlite_own_connection_t ok; + spin_sqlite_sqlite_error_t err; + } val; +} spin_sqlite_sqlite_result_own_connection_error_t; + +typedef struct { + bool is_err; + union { + spin_sqlite_sqlite_query_result_t ok; + spin_sqlite_sqlite_error_t err; + } val; +} spin_sqlite_sqlite_result_query_result_error_t; + +// An error type that encapsulates the different errors that can occur fetching configuration values. +typedef struct wasi_config_store_error_t { + uint8_t tag; + union { + http_trigger_string_t upstream; + http_trigger_string_t io; + } val; +} wasi_config_store_error_t; + +// 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. +#define WASI_CONFIG_STORE_ERROR_UPSTREAM 0 +// 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. +#define WASI_CONFIG_STORE_ERROR_IO 1 + +typedef struct { + bool is_err; + union { + http_trigger_option_string_t ok; + wasi_config_store_error_t err; + } val; +} wasi_config_store_result_option_string_error_t; + +typedef struct { + bool is_err; + union { + http_trigger_list_tuple2_string_string_t ok; + wasi_config_store_error_t err; + } val; +} wasi_config_store_result_list_tuple2_string_string_error_t; + +typedef struct wasi_io_0_2_0_poll_own_pollable_t { + int32_t __handle; +} wasi_io_0_2_0_poll_own_pollable_t; + +typedef struct wasi_io_0_2_0_poll_borrow_pollable_t { + int32_t __handle; +} wasi_io_0_2_0_poll_borrow_pollable_t; + +typedef struct { + wasi_io_0_2_0_poll_borrow_pollable_t *ptr; + size_t len; +} wasi_io_0_2_0_poll_list_borrow_pollable_t; + +typedef struct { + uint32_t *ptr; + size_t len; +} http_trigger_list_u32_t; + +// An instant in time, in nanoseconds. An instant is relative to an +// unspecified initial value, and can only be compared to instances from +// the same monotonic-clock. +typedef uint64_t wasi_clocks_0_2_0_monotonic_clock_instant_t; + +// A duration of time, in nanoseconds. +typedef uint64_t wasi_clocks_0_2_0_monotonic_clock_duration_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_clocks_0_2_0_monotonic_clock_own_pollable_t; + +typedef struct wasi_io_0_2_0_error_own_error_t { + int32_t __handle; +} wasi_io_0_2_0_error_own_error_t; + +typedef struct wasi_io_0_2_0_error_borrow_error_t { + int32_t __handle; +} wasi_io_0_2_0_error_borrow_error_t; + +typedef wasi_io_0_2_0_error_own_error_t wasi_io_0_2_0_streams_own_error_t; + +// An error for input-stream and output-stream operations. +typedef struct wasi_io_0_2_0_streams_stream_error_t { + uint8_t tag; + union { + wasi_io_0_2_0_streams_own_error_t last_operation_failed; + } val; +} wasi_io_0_2_0_streams_stream_error_t; + +// The last operation (a write or flush) failed before completion. +// +// More information is available in the `error` payload. +#define WASI_IO_0_2_0_STREAMS_STREAM_ERROR_LAST_OPERATION_FAILED 0 +// The stream is closed: no more input will be accepted by the +// stream. A closed output-stream will return this error on all +// future operations. +#define WASI_IO_0_2_0_STREAMS_STREAM_ERROR_CLOSED 1 + +typedef struct wasi_io_0_2_0_streams_own_input_stream_t { + int32_t __handle; +} wasi_io_0_2_0_streams_own_input_stream_t; + +typedef struct wasi_io_0_2_0_streams_borrow_input_stream_t { + int32_t __handle; +} wasi_io_0_2_0_streams_borrow_input_stream_t; + +typedef struct wasi_io_0_2_0_streams_own_output_stream_t { + int32_t __handle; +} wasi_io_0_2_0_streams_own_output_stream_t; + +typedef struct wasi_io_0_2_0_streams_borrow_output_stream_t { + int32_t __handle; +} wasi_io_0_2_0_streams_borrow_output_stream_t; + +typedef struct { + bool is_err; + union { + http_trigger_list_u8_t ok; + wasi_io_0_2_0_streams_stream_error_t err; + } val; +} wasi_io_0_2_0_streams_result_list_u8_stream_error_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + wasi_io_0_2_0_streams_stream_error_t err; + } val; +} wasi_io_0_2_0_streams_result_u64_stream_error_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_io_0_2_0_streams_own_pollable_t; + +typedef struct { + bool is_err; + union { + wasi_io_0_2_0_streams_stream_error_t err; + } val; +} wasi_io_0_2_0_streams_result_void_stream_error_t; + +typedef wasi_clocks_0_2_0_monotonic_clock_duration_t wasi_http_0_2_0_types_duration_t; + +// This type corresponds to HTTP standard Methods. +typedef struct wasi_http_0_2_0_types_method_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} wasi_http_0_2_0_types_method_t; + +#define WASI_HTTP_0_2_0_TYPES_METHOD_GET 0 +#define WASI_HTTP_0_2_0_TYPES_METHOD_HEAD 1 +#define WASI_HTTP_0_2_0_TYPES_METHOD_POST 2 +#define WASI_HTTP_0_2_0_TYPES_METHOD_PUT 3 +#define WASI_HTTP_0_2_0_TYPES_METHOD_DELETE 4 +#define WASI_HTTP_0_2_0_TYPES_METHOD_CONNECT 5 +#define WASI_HTTP_0_2_0_TYPES_METHOD_OPTIONS 6 +#define WASI_HTTP_0_2_0_TYPES_METHOD_TRACE 7 +#define WASI_HTTP_0_2_0_TYPES_METHOD_PATCH 8 +#define WASI_HTTP_0_2_0_TYPES_METHOD_OTHER 9 + +// This type corresponds to HTTP standard Related Schemes. +typedef struct wasi_http_0_2_0_types_scheme_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} wasi_http_0_2_0_types_scheme_t; + +#define WASI_HTTP_0_2_0_TYPES_SCHEME_HTTP 0 +#define WASI_HTTP_0_2_0_TYPES_SCHEME_HTTPS 1 +#define WASI_HTTP_0_2_0_TYPES_SCHEME_OTHER 2 + +typedef struct { + bool is_some; + uint16_t val; +} http_trigger_option_u16_t; + +// Defines the case payload type for `DNS-error` above: +typedef struct wasi_http_0_2_0_types_dns_error_payload_t { + http_trigger_option_string_t rcode; + http_trigger_option_u16_t info_code; +} wasi_http_0_2_0_types_dns_error_payload_t; + +typedef struct { + bool is_some; + uint8_t val; +} http_trigger_option_u8_t; + +// Defines the case payload type for `TLS-alert-received` above: +typedef struct wasi_http_0_2_0_types_tls_alert_received_payload_t { + http_trigger_option_u8_t alert_id; + http_trigger_option_string_t alert_message; +} wasi_http_0_2_0_types_tls_alert_received_payload_t; + +typedef struct { + bool is_some; + uint32_t val; +} http_trigger_option_u32_t; + +// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: +typedef struct wasi_http_0_2_0_types_field_size_payload_t { + http_trigger_option_string_t field_name; + http_trigger_option_u32_t field_size; +} wasi_http_0_2_0_types_field_size_payload_t; + +typedef struct { + bool is_some; + uint64_t val; +} http_trigger_option_u64_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_field_size_payload_t val; +} wasi_http_0_2_0_types_option_field_size_payload_t; + +// These cases are inspired by the IANA HTTP Proxy Error Types: +// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types +typedef struct wasi_http_0_2_0_types_error_code_t { + uint8_t tag; + union { + wasi_http_0_2_0_types_dns_error_payload_t dns_error; + wasi_http_0_2_0_types_tls_alert_received_payload_t tls_alert_received; + http_trigger_option_u64_t http_request_body_size; + http_trigger_option_u32_t http_request_header_section_size; + wasi_http_0_2_0_types_option_field_size_payload_t http_request_header_size; + http_trigger_option_u32_t http_request_trailer_section_size; + wasi_http_0_2_0_types_field_size_payload_t http_request_trailer_size; + http_trigger_option_u32_t http_response_header_section_size; + wasi_http_0_2_0_types_field_size_payload_t http_response_header_size; + http_trigger_option_u64_t http_response_body_size; + http_trigger_option_u32_t http_response_trailer_section_size; + wasi_http_0_2_0_types_field_size_payload_t http_response_trailer_size; + http_trigger_option_string_t http_response_transfer_coding; + http_trigger_option_string_t http_response_content_coding; + http_trigger_option_string_t internal_error; + } val; +} wasi_http_0_2_0_types_error_code_t; + +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DNS_TIMEOUT 0 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DNS_ERROR 1 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DESTINATION_NOT_FOUND 2 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DESTINATION_UNAVAILABLE 3 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DESTINATION_IP_PROHIBITED 4 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_DESTINATION_IP_UNROUTABLE 5 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_REFUSED 6 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_TERMINATED 7 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_TIMEOUT 8 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_READ_TIMEOUT 9 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_WRITE_TIMEOUT 10 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONNECTION_LIMIT_REACHED 11 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_TLS_PROTOCOL_ERROR 12 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_TLS_CERTIFICATE_ERROR 13 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_TLS_ALERT_RECEIVED 14 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_DENIED 15 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_LENGTH_REQUIRED 16 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_BODY_SIZE 17 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_METHOD_INVALID 18 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_URI_INVALID 19 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_URI_TOO_LONG 20 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_HEADER_SECTION_SIZE 21 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_HEADER_SIZE 22 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_TRAILER_SECTION_SIZE 23 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_REQUEST_TRAILER_SIZE 24 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_INCOMPLETE 25 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_HEADER_SECTION_SIZE 26 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_HEADER_SIZE 27 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_BODY_SIZE 28 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_TRAILER_SECTION_SIZE 29 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_TRAILER_SIZE 30 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_TRANSFER_CODING 31 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_CONTENT_CODING 32 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_RESPONSE_TIMEOUT 33 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_UPGRADE_FAILED 34 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_HTTP_PROTOCOL_ERROR 35 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_LOOP_DETECTED 36 +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_CONFIGURATION_ERROR 37 +// This is a catch-all error for anything that doesn't fit cleanly into a +// more specific case. It also includes an optional string for an +// unstructured description of the error. Users should not depend on the +// string for diagnosing errors, as it's not required to be consistent +// between implementations. +#define WASI_HTTP_0_2_0_TYPES_ERROR_CODE_INTERNAL_ERROR 38 + +// This type enumerates the different kinds of errors that may occur when +// setting or appending to a `fields` resource. +typedef struct wasi_http_0_2_0_types_header_error_t { + uint8_t tag; +} wasi_http_0_2_0_types_header_error_t; + +// This error indicates that a `field-key` or `field-value` was +// syntactically invalid when used with an operation that sets headers in a +// `fields`. +#define WASI_HTTP_0_2_0_TYPES_HEADER_ERROR_INVALID_SYNTAX 0 +// This error indicates that a forbidden `field-key` was used when trying +// to set a header in a `fields`. +#define WASI_HTTP_0_2_0_TYPES_HEADER_ERROR_FORBIDDEN 1 +// This error indicates that the operation on the `fields` was not +// permitted because the fields are immutable. +#define WASI_HTTP_0_2_0_TYPES_HEADER_ERROR_IMMUTABLE 2 + +// Field keys are always strings. +typedef http_trigger_string_t wasi_http_0_2_0_types_field_key_t; + +// Field values should always be ASCII strings. However, in +// reality, HTTP implementations often have to interpret malformed values, +// so they are provided as a list of bytes. +typedef struct wasi_http_0_2_0_types_field_value_t { + uint8_t *ptr; + size_t len; +} wasi_http_0_2_0_types_field_value_t; + +typedef struct wasi_http_0_2_0_types_own_fields_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_fields_t; + +typedef struct wasi_http_0_2_0_types_borrow_fields_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_fields_t; + +typedef struct wasi_http_0_2_0_types_own_incoming_request_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_incoming_request_t; + +typedef struct wasi_http_0_2_0_types_borrow_incoming_request_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_incoming_request_t; + +typedef struct wasi_http_0_2_0_types_own_outgoing_request_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_outgoing_request_t; + +typedef struct wasi_http_0_2_0_types_borrow_outgoing_request_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_outgoing_request_t; + +typedef struct wasi_http_0_2_0_types_own_request_options_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_request_options_t; + +typedef struct wasi_http_0_2_0_types_borrow_request_options_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_request_options_t; + +typedef struct wasi_http_0_2_0_types_own_response_outparam_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_response_outparam_t; + +typedef struct wasi_http_0_2_0_types_borrow_response_outparam_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_response_outparam_t; + +// This type corresponds to the HTTP standard Status Code. +typedef uint16_t wasi_http_0_2_0_types_status_code_t; + +typedef struct wasi_http_0_2_0_types_own_incoming_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_incoming_response_t; + +typedef struct wasi_http_0_2_0_types_borrow_incoming_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_incoming_response_t; + +typedef struct wasi_http_0_2_0_types_own_incoming_body_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_incoming_body_t; + +typedef struct wasi_http_0_2_0_types_borrow_incoming_body_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_incoming_body_t; + +typedef struct wasi_http_0_2_0_types_own_future_trailers_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_future_trailers_t; + +typedef struct wasi_http_0_2_0_types_borrow_future_trailers_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_future_trailers_t; + +typedef struct wasi_http_0_2_0_types_own_outgoing_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_outgoing_response_t; + +typedef struct wasi_http_0_2_0_types_borrow_outgoing_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_outgoing_response_t; + +typedef struct wasi_http_0_2_0_types_own_outgoing_body_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_outgoing_body_t; + +typedef struct wasi_http_0_2_0_types_borrow_outgoing_body_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_outgoing_body_t; + +typedef struct wasi_http_0_2_0_types_own_future_incoming_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_own_future_incoming_response_t; + +typedef struct wasi_http_0_2_0_types_borrow_future_incoming_response_t { + int32_t __handle; +} wasi_http_0_2_0_types_borrow_future_incoming_response_t; + +typedef wasi_io_0_2_0_error_borrow_error_t wasi_http_0_2_0_types_borrow_io_error_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_error_code_t val; +} wasi_http_0_2_0_types_option_error_code_t; + +typedef struct { + wasi_http_0_2_0_types_field_key_t f0; + wasi_http_0_2_0_types_field_value_t f1; +} http_trigger_tuple2_field_key_field_value_t; + +typedef struct { + http_trigger_tuple2_field_key_field_value_t *ptr; + size_t len; +} http_trigger_list_tuple2_field_key_field_value_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_fields_t ok; + wasi_http_0_2_0_types_header_error_t err; + } val; +} wasi_http_0_2_0_types_result_own_fields_header_error_t; + +typedef struct { + wasi_http_0_2_0_types_field_value_t *ptr; + size_t len; +} http_trigger_list_field_value_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_header_error_t err; + } val; +} wasi_http_0_2_0_types_result_void_header_error_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_scheme_t val; +} wasi_http_0_2_0_types_option_scheme_t; + +typedef wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_own_headers_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_incoming_body_t ok; + } val; +} wasi_http_0_2_0_types_result_own_incoming_body_void_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_outgoing_body_t ok; + } val; +} wasi_http_0_2_0_types_result_own_outgoing_body_void_t; + +typedef struct { + bool is_err; +} wasi_http_0_2_0_types_result_void_void_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_duration_t val; +} http_trigger_option_duration_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_outgoing_response_t ok; + wasi_http_0_2_0_types_error_code_t err; + } val; +} wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t; + +typedef wasi_io_0_2_0_streams_own_input_stream_t wasi_http_0_2_0_types_own_input_stream_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_input_stream_t ok; + } val; +} wasi_http_0_2_0_types_result_own_input_stream_void_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_http_0_2_0_types_own_pollable_t; + +typedef wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_own_trailers_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_own_trailers_t val; +} wasi_http_0_2_0_types_option_own_trailers_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_option_own_trailers_t ok; + wasi_http_0_2_0_types_error_code_t err; + } val; +} wasi_http_0_2_0_types_result_option_own_trailers_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_result_option_own_trailers_error_code_t ok; + } val; +} wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t val; +} wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_t; + +typedef wasi_io_0_2_0_streams_own_output_stream_t wasi_http_0_2_0_types_own_output_stream_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_output_stream_t ok; + } val; +} wasi_http_0_2_0_types_result_own_output_stream_void_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_error_code_t err; + } val; +} wasi_http_0_2_0_types_result_void_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_own_incoming_response_t ok; + wasi_http_0_2_0_types_error_code_t err; + } val; +} wasi_http_0_2_0_types_result_own_incoming_response_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_types_result_own_incoming_response_error_code_t ok; + } val; +} wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t val; +} wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_t; + +typedef wasi_http_0_2_0_types_error_code_t wasi_http_0_2_0_outgoing_handler_error_code_t; + +typedef wasi_http_0_2_0_types_own_outgoing_request_t wasi_http_0_2_0_outgoing_handler_own_outgoing_request_t; + +typedef wasi_http_0_2_0_types_own_request_options_t wasi_http_0_2_0_outgoing_handler_own_request_options_t; + +typedef struct { + bool is_some; + wasi_http_0_2_0_outgoing_handler_own_request_options_t val; +} wasi_http_0_2_0_outgoing_handler_option_own_request_options_t; + +typedef wasi_http_0_2_0_types_own_future_incoming_response_t wasi_http_0_2_0_outgoing_handler_own_future_incoming_response_t; + +typedef struct { + bool is_err; + union { + wasi_http_0_2_0_outgoing_handler_own_future_incoming_response_t ok; + wasi_http_0_2_0_outgoing_handler_error_code_t err; + } val; +} wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_t; + +// A Large Language Model. +typedef http_trigger_string_t fermyon_spin_2_0_0_llm_inferencing_model_t; + +// Inference request parameters +typedef struct fermyon_spin_2_0_0_llm_inferencing_params_t { + // The maximum tokens that should be inferred. + // + // Note: the backing implementation may return less tokens. + uint32_t max_tokens; + // The amount the model should avoid repeating tokens. + float repeat_penalty; + // The number of tokens the model should apply the repeat penalty to. + uint32_t repeat_penalty_last_n_token_count; + // The randomness with which the next token is selected. + float temperature; + // The number of possible next tokens the model will choose from. + uint32_t top_k; + // The probability total of next tokens the model will choose from. + float top_p; +} fermyon_spin_2_0_0_llm_inferencing_params_t; + +// The set of errors which may be raised by functions in this interface +typedef struct fermyon_spin_2_0_0_llm_error_t { + uint8_t tag; + union { + http_trigger_string_t runtime_error; + http_trigger_string_t invalid_input; + } val; +} fermyon_spin_2_0_0_llm_error_t; + +#define FERMYON_SPIN_2_0_0_LLM_ERROR_MODEL_NOT_SUPPORTED 0 +#define FERMYON_SPIN_2_0_0_LLM_ERROR_RUNTIME_ERROR 1 +#define FERMYON_SPIN_2_0_0_LLM_ERROR_INVALID_INPUT 2 + +// Usage information related to the inferencing result +typedef struct fermyon_spin_2_0_0_llm_inferencing_usage_t { + // Number of tokens in the prompt + uint32_t prompt_token_count; + // Number of tokens generated by the inferencing operation + uint32_t generated_token_count; +} fermyon_spin_2_0_0_llm_inferencing_usage_t; + +// An inferencing result +typedef struct fermyon_spin_2_0_0_llm_inferencing_result_t { + // The text generated by the model + // TODO: this should be a stream + http_trigger_string_t text; + // Usage information about the inferencing request + fermyon_spin_2_0_0_llm_inferencing_usage_t usage; +} fermyon_spin_2_0_0_llm_inferencing_result_t; + +// The model used for generating embeddings +typedef http_trigger_string_t fermyon_spin_2_0_0_llm_embedding_model_t; + +// Usage related to an embeddings generation request +typedef struct fermyon_spin_2_0_0_llm_embeddings_usage_t { + // Number of tokens in the prompt + uint32_t prompt_token_count; +} fermyon_spin_2_0_0_llm_embeddings_usage_t; + +typedef struct { + float *ptr; + size_t len; +} http_trigger_list_f32_t; + +typedef struct { + http_trigger_list_f32_t *ptr; + size_t len; +} http_trigger_list_list_f32_t; + +// Result of generating embeddings +typedef struct fermyon_spin_2_0_0_llm_embeddings_result_t { + // The embeddings generated by the request + http_trigger_list_list_f32_t embeddings; + // Usage related to the embeddings generation request + fermyon_spin_2_0_0_llm_embeddings_usage_t usage; +} fermyon_spin_2_0_0_llm_embeddings_result_t; + +typedef struct { + bool is_some; + fermyon_spin_2_0_0_llm_inferencing_params_t val; +} fermyon_spin_2_0_0_llm_option_inferencing_params_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_llm_inferencing_result_t ok; + fermyon_spin_2_0_0_llm_error_t err; + } val; +} fermyon_spin_2_0_0_llm_result_inferencing_result_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_llm_embeddings_result_t ok; + fermyon_spin_2_0_0_llm_error_t err; + } val; +} fermyon_spin_2_0_0_llm_result_embeddings_result_error_t; + +// Errors related to interacting with Redis +typedef struct fermyon_spin_2_0_0_redis_error_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} fermyon_spin_2_0_0_redis_error_t; + +// An invalid address string +#define FERMYON_SPIN_2_0_0_REDIS_ERROR_INVALID_ADDRESS 0 +// There are too many open connections +#define FERMYON_SPIN_2_0_0_REDIS_ERROR_TOO_MANY_CONNECTIONS 1 +// A retrieved value was not of the correct type +#define FERMYON_SPIN_2_0_0_REDIS_ERROR_TYPE_ERROR 2 +// Some other error occurred +#define FERMYON_SPIN_2_0_0_REDIS_ERROR_OTHER 3 + +typedef struct fermyon_spin_2_0_0_redis_own_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_redis_own_connection_t; + +typedef struct fermyon_spin_2_0_0_redis_borrow_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_redis_borrow_connection_t; + +// The message payload. +typedef struct fermyon_spin_2_0_0_redis_payload_t { + uint8_t *ptr; + size_t len; +} fermyon_spin_2_0_0_redis_payload_t; + +// A parameter type for the general-purpose `execute` function. +typedef struct fermyon_spin_2_0_0_redis_redis_parameter_t { + uint8_t tag; + union { + int64_t int64; + fermyon_spin_2_0_0_redis_payload_t binary; + } val; +} fermyon_spin_2_0_0_redis_redis_parameter_t; + +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_PARAMETER_INT64 0 +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_PARAMETER_BINARY 1 + +// A return type for the general-purpose `execute` function. +typedef struct fermyon_spin_2_0_0_redis_redis_result_t { + uint8_t tag; + union { + http_trigger_string_t status; + int64_t int64; + fermyon_spin_2_0_0_redis_payload_t binary; + } val; +} fermyon_spin_2_0_0_redis_redis_result_t; + +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_RESULT_NIL 0 +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_RESULT_STATUS 1 +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_RESULT_INT64 2 +#define FERMYON_SPIN_2_0_0_REDIS_REDIS_RESULT_BINARY 3 + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_redis_own_connection_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_own_connection_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_void_error_t; + +typedef struct { + bool is_some; + fermyon_spin_2_0_0_redis_payload_t val; +} http_trigger_option_payload_t; + +typedef struct { + bool is_err; + union { + http_trigger_option_payload_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_option_payload_error_t; + +typedef struct { + bool is_err; + union { + int64_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_s64_error_t; + +typedef struct { + bool is_err; + union { + uint32_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_u32_error_t; + +typedef struct { + bool is_err; + union { + http_trigger_list_string_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_list_string_error_t; + +typedef struct { + fermyon_spin_2_0_0_redis_redis_parameter_t *ptr; + size_t len; +} fermyon_spin_2_0_0_redis_list_redis_parameter_t; + +typedef struct { + fermyon_spin_2_0_0_redis_redis_result_t *ptr; + size_t len; +} fermyon_spin_2_0_0_redis_list_redis_result_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_redis_list_redis_result_t ok; + fermyon_spin_2_0_0_redis_error_t err; + } val; +} fermyon_spin_2_0_0_redis_result_list_redis_result_error_t; + +// Errors related to interacting with Mqtt +typedef struct fermyon_spin_2_0_0_mqtt_error_t { + uint8_t tag; + union { + http_trigger_string_t connection_failed; + http_trigger_string_t other; + } val; +} fermyon_spin_2_0_0_mqtt_error_t; + +// An invalid address string +#define FERMYON_SPIN_2_0_0_MQTT_ERROR_INVALID_ADDRESS 0 +// There are too many open connections +#define FERMYON_SPIN_2_0_0_MQTT_ERROR_TOO_MANY_CONNECTIONS 1 +// Connection failure e.g. address not allowed. +#define FERMYON_SPIN_2_0_0_MQTT_ERROR_CONNECTION_FAILED 2 +// Some other error occurred +#define FERMYON_SPIN_2_0_0_MQTT_ERROR_OTHER 3 + +// QoS for publishing Mqtt messages +typedef uint8_t fermyon_spin_2_0_0_mqtt_qos_t; + +#define FERMYON_SPIN_2_0_0_MQTT_QOS_AT_MOST_ONCE 0 +#define FERMYON_SPIN_2_0_0_MQTT_QOS_AT_LEAST_ONCE 1 +#define FERMYON_SPIN_2_0_0_MQTT_QOS_EXACTLY_ONCE 2 + +typedef struct fermyon_spin_2_0_0_mqtt_own_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_mqtt_own_connection_t; + +typedef struct fermyon_spin_2_0_0_mqtt_borrow_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_mqtt_borrow_connection_t; + +// The message payload. +typedef struct fermyon_spin_2_0_0_mqtt_payload_t { + uint8_t *ptr; + size_t len; +} fermyon_spin_2_0_0_mqtt_payload_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_mqtt_own_connection_t ok; + fermyon_spin_2_0_0_mqtt_error_t err; + } val; +} fermyon_spin_2_0_0_mqtt_result_own_connection_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_mqtt_error_t err; + } val; +} fermyon_spin_2_0_0_mqtt_result_void_error_t; + +// Errors related to interacting with a database. +typedef struct fermyon_spin_2_0_0_rdbms_types_error_t { + uint8_t tag; + union { + http_trigger_string_t connection_failed; + http_trigger_string_t bad_parameter; + http_trigger_string_t query_failed; + http_trigger_string_t value_conversion_failed; + http_trigger_string_t other; + } val; +} fermyon_spin_2_0_0_rdbms_types_error_t; + +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_ERROR_CONNECTION_FAILED 0 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_ERROR_BAD_PARAMETER 1 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_ERROR_QUERY_FAILED 2 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_ERROR_VALUE_CONVERSION_FAILED 3 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_ERROR_OTHER 4 + +// Data types for a database column +typedef uint8_t fermyon_spin_2_0_0_rdbms_types_db_data_type_t; + +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_BOOLEAN 0 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_INT8 1 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_INT16 2 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_INT32 3 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_INT64 4 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_UINT8 5 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_UINT16 6 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_UINT32 7 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_UINT64 8 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_FLOATING32 9 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_FLOATING64 10 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_STR 11 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_BINARY 12 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_DATA_TYPE_OTHER 13 + +// Database values +typedef struct fermyon_spin_2_0_0_rdbms_types_db_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + uint8_t uint8; + uint16_t uint16; + uint32_t uint32; + uint64_t uint64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + } val; +} fermyon_spin_2_0_0_rdbms_types_db_value_t; + +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_BOOLEAN 0 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_INT8 1 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_INT16 2 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_INT32 3 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_INT64 4 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_UINT8 5 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_UINT16 6 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_UINT32 7 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_UINT64 8 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_FLOATING32 9 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_FLOATING64 10 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_STR 11 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_BINARY 12 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_DB_NULL 13 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_DB_VALUE_UNSUPPORTED 14 + +// Values used in parameterized queries +typedef struct fermyon_spin_2_0_0_rdbms_types_parameter_value_t { + uint8_t tag; + union { + bool boolean; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + uint8_t uint8; + uint16_t uint16; + uint32_t uint32; + uint64_t uint64; + float floating32; + double floating64; + http_trigger_string_t str; + http_trigger_list_u8_t binary; + } val; +} fermyon_spin_2_0_0_rdbms_types_parameter_value_t; + +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_BOOLEAN 0 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_INT8 1 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_INT16 2 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_INT32 3 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_INT64 4 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_UINT8 5 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_UINT16 6 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_UINT32 7 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_UINT64 8 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_FLOATING32 9 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_FLOATING64 10 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_STR 11 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_BINARY 12 +#define FERMYON_SPIN_2_0_0_RDBMS_TYPES_PARAMETER_VALUE_DB_NULL 13 + +// A database column +typedef struct fermyon_spin_2_0_0_rdbms_types_column_t { + http_trigger_string_t name; + fermyon_spin_2_0_0_rdbms_types_db_data_type_t data_type; +} fermyon_spin_2_0_0_rdbms_types_column_t; + +// A database row +typedef struct fermyon_spin_2_0_0_rdbms_types_row_t { + fermyon_spin_2_0_0_rdbms_types_db_value_t *ptr; + size_t len; +} fermyon_spin_2_0_0_rdbms_types_row_t; + +typedef struct { + fermyon_spin_2_0_0_rdbms_types_column_t *ptr; + size_t len; +} fermyon_spin_2_0_0_rdbms_types_list_column_t; + +typedef struct { + fermyon_spin_2_0_0_rdbms_types_row_t *ptr; + size_t len; +} fermyon_spin_2_0_0_rdbms_types_list_row_t; + +// A set of database rows +typedef struct fermyon_spin_2_0_0_rdbms_types_row_set_t { + fermyon_spin_2_0_0_rdbms_types_list_column_t columns; + fermyon_spin_2_0_0_rdbms_types_list_row_t rows; +} fermyon_spin_2_0_0_rdbms_types_row_set_t; + +typedef fermyon_spin_2_0_0_rdbms_types_parameter_value_t fermyon_spin_2_0_0_postgres_parameter_value_t; + +typedef fermyon_spin_2_0_0_rdbms_types_row_set_t fermyon_spin_2_0_0_postgres_row_set_t; + +typedef fermyon_spin_2_0_0_rdbms_types_error_t fermyon_spin_2_0_0_postgres_error_t; + +typedef struct fermyon_spin_2_0_0_postgres_own_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_postgres_own_connection_t; + +typedef struct fermyon_spin_2_0_0_postgres_borrow_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_postgres_borrow_connection_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_postgres_own_connection_t ok; + fermyon_spin_2_0_0_postgres_error_t err; + } val; +} fermyon_spin_2_0_0_postgres_result_own_connection_error_t; + +typedef struct { + fermyon_spin_2_0_0_postgres_parameter_value_t *ptr; + size_t len; +} fermyon_spin_2_0_0_postgres_list_parameter_value_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_postgres_row_set_t ok; + fermyon_spin_2_0_0_postgres_error_t err; + } val; +} fermyon_spin_2_0_0_postgres_result_row_set_error_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + fermyon_spin_2_0_0_postgres_error_t err; + } val; +} fermyon_spin_2_0_0_postgres_result_u64_error_t; + +typedef fermyon_spin_2_0_0_rdbms_types_parameter_value_t fermyon_spin_2_0_0_mysql_parameter_value_t; + +typedef fermyon_spin_2_0_0_rdbms_types_row_set_t fermyon_spin_2_0_0_mysql_row_set_t; + +typedef fermyon_spin_2_0_0_rdbms_types_error_t fermyon_spin_2_0_0_mysql_error_t; + +typedef struct fermyon_spin_2_0_0_mysql_own_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_mysql_own_connection_t; + +typedef struct fermyon_spin_2_0_0_mysql_borrow_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_mysql_borrow_connection_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_mysql_own_connection_t ok; + fermyon_spin_2_0_0_mysql_error_t err; + } val; +} fermyon_spin_2_0_0_mysql_result_own_connection_error_t; + +typedef struct { + fermyon_spin_2_0_0_mysql_parameter_value_t *ptr; + size_t len; +} fermyon_spin_2_0_0_mysql_list_parameter_value_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_mysql_row_set_t ok; + fermyon_spin_2_0_0_mysql_error_t err; + } val; +} fermyon_spin_2_0_0_mysql_result_row_set_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_mysql_error_t err; + } val; +} fermyon_spin_2_0_0_mysql_result_void_error_t; + +typedef struct fermyon_spin_2_0_0_sqlite_own_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_sqlite_own_connection_t; + +typedef struct fermyon_spin_2_0_0_sqlite_borrow_connection_t { + int32_t __handle; +} fermyon_spin_2_0_0_sqlite_borrow_connection_t; + +// The set of errors which may be raised by functions in this interface +typedef struct fermyon_spin_2_0_0_sqlite_error_t { + uint8_t tag; + union { + http_trigger_string_t io; + } val; +} fermyon_spin_2_0_0_sqlite_error_t; + +// The host does not recognize the database name requested. +#define FERMYON_SPIN_2_0_0_SQLITE_ERROR_NO_SUCH_DATABASE 0 +// The requesting component does not have access to the specified database (which may or may not exist). +#define FERMYON_SPIN_2_0_0_SQLITE_ERROR_ACCESS_DENIED 1 +// The provided connection is not valid +#define FERMYON_SPIN_2_0_0_SQLITE_ERROR_INVALID_CONNECTION 2 +// The database has reached its capacity +#define FERMYON_SPIN_2_0_0_SQLITE_ERROR_DATABASE_FULL 3 +// Some implementation-specific error has occurred (e.g. I/O) +#define FERMYON_SPIN_2_0_0_SQLITE_ERROR_IO 4 + +// A single column's result from a database query +typedef struct fermyon_spin_2_0_0_sqlite_value_t { + uint8_t tag; + union { + int64_t integer; + double real; + http_trigger_string_t text; + http_trigger_list_u8_t blob; + } val; +} fermyon_spin_2_0_0_sqlite_value_t; + +#define FERMYON_SPIN_2_0_0_SQLITE_VALUE_INTEGER 0 +#define FERMYON_SPIN_2_0_0_SQLITE_VALUE_REAL 1 +#define FERMYON_SPIN_2_0_0_SQLITE_VALUE_TEXT 2 +#define FERMYON_SPIN_2_0_0_SQLITE_VALUE_BLOB 3 +#define FERMYON_SPIN_2_0_0_SQLITE_VALUE_NULL 4 + +typedef struct { + fermyon_spin_2_0_0_sqlite_value_t *ptr; + size_t len; +} fermyon_spin_2_0_0_sqlite_list_value_t; + +// A set of values for each of the columns in a query-result +typedef struct fermyon_spin_2_0_0_sqlite_row_result_t { + fermyon_spin_2_0_0_sqlite_list_value_t values; +} fermyon_spin_2_0_0_sqlite_row_result_t; + +typedef struct { + fermyon_spin_2_0_0_sqlite_row_result_t *ptr; + size_t len; +} fermyon_spin_2_0_0_sqlite_list_row_result_t; + +// A result of a query +typedef struct fermyon_spin_2_0_0_sqlite_query_result_t { + // The names of the columns retrieved in the query + http_trigger_list_string_t columns; + // the row results each containing the values for all the columns for a given row + fermyon_spin_2_0_0_sqlite_list_row_result_t rows; +} fermyon_spin_2_0_0_sqlite_query_result_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_sqlite_own_connection_t ok; + fermyon_spin_2_0_0_sqlite_error_t err; + } val; +} fermyon_spin_2_0_0_sqlite_result_own_connection_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_sqlite_query_result_t ok; + fermyon_spin_2_0_0_sqlite_error_t err; + } val; +} fermyon_spin_2_0_0_sqlite_result_query_result_error_t; + +typedef struct fermyon_spin_2_0_0_key_value_own_store_t { + int32_t __handle; +} fermyon_spin_2_0_0_key_value_own_store_t; + +typedef struct fermyon_spin_2_0_0_key_value_borrow_store_t { + int32_t __handle; +} fermyon_spin_2_0_0_key_value_borrow_store_t; + +// The set of errors which may be raised by functions in this interface +typedef struct fermyon_spin_2_0_0_key_value_error_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} fermyon_spin_2_0_0_key_value_error_t; + +// Too many stores have been opened simultaneously. Closing one or more +// stores prior to retrying may address this. +#define FERMYON_SPIN_2_0_0_KEY_VALUE_ERROR_STORE_TABLE_FULL 0 +// The host does not recognize the store label requested. +#define FERMYON_SPIN_2_0_0_KEY_VALUE_ERROR_NO_SUCH_STORE 1 +// The requesting component does not have access to the specified store +// (which may or may not exist). +#define FERMYON_SPIN_2_0_0_KEY_VALUE_ERROR_ACCESS_DENIED 2 +// Some implementation-specific error has occurred (e.g. I/O) +#define FERMYON_SPIN_2_0_0_KEY_VALUE_ERROR_OTHER 3 + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_key_value_own_store_t ok; + fermyon_spin_2_0_0_key_value_error_t err; + } val; +} fermyon_spin_2_0_0_key_value_result_own_store_error_t; + +typedef struct { + bool is_some; + http_trigger_list_u8_t val; +} http_trigger_option_list_u8_t; + +typedef struct { + bool is_err; + union { + http_trigger_option_list_u8_t ok; + fermyon_spin_2_0_0_key_value_error_t err; + } val; +} fermyon_spin_2_0_0_key_value_result_option_list_u8_error_t; + +typedef struct { + bool is_err; + union { + fermyon_spin_2_0_0_key_value_error_t err; + } val; +} fermyon_spin_2_0_0_key_value_result_void_error_t; + +typedef struct { + bool is_err; + union { + bool ok; + fermyon_spin_2_0_0_key_value_error_t err; + } val; +} fermyon_spin_2_0_0_key_value_result_bool_error_t; + +typedef struct { + bool is_err; + union { + http_trigger_list_string_t ok; + fermyon_spin_2_0_0_key_value_error_t err; + } val; +} fermyon_spin_2_0_0_key_value_result_list_string_error_t; + +// The set of errors which may be raised by functions in this interface. +typedef struct fermyon_spin_2_0_0_variables_error_t { + uint8_t tag; + union { + http_trigger_string_t invalid_name; + http_trigger_string_t undefined; + http_trigger_string_t provider; + http_trigger_string_t other; + } val; +} fermyon_spin_2_0_0_variables_error_t; + +// The provided variable name is invalid. +#define FERMYON_SPIN_2_0_0_VARIABLES_ERROR_INVALID_NAME 0 +// The provided variable is undefined. +#define FERMYON_SPIN_2_0_0_VARIABLES_ERROR_UNDEFINED 1 +// A variables provider specific error has occurred. +#define FERMYON_SPIN_2_0_0_VARIABLES_ERROR_PROVIDER 2 +// Some implementation-specific error has occurred. +#define FERMYON_SPIN_2_0_0_VARIABLES_ERROR_OTHER 3 + +typedef struct { + bool is_err; + union { + http_trigger_string_t ok; + fermyon_spin_2_0_0_variables_error_t err; + } val; +} fermyon_spin_2_0_0_variables_result_string_error_t; + +typedef struct { + bool is_err; +} wasi_cli_0_2_0_exit_result_void_void_t; + +typedef wasi_io_0_2_0_streams_own_input_stream_t wasi_cli_0_2_0_stdin_own_input_stream_t; + +typedef wasi_io_0_2_0_streams_own_output_stream_t wasi_cli_0_2_0_stdout_own_output_stream_t; + +typedef wasi_io_0_2_0_streams_own_output_stream_t wasi_cli_0_2_0_stderr_own_output_stream_t; + +typedef struct wasi_cli_0_2_0_terminal_input_own_terminal_input_t { + int32_t __handle; +} wasi_cli_0_2_0_terminal_input_own_terminal_input_t; + +typedef struct wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t { + int32_t __handle; +} wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t; + +typedef struct wasi_cli_0_2_0_terminal_output_own_terminal_output_t { + int32_t __handle; +} wasi_cli_0_2_0_terminal_output_own_terminal_output_t; + +typedef struct wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t { + int32_t __handle; +} wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t; + +typedef wasi_cli_0_2_0_terminal_input_own_terminal_input_t wasi_cli_0_2_0_terminal_stdin_own_terminal_input_t; + +typedef struct { + bool is_some; + wasi_cli_0_2_0_terminal_stdin_own_terminal_input_t val; +} wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_t; + +typedef wasi_cli_0_2_0_terminal_output_own_terminal_output_t wasi_cli_0_2_0_terminal_stdout_own_terminal_output_t; + +typedef struct { + bool is_some; + wasi_cli_0_2_0_terminal_stdout_own_terminal_output_t val; +} wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_t; + +typedef wasi_cli_0_2_0_terminal_output_own_terminal_output_t wasi_cli_0_2_0_terminal_stderr_own_terminal_output_t; + +typedef struct { + bool is_some; + wasi_cli_0_2_0_terminal_stderr_own_terminal_output_t val; +} wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_t; + +// A time and date in seconds plus nanoseconds. +typedef struct wasi_clocks_0_2_0_wall_clock_datetime_t { + uint64_t seconds; + uint32_t nanoseconds; +} wasi_clocks_0_2_0_wall_clock_datetime_t; + +typedef wasi_clocks_0_2_0_wall_clock_datetime_t wasi_filesystem_0_2_0_types_datetime_t; + +// File size or length of a region within a file. +typedef uint64_t wasi_filesystem_0_2_0_types_filesize_t; + +// The type of a filesystem object referenced by a descriptor. +// +// Note: This was called `filetype` in earlier versions of WASI. +typedef uint8_t wasi_filesystem_0_2_0_types_descriptor_type_t; + +// The type of the descriptor or file is unknown or is different from +// any of the other types specified. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_UNKNOWN 0 +// The descriptor refers to a block device inode. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_BLOCK_DEVICE 1 +// The descriptor refers to a character device inode. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_CHARACTER_DEVICE 2 +// The descriptor refers to a directory inode. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_DIRECTORY 3 +// The descriptor refers to a named pipe. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_FIFO 4 +// The file refers to a symbolic link inode. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_SYMBOLIC_LINK 5 +// The descriptor refers to a regular file inode. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_REGULAR_FILE 6 +// The descriptor refers to a socket. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_TYPE_SOCKET 7 + +// Descriptor flags. +// +// Note: This was called `fdflags` in earlier versions of WASI. +typedef uint8_t wasi_filesystem_0_2_0_types_descriptor_flags_t; + +// Read mode: Data can be read. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_READ (1 << 0) +// Write mode: Data can be written to. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_WRITE (1 << 1) +// Request that writes be performed according to synchronized I/O file +// integrity completion. The data stored in the file and the file's +// metadata are synchronized. This is similar to `O_SYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_FILE_INTEGRITY_SYNC (1 << 2) +// Request that writes be performed according to synchronized I/O data +// integrity completion. Only the data stored in the file is +// synchronized. This is similar to `O_DSYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_DATA_INTEGRITY_SYNC (1 << 3) +// Requests that reads be performed at the same level of integrety +// requested for writes. This is similar to `O_RSYNC` in POSIX. +// +// The precise semantics of this operation have not yet been defined for +// WASI. At this time, it should be interpreted as a request, and not a +// requirement. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_REQUESTED_WRITE_SYNC (1 << 4) +// Mutating directories mode: Directory contents may be mutated. +// +// When this flag is unset on a descriptor, operations using the +// descriptor which would create, rename, delete, modify the data or +// metadata of filesystem objects, or obtain another handle which +// would permit any of those, shall fail with `error-code::read-only` if +// they would otherwise succeed. +// +// This may only be set on directories. +#define WASI_FILESYSTEM_0_2_0_TYPES_DESCRIPTOR_FLAGS_MUTATE_DIRECTORY (1 << 5) + +// Flags determining the method of how paths are resolved. +typedef uint8_t wasi_filesystem_0_2_0_types_path_flags_t; + +// As long as the resolved path corresponds to a symbolic link, it is +// expanded. +#define WASI_FILESYSTEM_0_2_0_TYPES_PATH_FLAGS_SYMLINK_FOLLOW (1 << 0) + +// Open flags used by `open-at`. +typedef uint8_t wasi_filesystem_0_2_0_types_open_flags_t; + +// Create file if it does not exist, similar to `O_CREAT` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_OPEN_FLAGS_CREATE (1 << 0) +// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_OPEN_FLAGS_DIRECTORY (1 << 1) +// Fail if file already exists, similar to `O_EXCL` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_OPEN_FLAGS_EXCLUSIVE (1 << 2) +// Truncate file to size 0, similar to `O_TRUNC` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_OPEN_FLAGS_TRUNCATE (1 << 3) + +// Number of hard links to an inode. +typedef uint64_t wasi_filesystem_0_2_0_types_link_count_t; + +typedef struct { + bool is_some; + wasi_filesystem_0_2_0_types_datetime_t val; +} wasi_filesystem_0_2_0_types_option_datetime_t; + +// File attributes. +// +// Note: This was called `filestat` in earlier versions of WASI. +typedef struct wasi_filesystem_0_2_0_types_descriptor_stat_t { + // File type. + wasi_filesystem_0_2_0_types_descriptor_type_t type; + // Number of hard links to the file. + wasi_filesystem_0_2_0_types_link_count_t link_count; + // For regular files, the file size in bytes. For symbolic links, the + // length in bytes of the pathname contained in the symbolic link. + wasi_filesystem_0_2_0_types_filesize_t size; + // Last data access timestamp. + // + // If the `option` is none, the platform doesn't maintain an access + // timestamp for this file. + wasi_filesystem_0_2_0_types_option_datetime_t data_access_timestamp; + // Last data modification timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // modification timestamp for this file. + wasi_filesystem_0_2_0_types_option_datetime_t data_modification_timestamp; + // Last file status-change timestamp. + // + // If the `option` is none, the platform doesn't maintain a + // status-change timestamp for this file. + wasi_filesystem_0_2_0_types_option_datetime_t status_change_timestamp; +} wasi_filesystem_0_2_0_types_descriptor_stat_t; + +// When setting a timestamp, this gives the value to set it to. +typedef struct wasi_filesystem_0_2_0_types_new_timestamp_t { + uint8_t tag; + union { + wasi_filesystem_0_2_0_types_datetime_t timestamp; + } val; +} wasi_filesystem_0_2_0_types_new_timestamp_t; + +// Leave the timestamp set to its previous value. +#define WASI_FILESYSTEM_0_2_0_TYPES_NEW_TIMESTAMP_NO_CHANGE 0 +// Set the timestamp to the current time of the system clock associated +// with the filesystem. +#define WASI_FILESYSTEM_0_2_0_TYPES_NEW_TIMESTAMP_NOW 1 +// Set the timestamp to the given value. +#define WASI_FILESYSTEM_0_2_0_TYPES_NEW_TIMESTAMP_TIMESTAMP 2 + +// A directory entry. +typedef struct wasi_filesystem_0_2_0_types_directory_entry_t { + // The type of the file referred to by this directory entry. + wasi_filesystem_0_2_0_types_descriptor_type_t type; + // The name of the object. + http_trigger_string_t name; +} wasi_filesystem_0_2_0_types_directory_entry_t; + +// Error codes returned by functions, similar to `errno` in POSIX. +// Not all of these error codes are returned by the functions provided by this +// API; some are used in higher-level library layers, and others are provided +// merely for alignment with POSIX. +typedef uint8_t wasi_filesystem_0_2_0_types_error_code_t; + +// Permission denied, similar to `EACCES` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_ACCESS 0 +// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_WOULD_BLOCK 1 +// Connection already in progress, similar to `EALREADY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_ALREADY 2 +// Bad descriptor, similar to `EBADF` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_BAD_DESCRIPTOR 3 +// Device or resource busy, similar to `EBUSY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_BUSY 4 +// Resource deadlock would occur, similar to `EDEADLK` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_DEADLOCK 5 +// Storage quota exceeded, similar to `EDQUOT` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_QUOTA 6 +// File exists, similar to `EEXIST` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_EXIST 7 +// File too large, similar to `EFBIG` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_FILE_TOO_LARGE 8 +// Illegal byte sequence, similar to `EILSEQ` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 9 +// Operation in progress, similar to `EINPROGRESS` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_IN_PROGRESS 10 +// Interrupted function, similar to `EINTR` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_INTERRUPTED 11 +// Invalid argument, similar to `EINVAL` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_INVALID 12 +// I/O error, similar to `EIO` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_IO 13 +// Is a directory, similar to `EISDIR` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_IS_DIRECTORY 14 +// Too many levels of symbolic links, similar to `ELOOP` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_LOOP 15 +// Too many links, similar to `EMLINK` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_TOO_MANY_LINKS 16 +// Message too large, similar to `EMSGSIZE` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_MESSAGE_SIZE 17 +// Filename too long, similar to `ENAMETOOLONG` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NAME_TOO_LONG 18 +// No such device, similar to `ENODEV` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NO_DEVICE 19 +// No such file or directory, similar to `ENOENT` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NO_ENTRY 20 +// No locks available, similar to `ENOLCK` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NO_LOCK 21 +// Not enough space, similar to `ENOMEM` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_INSUFFICIENT_MEMORY 22 +// No space left on device, similar to `ENOSPC` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_INSUFFICIENT_SPACE 23 +// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NOT_DIRECTORY 24 +// Directory not empty, similar to `ENOTEMPTY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NOT_EMPTY 25 +// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NOT_RECOVERABLE 26 +// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_UNSUPPORTED 27 +// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NO_TTY 28 +// No such device or address, similar to `ENXIO` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NO_SUCH_DEVICE 29 +// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_OVERFLOW 30 +// Operation not permitted, similar to `EPERM` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_NOT_PERMITTED 31 +// Broken pipe, similar to `EPIPE` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_PIPE 32 +// Read-only file system, similar to `EROFS` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_READ_ONLY 33 +// Invalid seek, similar to `ESPIPE` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_INVALID_SEEK 34 +// Text file busy, similar to `ETXTBSY` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_TEXT_FILE_BUSY 35 +// Cross-device link, similar to `EXDEV` in POSIX. +#define WASI_FILESYSTEM_0_2_0_TYPES_ERROR_CODE_CROSS_DEVICE 36 + +// File or memory access pattern advisory information. +typedef uint8_t wasi_filesystem_0_2_0_types_advice_t; + +// The application has no advice to give on its behavior with respect +// to the specified data. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_NORMAL 0 +// The application expects to access the specified data sequentially +// from lower offsets to higher offsets. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_SEQUENTIAL 1 +// The application expects to access the specified data in a random +// order. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_RANDOM 2 +// The application expects to access the specified data in the near +// future. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_WILL_NEED 3 +// The application expects that it will not access the specified data +// in the near future. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_DONT_NEED 4 +// The application expects to access the specified data once and then +// not reuse it thereafter. +#define WASI_FILESYSTEM_0_2_0_TYPES_ADVICE_NO_REUSE 5 + +// A 128-bit hash value, split into parts because wasm doesn't have a +// 128-bit integer type. +typedef struct wasi_filesystem_0_2_0_types_metadata_hash_value_t { + // 64 bits of a 128-bit hash value. + uint64_t lower; + // Another 64 bits of a 128-bit hash value. + uint64_t upper; +} wasi_filesystem_0_2_0_types_metadata_hash_value_t; + +typedef struct wasi_filesystem_0_2_0_types_own_descriptor_t { + int32_t __handle; +} wasi_filesystem_0_2_0_types_own_descriptor_t; + +typedef struct wasi_filesystem_0_2_0_types_borrow_descriptor_t { + int32_t __handle; +} wasi_filesystem_0_2_0_types_borrow_descriptor_t; + +typedef struct wasi_filesystem_0_2_0_types_own_directory_entry_stream_t { + int32_t __handle; +} wasi_filesystem_0_2_0_types_own_directory_entry_stream_t; + +typedef struct wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t { + int32_t __handle; +} wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t; + +typedef wasi_io_0_2_0_streams_own_input_stream_t wasi_filesystem_0_2_0_types_own_input_stream_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_own_input_stream_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_t; + +typedef wasi_io_0_2_0_streams_own_output_stream_t wasi_filesystem_0_2_0_types_own_output_stream_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_own_output_stream_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_void_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_descriptor_flags_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_descriptor_type_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_t; + +typedef struct { + http_trigger_list_u8_t f0; + bool f1; +} http_trigger_tuple2_list_u8_bool_t; + +typedef struct { + bool is_err; + union { + http_trigger_tuple2_list_u8_bool_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_filesize_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_filesize_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_own_directory_entry_stream_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_descriptor_stat_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_own_descriptor_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_t; + +typedef struct { + bool is_err; + union { + http_trigger_string_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_string_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_metadata_hash_value_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_t; + +typedef struct { + bool is_some; + wasi_filesystem_0_2_0_types_directory_entry_t val; +} wasi_filesystem_0_2_0_types_option_directory_entry_t; + +typedef struct { + bool is_err; + union { + wasi_filesystem_0_2_0_types_option_directory_entry_t ok; + wasi_filesystem_0_2_0_types_error_code_t err; + } val; +} wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_t; + +typedef wasi_io_0_2_0_error_borrow_error_t wasi_filesystem_0_2_0_types_borrow_error_t; + +typedef struct { + bool is_some; + wasi_filesystem_0_2_0_types_error_code_t val; +} wasi_filesystem_0_2_0_types_option_error_code_t; + +typedef wasi_filesystem_0_2_0_types_own_descriptor_t wasi_filesystem_0_2_0_preopens_own_descriptor_t; + +typedef struct { + wasi_filesystem_0_2_0_preopens_own_descriptor_t f0; + http_trigger_string_t f1; +} wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t; + +typedef struct { + wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t *ptr; + size_t len; +} wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t; + +typedef struct wasi_sockets_0_2_0_network_own_network_t { + int32_t __handle; +} wasi_sockets_0_2_0_network_own_network_t; + +typedef struct wasi_sockets_0_2_0_network_borrow_network_t { + int32_t __handle; +} wasi_sockets_0_2_0_network_borrow_network_t; + +// Error codes. +// +// In theory, every API can return any error code. +// In practice, API's typically only return the errors documented per API +// combined with a couple of errors that are always possible: +// - `unknown` +// - `access-denied` +// - `not-supported` +// - `out-of-memory` +// - `concurrency-conflict` +// +// See each individual API for what the POSIX equivalents are. They sometimes differ per API. +typedef uint8_t wasi_sockets_0_2_0_network_error_code_t; + +// Unknown error +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_UNKNOWN 0 +// Access denied. +// +// POSIX equivalent: EACCES, EPERM +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_ACCESS_DENIED 1 +// The operation is not supported. +// +// POSIX equivalent: EOPNOTSUPP +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_NOT_SUPPORTED 2 +// One of the arguments is invalid. +// +// POSIX equivalent: EINVAL +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_INVALID_ARGUMENT 3 +// Not enough memory to complete the operation. +// +// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_OUT_OF_MEMORY 4 +// The operation timed out before it could finish completely. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_TIMEOUT 5 +// This operation is incompatible with another asynchronous operation that is already in progress. +// +// POSIX equivalent: EALREADY +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_CONCURRENCY_CONFLICT 6 +// Trying to finish an asynchronous operation that: +// - has not been started yet, or: +// - was already finished by a previous `finish-*` call. +// +// Note: this is scheduled to be removed when `future`s are natively supported. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_NOT_IN_PROGRESS 7 +// The operation has been aborted because it could not be completed immediately. +// +// Note: this is scheduled to be removed when `future`s are natively supported. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_WOULD_BLOCK 8 +// The operation is not valid in the socket's current state. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_INVALID_STATE 9 +// A new socket resource could not be created because of a system limit. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_NEW_SOCKET_LIMIT 10 +// A bind operation failed because the provided address is not an address that the `network` can bind to. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_ADDRESS_NOT_BINDABLE 11 +// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_ADDRESS_IN_USE 12 +// The remote address is not reachable +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_REMOTE_UNREACHABLE 13 +// The TCP connection was forcefully rejected +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_CONNECTION_REFUSED 14 +// The TCP connection was reset. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_CONNECTION_RESET 15 +// A TCP connection was aborted. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_CONNECTION_ABORTED 16 +// The size of a datagram sent to a UDP socket exceeded the maximum +// supported size. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_DATAGRAM_TOO_LARGE 17 +// Name does not exist or has no suitable associated IP addresses. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_NAME_UNRESOLVABLE 18 +// A temporary failure in name resolution occurred. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_TEMPORARY_RESOLVER_FAILURE 19 +// A permanent failure in name resolution occurred. +#define WASI_SOCKETS_0_2_0_NETWORK_ERROR_CODE_PERMANENT_RESOLVER_FAILURE 20 + +typedef uint8_t wasi_sockets_0_2_0_network_ip_address_family_t; + +// Similar to `AF_INET` in POSIX. +#define WASI_SOCKETS_0_2_0_NETWORK_IP_ADDRESS_FAMILY_IPV4 0 +// Similar to `AF_INET6` in POSIX. +#define WASI_SOCKETS_0_2_0_NETWORK_IP_ADDRESS_FAMILY_IPV6 1 + +typedef struct wasi_sockets_0_2_0_network_ipv4_address_t { + uint8_t f0; + uint8_t f1; + uint8_t f2; + uint8_t f3; +} wasi_sockets_0_2_0_network_ipv4_address_t; + +typedef struct wasi_sockets_0_2_0_network_ipv6_address_t { + uint16_t f0; + uint16_t f1; + uint16_t f2; + uint16_t f3; + uint16_t f4; + uint16_t f5; + uint16_t f6; + uint16_t f7; +} wasi_sockets_0_2_0_network_ipv6_address_t; + +typedef struct wasi_sockets_0_2_0_network_ip_address_t { + uint8_t tag; + union { + wasi_sockets_0_2_0_network_ipv4_address_t ipv4; + wasi_sockets_0_2_0_network_ipv6_address_t ipv6; + } val; +} wasi_sockets_0_2_0_network_ip_address_t; + +#define WASI_SOCKETS_0_2_0_NETWORK_IP_ADDRESS_IPV4 0 +#define WASI_SOCKETS_0_2_0_NETWORK_IP_ADDRESS_IPV6 1 + +typedef struct wasi_sockets_0_2_0_network_ipv4_socket_address_t { + // sin_port + uint16_t port; + // sin_addr + wasi_sockets_0_2_0_network_ipv4_address_t address; +} wasi_sockets_0_2_0_network_ipv4_socket_address_t; + +typedef struct wasi_sockets_0_2_0_network_ipv6_socket_address_t { + // sin6_port + uint16_t port; + // sin6_flowinfo + uint32_t flow_info; + // sin6_addr + wasi_sockets_0_2_0_network_ipv6_address_t address; + // sin6_scope_id + uint32_t scope_id; +} wasi_sockets_0_2_0_network_ipv6_socket_address_t; + +typedef struct wasi_sockets_0_2_0_network_ip_socket_address_t { + uint8_t tag; + union { + wasi_sockets_0_2_0_network_ipv4_socket_address_t ipv4; + wasi_sockets_0_2_0_network_ipv6_socket_address_t ipv6; + } val; +} wasi_sockets_0_2_0_network_ip_socket_address_t; + +#define WASI_SOCKETS_0_2_0_NETWORK_IP_SOCKET_ADDRESS_IPV4 0 +#define WASI_SOCKETS_0_2_0_NETWORK_IP_SOCKET_ADDRESS_IPV6 1 + +typedef wasi_sockets_0_2_0_network_own_network_t wasi_sockets_0_2_0_instance_network_own_network_t; + +typedef wasi_sockets_0_2_0_network_error_code_t wasi_sockets_0_2_0_udp_error_code_t; + +typedef wasi_sockets_0_2_0_network_ip_socket_address_t wasi_sockets_0_2_0_udp_ip_socket_address_t; + +typedef wasi_sockets_0_2_0_network_ip_address_family_t wasi_sockets_0_2_0_udp_ip_address_family_t; + +// A received datagram. +typedef struct wasi_sockets_0_2_0_udp_incoming_datagram_t { + // The payload. + // + // Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes. + http_trigger_list_u8_t data; + // The source address. + // + // This field is guaranteed to match the remote address the stream was initialized with, if any. + // + // Equivalent to the `src_addr` out parameter of `recvfrom`. + wasi_sockets_0_2_0_udp_ip_socket_address_t remote_address; +} wasi_sockets_0_2_0_udp_incoming_datagram_t; + +typedef struct { + bool is_some; + wasi_sockets_0_2_0_udp_ip_socket_address_t val; +} wasi_sockets_0_2_0_udp_option_ip_socket_address_t; + +// A datagram to be sent out. +typedef struct wasi_sockets_0_2_0_udp_outgoing_datagram_t { + // The payload. + http_trigger_list_u8_t data; + // The destination address. + // + // The requirements on this field depend on how the stream was initialized: + // - with a remote address: this field must be None or match the stream's remote address exactly. + // - without a remote address: this field is required. + // + // If this value is None, the send operation is equivalent to `send` in POSIX. Otherwise it is equivalent to `sendto`. + wasi_sockets_0_2_0_udp_option_ip_socket_address_t remote_address; +} wasi_sockets_0_2_0_udp_outgoing_datagram_t; + +typedef struct wasi_sockets_0_2_0_udp_own_udp_socket_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_own_udp_socket_t; + +typedef struct wasi_sockets_0_2_0_udp_borrow_udp_socket_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_borrow_udp_socket_t; + +typedef struct wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t; + +typedef struct wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t; + +typedef struct wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t; + +typedef struct wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t; + +typedef wasi_sockets_0_2_0_network_borrow_network_t wasi_sockets_0_2_0_udp_borrow_network_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_void_error_code_t; + +typedef struct { + wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t f0; + wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t f1; +} wasi_sockets_0_2_0_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t ok; + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_udp_ip_socket_address_t ok; + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_t; + +typedef struct { + bool is_err; + union { + uint8_t ok; + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_u8_error_code_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_u64_error_code_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_sockets_0_2_0_udp_own_pollable_t; + +typedef struct { + wasi_sockets_0_2_0_udp_incoming_datagram_t *ptr; + size_t len; +} wasi_sockets_0_2_0_udp_list_incoming_datagram_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_udp_list_incoming_datagram_t ok; + wasi_sockets_0_2_0_udp_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_t; + +typedef struct { + wasi_sockets_0_2_0_udp_outgoing_datagram_t *ptr; + size_t len; +} wasi_sockets_0_2_0_udp_list_outgoing_datagram_t; + +typedef wasi_sockets_0_2_0_network_error_code_t wasi_sockets_0_2_0_udp_create_socket_error_code_t; + +typedef wasi_sockets_0_2_0_network_ip_address_family_t wasi_sockets_0_2_0_udp_create_socket_ip_address_family_t; + +typedef wasi_sockets_0_2_0_udp_own_udp_socket_t wasi_sockets_0_2_0_udp_create_socket_own_udp_socket_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_udp_create_socket_own_udp_socket_t ok; + wasi_sockets_0_2_0_udp_create_socket_error_code_t err; + } val; +} wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_t; + +typedef wasi_clocks_0_2_0_monotonic_clock_duration_t wasi_sockets_0_2_0_tcp_duration_t; + +typedef wasi_sockets_0_2_0_network_error_code_t wasi_sockets_0_2_0_tcp_error_code_t; + +typedef wasi_sockets_0_2_0_network_ip_socket_address_t wasi_sockets_0_2_0_tcp_ip_socket_address_t; + +typedef wasi_sockets_0_2_0_network_ip_address_family_t wasi_sockets_0_2_0_tcp_ip_address_family_t; + +typedef uint8_t wasi_sockets_0_2_0_tcp_shutdown_type_t; + +// Similar to `SHUT_RD` in POSIX. +#define WASI_SOCKETS_0_2_0_TCP_SHUTDOWN_TYPE_RECEIVE 0 +// Similar to `SHUT_WR` in POSIX. +#define WASI_SOCKETS_0_2_0_TCP_SHUTDOWN_TYPE_SEND 1 +// Similar to `SHUT_RDWR` in POSIX. +#define WASI_SOCKETS_0_2_0_TCP_SHUTDOWN_TYPE_BOTH 2 + +typedef struct wasi_sockets_0_2_0_tcp_own_tcp_socket_t { + int32_t __handle; +} wasi_sockets_0_2_0_tcp_own_tcp_socket_t; + +typedef struct wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t { + int32_t __handle; +} wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t; + +typedef wasi_sockets_0_2_0_network_borrow_network_t wasi_sockets_0_2_0_tcp_borrow_network_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_void_error_code_t; + +typedef wasi_io_0_2_0_streams_own_input_stream_t wasi_sockets_0_2_0_tcp_own_input_stream_t; + +typedef wasi_io_0_2_0_streams_own_output_stream_t wasi_sockets_0_2_0_tcp_own_output_stream_t; + +typedef struct { + wasi_sockets_0_2_0_tcp_own_input_stream_t f0; + wasi_sockets_0_2_0_tcp_own_output_stream_t f1; +} wasi_sockets_0_2_0_tcp_tuple2_own_input_stream_own_output_stream_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_tuple2_own_input_stream_own_output_stream_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t; + +typedef struct { + wasi_sockets_0_2_0_tcp_own_tcp_socket_t f0; + wasi_sockets_0_2_0_tcp_own_input_stream_t f1; + wasi_sockets_0_2_0_tcp_own_output_stream_t f2; +} wasi_sockets_0_2_0_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_ip_socket_address_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_t; + +typedef struct { + bool is_err; + union { + bool ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_bool_error_code_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_duration_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_duration_error_code_t; + +typedef struct { + bool is_err; + union { + uint32_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_u32_error_code_t; + +typedef struct { + bool is_err; + union { + uint8_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_u8_error_code_t; + +typedef struct { + bool is_err; + union { + uint64_t ok; + wasi_sockets_0_2_0_tcp_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_result_u64_error_code_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_sockets_0_2_0_tcp_own_pollable_t; + +typedef wasi_sockets_0_2_0_network_error_code_t wasi_sockets_0_2_0_tcp_create_socket_error_code_t; + +typedef wasi_sockets_0_2_0_network_ip_address_family_t wasi_sockets_0_2_0_tcp_create_socket_ip_address_family_t; + +typedef wasi_sockets_0_2_0_tcp_own_tcp_socket_t wasi_sockets_0_2_0_tcp_create_socket_own_tcp_socket_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_tcp_create_socket_own_tcp_socket_t ok; + wasi_sockets_0_2_0_tcp_create_socket_error_code_t err; + } val; +} wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_t; + +typedef wasi_sockets_0_2_0_network_error_code_t wasi_sockets_0_2_0_ip_name_lookup_error_code_t; + +typedef wasi_sockets_0_2_0_network_ip_address_t wasi_sockets_0_2_0_ip_name_lookup_ip_address_t; + +typedef struct wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t; + +typedef struct wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t { + int32_t __handle; +} wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t; + +typedef wasi_sockets_0_2_0_network_borrow_network_t wasi_sockets_0_2_0_ip_name_lookup_borrow_network_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t ok; + wasi_sockets_0_2_0_ip_name_lookup_error_code_t err; + } val; +} wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_t; + +typedef struct { + bool is_some; + wasi_sockets_0_2_0_ip_name_lookup_ip_address_t val; +} wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t; + +typedef struct { + bool is_err; + union { + wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t ok; + wasi_sockets_0_2_0_ip_name_lookup_error_code_t err; + } val; +} wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_t; + +typedef wasi_io_0_2_0_poll_own_pollable_t wasi_sockets_0_2_0_ip_name_lookup_own_pollable_t; + +typedef struct { + uint64_t f0; + uint64_t f1; +} http_trigger_tuple2_u64_u64_t; + +// The set of errors which may be raised by functions in this package +typedef struct wasi_keyvalue_store_error_t { + uint8_t tag; + union { + http_trigger_string_t other; + } val; +} wasi_keyvalue_store_error_t; + +// The host does not recognize the store identifier requested. +#define WASI_KEYVALUE_STORE_ERROR_NO_SUCH_STORE 0 +// The requesting component does not have access to the specified store +// (which may or may not exist). +#define WASI_KEYVALUE_STORE_ERROR_ACCESS_DENIED 1 +// Some implementation-specific error has occurred (e.g. I/O) +#define WASI_KEYVALUE_STORE_ERROR_OTHER 2 + +// A response to a `list-keys` operation. +typedef struct wasi_keyvalue_store_key_response_t { + // The list of keys returned by the query. + http_trigger_list_string_t keys; + // The continuation token to use to fetch the next page of keys. If this is `null`, then + // there are no more keys to fetch. + http_trigger_option_string_t cursor; +} wasi_keyvalue_store_key_response_t; + +typedef struct wasi_keyvalue_store_own_bucket_t { + int32_t __handle; +} wasi_keyvalue_store_own_bucket_t; + +typedef struct wasi_keyvalue_store_borrow_bucket_t { + int32_t __handle; +} wasi_keyvalue_store_borrow_bucket_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_store_own_bucket_t ok; + wasi_keyvalue_store_error_t err; + } val; +} wasi_keyvalue_store_result_own_bucket_error_t; + +typedef struct { + bool is_err; + union { + http_trigger_option_list_u8_t ok; + wasi_keyvalue_store_error_t err; + } val; +} wasi_keyvalue_store_result_option_list_u8_error_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_store_error_t err; + } val; +} wasi_keyvalue_store_result_void_error_t; + +typedef struct { + bool is_err; + union { + bool ok; + wasi_keyvalue_store_error_t err; + } val; +} wasi_keyvalue_store_result_bool_error_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_store_key_response_t ok; + wasi_keyvalue_store_error_t err; + } val; +} wasi_keyvalue_store_result_key_response_error_t; + +typedef wasi_keyvalue_store_error_t wasi_keyvalue_atomics_error_t; + +typedef struct wasi_keyvalue_atomics_own_cas_t { + int32_t __handle; +} wasi_keyvalue_atomics_own_cas_t; + +typedef struct wasi_keyvalue_atomics_borrow_cas_t { + int32_t __handle; +} wasi_keyvalue_atomics_borrow_cas_t; + +// The error returned by a CAS operation +typedef struct wasi_keyvalue_atomics_cas_error_t { + uint8_t tag; + union { + wasi_keyvalue_atomics_error_t store_error; + wasi_keyvalue_atomics_own_cas_t cas_failed; + } val; +} wasi_keyvalue_atomics_cas_error_t; + +// A store error occurred when performing the operation +#define WASI_KEYVALUE_ATOMICS_CAS_ERROR_STORE_ERROR 0 +// The CAS operation failed because the value was too old. This returns a new CAS handle +// for easy retries. Implementors MUST return a CAS handle that has been updated to the +// latest version or transaction. +#define WASI_KEYVALUE_ATOMICS_CAS_ERROR_CAS_FAILED 1 + +typedef wasi_keyvalue_store_borrow_bucket_t wasi_keyvalue_atomics_borrow_bucket_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_atomics_own_cas_t ok; + wasi_keyvalue_atomics_error_t err; + } val; +} wasi_keyvalue_atomics_result_own_cas_error_t; + +typedef struct { + bool is_err; + union { + http_trigger_option_list_u8_t ok; + wasi_keyvalue_atomics_error_t err; + } val; +} wasi_keyvalue_atomics_result_option_list_u8_error_t; + +typedef struct { + bool is_err; + union { + int64_t ok; + wasi_keyvalue_atomics_error_t err; + } val; +} wasi_keyvalue_atomics_result_s64_error_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_atomics_cas_error_t err; + } val; +} wasi_keyvalue_atomics_result_void_cas_error_t; + +typedef wasi_keyvalue_store_error_t wasi_keyvalue_batch_error_t; + +typedef wasi_keyvalue_store_borrow_bucket_t wasi_keyvalue_batch_borrow_bucket_t; + +typedef struct { + http_trigger_string_t f0; + http_trigger_option_list_u8_t f1; +} http_trigger_tuple2_string_option_list_u8_t; + +typedef struct { + http_trigger_tuple2_string_option_list_u8_t *ptr; + size_t len; +} http_trigger_list_tuple2_string_option_list_u8_t; + +typedef struct { + bool is_err; + union { + http_trigger_list_tuple2_string_option_list_u8_t ok; + wasi_keyvalue_batch_error_t err; + } val; +} wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_t; + +typedef struct { + http_trigger_string_t f0; + http_trigger_list_u8_t f1; +} http_trigger_tuple2_string_list_u8_t; + +typedef struct { + http_trigger_tuple2_string_list_u8_t *ptr; + size_t len; +} http_trigger_list_tuple2_string_list_u8_t; + +typedef struct { + bool is_err; + union { + wasi_keyvalue_batch_error_t err; + } val; +} wasi_keyvalue_batch_result_void_error_t; + +typedef wasi_http_0_2_0_types_own_incoming_request_t exports_wasi_http_0_2_0_incoming_handler_own_incoming_request_t; + +typedef wasi_http_0_2_0_types_own_response_outparam_t exports_wasi_http_0_2_0_incoming_handler_own_response_outparam_t; + +// Imported Functions from `spin:postgres/postgres@3.0.0` +// Open a connection to the Postgres instance at `address`. +extern bool spin_postgres_3_0_0_postgres_static_connection_open(http_trigger_string_t *address, spin_postgres_3_0_0_postgres_own_connection_t *ret, spin_postgres_3_0_0_postgres_error_t *err); +// Query the database. +extern bool spin_postgres_3_0_0_postgres_method_connection_query(spin_postgres_3_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_3_0_0_postgres_list_parameter_value_t *params, spin_postgres_3_0_0_postgres_row_set_t *ret, spin_postgres_3_0_0_postgres_error_t *err); +// Execute command to the database. +extern bool spin_postgres_3_0_0_postgres_method_connection_execute(spin_postgres_3_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_3_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, spin_postgres_3_0_0_postgres_error_t *err); + +// Imported Functions from `spin:postgres/postgres@4.0.0` +// Open a connection to the Postgres instance at `address`. +extern bool spin_postgres_4_0_0_postgres_static_connection_open(http_trigger_string_t *address, spin_postgres_4_0_0_postgres_own_connection_t *ret, spin_postgres_4_0_0_postgres_error_t *err); +// Query the database. +extern bool spin_postgres_4_0_0_postgres_method_connection_query(spin_postgres_4_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_4_0_0_postgres_list_parameter_value_t *params, spin_postgres_4_0_0_postgres_row_set_t *ret, spin_postgres_4_0_0_postgres_error_t *err); +// Execute command to the database. +extern bool spin_postgres_4_0_0_postgres_method_connection_execute(spin_postgres_4_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, spin_postgres_4_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, spin_postgres_4_0_0_postgres_error_t *err); + +// Imported Functions from `spin:sqlite/sqlite@3.0.0` +// Open a connection to a named database instance. +// +// If `database` is "default", the default instance is opened. +// +// `error::no-such-database` will be raised if the `name` is not recognized. +extern bool spin_sqlite_sqlite_static_connection_open(http_trigger_string_t *database, spin_sqlite_sqlite_own_connection_t *ret, spin_sqlite_sqlite_error_t *err); +// Execute a statement returning back data if there is any +extern bool spin_sqlite_sqlite_method_connection_execute(spin_sqlite_sqlite_borrow_connection_t self, http_trigger_string_t *statement, spin_sqlite_sqlite_list_value_t *parameters, spin_sqlite_sqlite_query_result_t *ret, spin_sqlite_sqlite_error_t *err); +// The SQLite rowid of the most recent successful INSERT on the connection, or 0 if +// there has not yet been an INSERT on the connection. +extern int64_t spin_sqlite_sqlite_method_connection_last_insert_rowid(spin_sqlite_sqlite_borrow_connection_t self); +// The number of rows modified, inserted or deleted by the most recently completed +// INSERT, UPDATE or DELETE statement on the connection. +extern uint64_t spin_sqlite_sqlite_method_connection_changes(spin_sqlite_sqlite_borrow_connection_t self); + +// Imported Functions from `wasi:config/store@0.2.0-draft-2024-09-27` +// Gets a configuration value of type `string` associated with the `key`. +// +// The value is returned as an `option`. If the key is not found, +// `Ok(none)` is returned. If an error occurs, an `Err(error)` is returned. +extern bool wasi_config_store_get(http_trigger_string_t *key, http_trigger_option_string_t *ret, wasi_config_store_error_t *err); +// Gets a list of configuration key-value pairs of type `string`. +// +// If an error occurs, an `Err(error)` is returned. +extern bool wasi_config_store_get_all(http_trigger_list_tuple2_string_string_t *ret, wasi_config_store_error_t *err); + +// Imported Functions from `wasi:io/poll@0.2.0` +// Return the readiness of a pollable. This function never blocks. +// +// Returns `true` when the pollable is ready, and `false` otherwise. +extern bool wasi_io_0_2_0_poll_method_pollable_ready(wasi_io_0_2_0_poll_borrow_pollable_t self); +// `block` returns immediately if the pollable is ready, and otherwise +// blocks until ready. +// +// This function is equivalent to calling `poll.poll` on a list +// containing only this pollable. +extern void wasi_io_0_2_0_poll_method_pollable_block(wasi_io_0_2_0_poll_borrow_pollable_t self); +// Poll for completion on a set of pollables. +// +// This function takes a list of pollables, which identify I/O sources of +// interest, and waits until one or more of the events is ready for I/O. +// +// The result `list` contains one or more indices of handles in the +// argument list that is ready for I/O. +// +// If the list contains more elements than can be indexed with a `u32` +// value, this function traps. +// +// A timeout can be implemented by adding a pollable from the +// wasi-clocks API to the list. +// +// This function does not return a `result`; polling in itself does not +// do any I/O so it doesn't fail. If any of the I/O sources identified by +// the pollables has an error, it is indicated by marking the source as +// being reaedy for I/O. +extern void wasi_io_0_2_0_poll_poll(wasi_io_0_2_0_poll_list_borrow_pollable_t *in, http_trigger_list_u32_t *ret); + +// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0` +// Read the current value of the clock. +// +// The clock is monotonic, therefore calling this function repeatedly will +// produce a sequence of non-decreasing values. +extern wasi_clocks_0_2_0_monotonic_clock_instant_t wasi_clocks_0_2_0_monotonic_clock_now(void); +// Query the resolution of the clock. Returns the duration of time +// corresponding to a clock tick. +extern wasi_clocks_0_2_0_monotonic_clock_duration_t wasi_clocks_0_2_0_monotonic_clock_resolution(void); +// Create a `pollable` which will resolve once the specified instant +// occured. +extern wasi_clocks_0_2_0_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_monotonic_clock_subscribe_instant(wasi_clocks_0_2_0_monotonic_clock_instant_t when); +// Create a `pollable` which will resolve once the given duration has +// elapsed, starting at the time at which this function was called. +// occured. +extern wasi_clocks_0_2_0_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_monotonic_clock_subscribe_duration(wasi_clocks_0_2_0_monotonic_clock_duration_t when); + +// Imported Functions from `wasi:io/error@0.2.0` +// Returns a string that is suitable to assist humans in debugging +// this error. +// +// WARNING: The returned string should not be consumed mechanically! +// It may change across platforms, hosts, or other implementation +// details. Parsing this string is a major platform-compatibility +// hazard. +extern void wasi_io_0_2_0_error_method_error_to_debug_string(wasi_io_0_2_0_error_borrow_error_t self, http_trigger_string_t *ret); + +// Imported Functions from `wasi:io/streams@0.2.0` +// Perform a non-blocking read from the stream. +// +// When the source of a `read` is binary data, the bytes from the source +// are returned verbatim. When the source of a `read` is known to the +// implementation to be text, bytes containing the UTF-8 encoding of the +// text are returned. +// +// This function returns a list of bytes containing the read data, +// when successful. The returned list will contain up to `len` bytes; +// it may return fewer than requested, but not more. The list is +// empty when no bytes are available for reading at this time. The +// pollable given by `subscribe` will be ready when more bytes are +// available. +// +// This function fails with a `stream-error` when the operation +// encounters an error, giving `last-operation-failed`, or when the +// stream is closed, giving `closed`. +// +// When the caller gives a `len` of 0, it represents a request to +// read 0 bytes. If the stream is still open, this call should +// succeed and return an empty list, or otherwise fail with `closed`. +// +// The `len` parameter is a `u64`, which could represent a list of u8 which +// is not possible to allocate in wasm32, or not desirable to allocate as +// as a return value by the callee. The callee may return a list of bytes +// less than `len` in size while more bytes are available for reading. +extern bool wasi_io_0_2_0_streams_method_input_stream_read(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, http_trigger_list_u8_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Read bytes from a stream, after blocking until at least one byte can +// be read. Except for blocking, behavior is identical to `read`. +extern bool wasi_io_0_2_0_streams_method_input_stream_blocking_read(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, http_trigger_list_u8_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Skip bytes from a stream. Returns number of bytes skipped. +// +// Behaves identical to `read`, except instead of returning a list +// of bytes, returns the number of bytes consumed from the stream. +extern bool wasi_io_0_2_0_streams_method_input_stream_skip(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Skip bytes from a stream, after blocking until at least one byte +// can be skipped. Except for blocking behavior, identical to `skip`. +extern bool wasi_io_0_2_0_streams_method_input_stream_blocking_skip(wasi_io_0_2_0_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Create a `pollable` which will resolve once either the specified stream +// has bytes available to read or the other end of the stream has been +// closed. +// The created `pollable` is a child resource of the `input-stream`. +// Implementations may trap if the `input-stream` is dropped before +// all derived `pollable`s created with this function are dropped. +extern wasi_io_0_2_0_streams_own_pollable_t wasi_io_0_2_0_streams_method_input_stream_subscribe(wasi_io_0_2_0_streams_borrow_input_stream_t self); +// Check readiness for writing. This function never blocks. +// +// Returns the number of bytes permitted for the next call to `write`, +// or an error. Calling `write` with more bytes than this function has +// permitted will trap. +// +// When this function returns 0 bytes, the `subscribe` pollable will +// become ready when this function will report at least 1 byte, or an +// error. +extern bool wasi_io_0_2_0_streams_method_output_stream_check_write(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Perform a write. This function never blocks. +// +// When the destination of a `write` is binary data, the bytes from +// `contents` are written verbatim. When the destination of a `write` is +// known to the implementation to be text, the bytes of `contents` are +// transcoded from UTF-8 into the encoding of the destination and then +// written. +// +// Precondition: check-write gave permit of Ok(n) and contents has a +// length of less than or equal to n. Otherwise, this function will trap. +// +// returns Err(closed) without writing if the stream has closed since +// the last call to check-write provided a permit. +extern bool wasi_io_0_2_0_streams_method_output_stream_write(wasi_io_0_2_0_streams_borrow_output_stream_t self, http_trigger_list_u8_t *contents, wasi_io_0_2_0_streams_stream_error_t *err); +// Perform a write of up to 4096 bytes, and then flush the stream. Block +// until all of these operations are complete, or an error occurs. +// +// This is a convenience wrapper around the use of `check-write`, +// `subscribe`, `write`, and `flush`, and is implemented with the +// following pseudo-code: +// +// ```text +// let pollable = this.subscribe(); +// while !contents.is_empty() { +// // Wait for the stream to become writable +// pollable.block(); +// let Ok(n) = this.check-write(); // eliding error handling +// let len = min(n, contents.len()); +// let (chunk, rest) = contents.split_at(len); +// this.write(chunk ); // eliding error handling +// contents = rest; +// } +// this.flush(); +// // Wait for completion of `flush` +// pollable.block(); +// // Check for any errors that arose during `flush` +// let _ = this.check-write(); // eliding error handling +// ``` +extern bool wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, http_trigger_list_u8_t *contents, wasi_io_0_2_0_streams_stream_error_t *err); +// Request to flush buffered output. This function never blocks. +// +// This tells the output-stream that the caller intends any buffered +// output to be flushed. the output which is expected to be flushed +// is all that has been passed to `write` prior to this call. +// +// Upon calling this function, the `output-stream` will not accept any +// writes (`check-write` will return `ok(0)`) until the flush has +// completed. The `subscribe` pollable will become ready when the +// flush has completed and the stream can accept more writes. +extern bool wasi_io_0_2_0_streams_method_output_stream_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_stream_error_t *err); +// Request to flush buffered output, and block until flush completes +// and stream is ready for writing again. +extern bool wasi_io_0_2_0_streams_method_output_stream_blocking_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_stream_error_t *err); +// Create a `pollable` which will resolve once the output-stream +// is ready for more writing, or an error has occured. When this +// pollable is ready, `check-write` will return `ok(n)` with n>0, or an +// error. +// +// If the stream is closed, this pollable is always ready immediately. +// +// The created `pollable` is a child resource of the `output-stream`. +// Implementations may trap if the `output-stream` is dropped before +// all derived `pollable`s created with this function are dropped. +extern wasi_io_0_2_0_streams_own_pollable_t wasi_io_0_2_0_streams_method_output_stream_subscribe(wasi_io_0_2_0_streams_borrow_output_stream_t self); +// Write zeroes to a stream. +// +// This should be used precisely like `write` with the exact same +// preconditions (must use check-write first), but instead of +// passing a list of bytes, you simply pass the number of zero-bytes +// that should be written. +extern bool wasi_io_0_2_0_streams_method_output_stream_write_zeroes(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_streams_stream_error_t *err); +// Perform a write of up to 4096 zeroes, and then flush the stream. +// Block until all of these operations are complete, or an error +// occurs. +// +// This is a convenience wrapper around the use of `check-write`, +// `subscribe`, `write-zeroes`, and `flush`, and is implemented with +// the following pseudo-code: +// +// ```text +// let pollable = this.subscribe(); +// while num_zeroes != 0 { +// // Wait for the stream to become writable +// pollable.block(); +// let Ok(n) = this.check-write(); // eliding error handling +// let len = min(n, num_zeroes); +// this.write-zeroes(len); // eliding error handling +// num_zeroes -= len; +// } +// this.flush(); +// // Wait for completion of `flush` +// pollable.block(); +// // Check for any errors that arose during `flush` +// let _ = this.check-write(); // eliding error handling +// ``` +extern bool wasi_io_0_2_0_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_0_2_0_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_streams_stream_error_t *err); +// Read from one stream and write to another. +// +// The behavior of splice is equivelant to: +// 1. calling `check-write` on the `output-stream` +// 2. calling `read` on the `input-stream` with the smaller of the +// `check-write` permitted length and the `len` provided to `splice` +// 3. calling `write` on the `output-stream` with that read data. +// +// Any error reported by the call to `check-write`, `read`, or +// `write` ends the splice and reports that error. +// +// This function returns the number of bytes transferred; it may be less +// than `len`. +extern bool wasi_io_0_2_0_streams_method_output_stream_splice(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); +// Read from one stream and write to another, with blocking. +// +// This is similar to `splice`, except that it blocks until the +// `output-stream` is ready for writing, and the `input-stream` +// is ready for reading, before performing the `splice`. +extern bool wasi_io_0_2_0_streams_method_output_stream_blocking_splice(wasi_io_0_2_0_streams_borrow_output_stream_t self, wasi_io_0_2_0_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_streams_stream_error_t *err); + +// Imported Functions from `wasi:http/types@0.2.0` +// Attempts to extract a http-related `error` from the wasi:io `error` +// provided. +// +// Stream operations which return +// `wasi:io/stream/stream-error::last-operation-failed` have a payload of +// type `wasi:io/error/error` with more information about the operation +// that failed. This payload can be passed through to this function to see +// if there's http-related information about the error to return. +// +// Note that this function is fallible because not all io-errors are +// http-related errors. +extern bool wasi_http_0_2_0_types_http_error_code(wasi_http_0_2_0_types_borrow_io_error_t err_, wasi_http_0_2_0_types_error_code_t *ret); +// Construct an empty HTTP Fields. +// +// The resulting `fields` is mutable. +extern wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_constructor_fields(void); +// Construct an HTTP Fields. +// +// The resulting `fields` is mutable. +// +// The list represents each key-value pair in the Fields. Keys +// which have multiple values are represented by multiple entries in this +// list with the same key. +// +// The tuple is a pair of the field key, represented as a string, and +// Value, represented as a list of bytes. In a valid Fields, all keys +// and values are valid UTF-8 strings. However, values are not always +// well-formed, so they are represented as a raw list of bytes. +// +// An error result will be returned if any header or value was +// syntactically invalid, or if a header was forbidden. +extern bool wasi_http_0_2_0_types_static_fields_from_list(http_trigger_list_tuple2_field_key_field_value_t *entries, wasi_http_0_2_0_types_own_fields_t *ret, wasi_http_0_2_0_types_header_error_t *err); +// Get all of the values corresponding to a key. If the key is not present +// in this `fields`, an empty list is returned. However, if the key is +// present but empty, this is represented by a list with one or more +// empty field-values present. +extern void wasi_http_0_2_0_types_method_fields_get(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, http_trigger_list_field_value_t *ret); +// Returns `true` when the key is present in this `fields`. If the key is +// syntactically invalid, `false` is returned. +extern bool wasi_http_0_2_0_types_method_fields_has(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name); +// Set all of the values for a key. Clears any existing values for that +// key, if they have been set. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +extern bool wasi_http_0_2_0_types_method_fields_set(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, http_trigger_list_field_value_t *value, wasi_http_0_2_0_types_header_error_t *err); +// Delete all values for a key. Does nothing if no values for the key +// exist. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +extern bool wasi_http_0_2_0_types_method_fields_delete(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, wasi_http_0_2_0_types_header_error_t *err); +// Append a value for a key. Does not change or delete any existing +// values for that key. +// +// Fails with `header-error.immutable` if the `fields` are immutable. +extern bool wasi_http_0_2_0_types_method_fields_append(wasi_http_0_2_0_types_borrow_fields_t self, wasi_http_0_2_0_types_field_key_t *name, wasi_http_0_2_0_types_field_value_t *value, wasi_http_0_2_0_types_header_error_t *err); +// Retrieve the full set of keys and values in the Fields. Like the +// constructor, the list represents each key-value pair. +// +// The outer list represents each key-value pair in the Fields. Keys +// which have multiple values are represented by multiple entries in this +// list with the same key. +extern void wasi_http_0_2_0_types_method_fields_entries(wasi_http_0_2_0_types_borrow_fields_t self, http_trigger_list_tuple2_field_key_field_value_t *ret); +// Make a deep copy of the Fields. Equivelant in behavior to calling the +// `fields` constructor on the return value of `entries`. The resulting +// `fields` is mutable. +extern wasi_http_0_2_0_types_own_fields_t wasi_http_0_2_0_types_method_fields_clone(wasi_http_0_2_0_types_borrow_fields_t self); +// Returns the method of the incoming request. +extern void wasi_http_0_2_0_types_method_incoming_request_method(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_method_t *ret); +// Returns the path with query parameters from the request, as a string. +extern bool wasi_http_0_2_0_types_method_incoming_request_path_with_query(wasi_http_0_2_0_types_borrow_incoming_request_t self, http_trigger_string_t *ret); +// Returns the protocol scheme from the request. +extern bool wasi_http_0_2_0_types_method_incoming_request_scheme(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_scheme_t *ret); +// Returns the authority from the request, if it was present. +extern bool wasi_http_0_2_0_types_method_incoming_request_authority(wasi_http_0_2_0_types_borrow_incoming_request_t self, http_trigger_string_t *ret); +// Get the `headers` associated with the request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// The `headers` returned are a child resource: it must be dropped before +// the parent `incoming-request` is dropped. Dropping this +// `incoming-request` before all children are dropped will trap. +extern wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_incoming_request_headers(wasi_http_0_2_0_types_borrow_incoming_request_t self); +// Gives the `incoming-body` associated with this request. Will only +// return success at most once, and subsequent calls will return error. +extern bool wasi_http_0_2_0_types_method_incoming_request_consume(wasi_http_0_2_0_types_borrow_incoming_request_t self, wasi_http_0_2_0_types_own_incoming_body_t *ret); +// Construct a new `outgoing-request` with a default `method` of `GET`, and +// `none` values for `path-with-query`, `scheme`, and `authority`. +// +// * `headers` is the HTTP Headers for the Request. +// +// It is possible to construct, or manipulate with the accessor functions +// below, an `outgoing-request` with an invalid combination of `scheme` +// and `authority`, or `headers` which are not permitted to be sent. +// It is the obligation of the `outgoing-handler.handle` implementation +// to reject invalid constructions of `outgoing-request`. +extern wasi_http_0_2_0_types_own_outgoing_request_t wasi_http_0_2_0_types_constructor_outgoing_request(wasi_http_0_2_0_types_own_headers_t headers); +// Returns the resource corresponding to the outgoing Body for this +// Request. +// +// Returns success on the first call: the `outgoing-body` resource for +// this `outgoing-request` can be retrieved at most once. Subsequent +// calls will return error. +extern bool wasi_http_0_2_0_types_method_outgoing_request_body(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_own_outgoing_body_t *ret); +// Get the Method for the Request. +extern void wasi_http_0_2_0_types_method_outgoing_request_method(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_method_t *ret); +// Set the Method for the Request. Fails if the string present in a +// `method.other` argument is not a syntactically valid method. +extern bool wasi_http_0_2_0_types_method_outgoing_request_set_method(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_method_t *method); +// Get the combination of the HTTP Path and Query for the Request. +// When `none`, this represents an empty Path and empty Query. +extern bool wasi_http_0_2_0_types_method_outgoing_request_path_with_query(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *ret); +// Set the combination of the HTTP Path and Query for the Request. +// When `none`, this represents an empty Path and empty Query. Fails is the +// string given is not a syntactically valid path and query uri component. +extern bool wasi_http_0_2_0_types_method_outgoing_request_set_path_with_query(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *maybe_path_with_query); +// Get the HTTP Related Scheme for the Request. When `none`, the +// implementation may choose an appropriate default scheme. +extern bool wasi_http_0_2_0_types_method_outgoing_request_scheme(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_scheme_t *ret); +// Set the HTTP Related Scheme for the Request. When `none`, the +// implementation may choose an appropriate default scheme. Fails if the +// string given is not a syntactically valid uri scheme. +extern bool wasi_http_0_2_0_types_method_outgoing_request_set_scheme(wasi_http_0_2_0_types_borrow_outgoing_request_t self, wasi_http_0_2_0_types_scheme_t *maybe_scheme); +// Get the HTTP Authority for the Request. A value of `none` may be used +// with Related Schemes which do not require an Authority. The HTTP and +// HTTPS schemes always require an authority. +extern bool wasi_http_0_2_0_types_method_outgoing_request_authority(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *ret); +// Set the HTTP Authority for the Request. A value of `none` may be used +// with Related Schemes which do not require an Authority. The HTTP and +// HTTPS schemes always require an authority. Fails if the string given is +// not a syntactically valid uri authority. +extern bool wasi_http_0_2_0_types_method_outgoing_request_set_authority(wasi_http_0_2_0_types_borrow_outgoing_request_t self, http_trigger_string_t *maybe_authority); +// Get the headers associated with the Request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `outgoing-request` is dropped, or its ownership is transfered to +// another component by e.g. `outgoing-handler.handle`. +extern wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_outgoing_request_headers(wasi_http_0_2_0_types_borrow_outgoing_request_t self); +// Construct a default `request-options` value. +extern wasi_http_0_2_0_types_own_request_options_t wasi_http_0_2_0_types_constructor_request_options(void); +// The timeout for the initial connect to the HTTP Server. +extern bool wasi_http_0_2_0_types_method_request_options_connect_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret); +// Set the timeout for the initial connect to the HTTP Server. An error +// return value indicates that this timeout is not supported. +extern bool wasi_http_0_2_0_types_method_request_options_set_connect_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration); +// The timeout for receiving the first byte of the Response body. +extern bool wasi_http_0_2_0_types_method_request_options_first_byte_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret); +// Set the timeout for receiving the first byte of the Response body. An +// error return value indicates that this timeout is not supported. +extern bool wasi_http_0_2_0_types_method_request_options_set_first_byte_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration); +// The timeout for receiving subsequent chunks of bytes in the Response +// body stream. +extern bool wasi_http_0_2_0_types_method_request_options_between_bytes_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *ret); +// Set the timeout for receiving subsequent chunks of bytes in the Response +// body stream. An error return value indicates that this timeout is not +// supported. +extern bool wasi_http_0_2_0_types_method_request_options_set_between_bytes_timeout(wasi_http_0_2_0_types_borrow_request_options_t self, wasi_http_0_2_0_types_duration_t *maybe_duration); +// Set the value of the `response-outparam` to either send a response, +// or indicate an error. +// +// This method consumes the `response-outparam` to ensure that it is +// called at most once. If it is never called, the implementation +// will respond with an error. +// +// The user may provide an `error` to `response` to allow the +// implementation determine how to respond with an HTTP error response. +extern void wasi_http_0_2_0_types_static_response_outparam_set(wasi_http_0_2_0_types_own_response_outparam_t param, wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t *response); +// Returns the status code from the incoming response. +extern wasi_http_0_2_0_types_status_code_t wasi_http_0_2_0_types_method_incoming_response_status(wasi_http_0_2_0_types_borrow_incoming_response_t self); +// Returns the headers from the incoming response. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `incoming-response` is dropped. +extern wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_incoming_response_headers(wasi_http_0_2_0_types_borrow_incoming_response_t self); +// Returns the incoming body. May be called at most once. Returns error +// if called additional times. +extern bool wasi_http_0_2_0_types_method_incoming_response_consume(wasi_http_0_2_0_types_borrow_incoming_response_t self, wasi_http_0_2_0_types_own_incoming_body_t *ret); +// Returns the contents of the body, as a stream of bytes. +// +// Returns success on first call: the stream representing the contents +// can be retrieved at most once. Subsequent calls will return error. +// +// The returned `input-stream` resource is a child: it must be dropped +// before the parent `incoming-body` is dropped, or consumed by +// `incoming-body.finish`. +// +// This invariant ensures that the implementation can determine whether +// the user is consuming the contents of the body, waiting on the +// `future-trailers` to be ready, or neither. This allows for network +// backpressure is to be applied when the user is consuming the body, +// and for that backpressure to not inhibit delivery of the trailers if +// the user does not read the entire body. +extern bool wasi_http_0_2_0_types_method_incoming_body_stream(wasi_http_0_2_0_types_borrow_incoming_body_t self, wasi_http_0_2_0_types_own_input_stream_t *ret); +// Takes ownership of `incoming-body`, and returns a `future-trailers`. +// This function will trap if the `input-stream` child is still alive. +extern wasi_http_0_2_0_types_own_future_trailers_t wasi_http_0_2_0_types_static_incoming_body_finish(wasi_http_0_2_0_types_own_incoming_body_t this_); +// Returns a pollable which becomes ready when either the trailers have +// been received, or an error has occured. When this pollable is ready, +// the `get` method will return `some`. +extern wasi_http_0_2_0_types_own_pollable_t wasi_http_0_2_0_types_method_future_trailers_subscribe(wasi_http_0_2_0_types_borrow_future_trailers_t self); +// Returns the contents of the trailers, or an error which occured, +// once the future is ready. +// +// The outer `option` represents future readiness. Users can wait on this +// `option` to become `some` using the `subscribe` method. +// +// The outer `result` is used to retrieve the trailers or error at most +// once. It will be success on the first call in which the outer option +// is `some`, and error on subsequent calls. +// +// The inner `result` represents that either the HTTP Request or Response +// body, as well as any trailers, were received successfully, or that an +// error occured receiving them. The optional `trailers` indicates whether +// or not trailers were present in the body. +// +// When some `trailers` are returned by this method, the `trailers` +// resource is immutable, and a child. Use of the `set`, `append`, or +// `delete` methods will return an error, and the resource must be +// dropped before the parent `future-trailers` is dropped. +extern bool wasi_http_0_2_0_types_method_future_trailers_get(wasi_http_0_2_0_types_borrow_future_trailers_t self, wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t *ret); +// Construct an `outgoing-response`, with a default `status-code` of `200`. +// If a different `status-code` is needed, it must be set via the +// `set-status-code` method. +// +// * `headers` is the HTTP Headers for the Response. +extern wasi_http_0_2_0_types_own_outgoing_response_t wasi_http_0_2_0_types_constructor_outgoing_response(wasi_http_0_2_0_types_own_headers_t headers); +// Get the HTTP Status Code for the Response. +extern wasi_http_0_2_0_types_status_code_t wasi_http_0_2_0_types_method_outgoing_response_status_code(wasi_http_0_2_0_types_borrow_outgoing_response_t self); +// Set the HTTP Status Code for the Response. Fails if the status-code +// given is not a valid http status code. +extern bool wasi_http_0_2_0_types_method_outgoing_response_set_status_code(wasi_http_0_2_0_types_borrow_outgoing_response_t self, wasi_http_0_2_0_types_status_code_t status_code); +// Get the headers associated with the Request. +// +// The returned `headers` resource is immutable: `set`, `append`, and +// `delete` operations will fail with `header-error.immutable`. +// +// This headers resource is a child: it must be dropped before the parent +// `outgoing-request` is dropped, or its ownership is transfered to +// another component by e.g. `outgoing-handler.handle`. +extern wasi_http_0_2_0_types_own_headers_t wasi_http_0_2_0_types_method_outgoing_response_headers(wasi_http_0_2_0_types_borrow_outgoing_response_t self); +// Returns the resource corresponding to the outgoing Body for this Response. +// +// Returns success on the first call: the `outgoing-body` resource for +// this `outgoing-response` can be retrieved at most once. Subsequent +// calls will return error. +extern bool wasi_http_0_2_0_types_method_outgoing_response_body(wasi_http_0_2_0_types_borrow_outgoing_response_t self, wasi_http_0_2_0_types_own_outgoing_body_t *ret); +// Returns a stream for writing the body contents. +// +// The returned `output-stream` is a child resource: it must be dropped +// before the parent `outgoing-body` resource is dropped (or finished), +// otherwise the `outgoing-body` drop or `finish` will trap. +// +// Returns success on the first call: the `output-stream` resource for +// this `outgoing-body` may be retrieved at most once. Subsequent calls +// will return error. +extern bool wasi_http_0_2_0_types_method_outgoing_body_write(wasi_http_0_2_0_types_borrow_outgoing_body_t self, wasi_http_0_2_0_types_own_output_stream_t *ret); +// Finalize an outgoing body, optionally providing trailers. This must be +// called to signal that the response is complete. If the `outgoing-body` +// is dropped without calling `outgoing-body.finalize`, the implementation +// should treat the body as corrupted. +// +// Fails if the body's `outgoing-request` or `outgoing-response` was +// constructed with a Content-Length header, and the contents written +// to the body (via `write`) does not match the value given in the +// Content-Length. +extern bool wasi_http_0_2_0_types_static_outgoing_body_finish(wasi_http_0_2_0_types_own_outgoing_body_t this_, wasi_http_0_2_0_types_own_trailers_t *maybe_trailers, wasi_http_0_2_0_types_error_code_t *err); +// Returns a pollable which becomes ready when either the Response has +// been received, or an error has occured. When this pollable is ready, +// the `get` method will return `some`. +extern wasi_http_0_2_0_types_own_pollable_t wasi_http_0_2_0_types_method_future_incoming_response_subscribe(wasi_http_0_2_0_types_borrow_future_incoming_response_t self); +// Returns the incoming HTTP Response, or an error, once one is ready. +// +// The outer `option` represents future readiness. Users can wait on this +// `option` to become `some` using the `subscribe` method. +// +// The outer `result` is used to retrieve the response or error at most +// once. It will be success on the first call in which the outer option +// is `some`, and error on subsequent calls. +// +// The inner `result` represents that either the incoming HTTP Response +// status and headers have recieved successfully, or that an error +// occured. Errors may also occur while consuming the response body, +// but those will be reported by the `incoming-body` and its +// `output-stream` child. +extern bool wasi_http_0_2_0_types_method_future_incoming_response_get(wasi_http_0_2_0_types_borrow_future_incoming_response_t self, wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t *ret); + +// Imported Functions from `wasi:http/outgoing-handler@0.2.0` +// This function is invoked with an outgoing HTTP Request, and it returns +// a resource `future-incoming-response` which represents an HTTP Response +// which may arrive in the future. +// +// The `options` argument accepts optional parameters for the HTTP +// protocol's transport layer. +// +// This function may return an error if the `outgoing-request` is invalid +// or not allowed to be made. Otherwise, protocol errors are reported +// through the `future-incoming-response`. +extern bool wasi_http_0_2_0_outgoing_handler_handle(wasi_http_0_2_0_outgoing_handler_own_outgoing_request_t request, wasi_http_0_2_0_outgoing_handler_own_request_options_t *maybe_options, wasi_http_0_2_0_outgoing_handler_own_future_incoming_response_t *ret, wasi_http_0_2_0_outgoing_handler_error_code_t *err); + +// Imported Functions from `fermyon:spin/llm@2.0.0` +// Perform inferencing using the provided model and prompt with the given optional params +extern bool fermyon_spin_2_0_0_llm_infer(fermyon_spin_2_0_0_llm_inferencing_model_t *model, http_trigger_string_t *prompt, fermyon_spin_2_0_0_llm_inferencing_params_t *maybe_params, fermyon_spin_2_0_0_llm_inferencing_result_t *ret, fermyon_spin_2_0_0_llm_error_t *err); +// Generate embeddings for the supplied list of text +extern bool fermyon_spin_2_0_0_llm_generate_embeddings(fermyon_spin_2_0_0_llm_embedding_model_t *model, http_trigger_list_string_t *text, fermyon_spin_2_0_0_llm_embeddings_result_t *ret, fermyon_spin_2_0_0_llm_error_t *err); + +// Imported Functions from `fermyon:spin/redis@2.0.0` +// Open a connection to the Redis instance at `address`. +extern bool fermyon_spin_2_0_0_redis_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_redis_own_connection_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Publish a Redis message to the specified channel. +extern bool fermyon_spin_2_0_0_redis_method_connection_publish(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *channel, fermyon_spin_2_0_0_redis_payload_t *payload, fermyon_spin_2_0_0_redis_error_t *err); +// Get the value of a key. +extern bool fermyon_spin_2_0_0_redis_method_connection_get(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_option_payload_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Set key to value. +// +// If key already holds a value, it is overwritten. +extern bool fermyon_spin_2_0_0_redis_method_connection_set(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, fermyon_spin_2_0_0_redis_payload_t *value, fermyon_spin_2_0_0_redis_error_t *err); +// Increments the number stored at key by one. +// +// If the key does not exist, it is set to 0 before performing the operation. +// An `error::type-error` is returned if the key contains a value of the wrong type +// or contains a string that can not be represented as integer. +extern bool fermyon_spin_2_0_0_redis_method_connection_incr(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, int64_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Removes the specified keys. +// +// A key is ignored if it does not exist. Returns the number of keys deleted. +extern bool fermyon_spin_2_0_0_redis_method_connection_del(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_list_string_t *keys, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Add the specified `values` to the set named `key`, returning the number of newly-added values. +extern bool fermyon_spin_2_0_0_redis_method_connection_sadd(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *values, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Retrieve the contents of the set named `key`. +extern bool fermyon_spin_2_0_0_redis_method_connection_smembers(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Remove the specified `values` from the set named `key`, returning the number of newly-removed values. +extern bool fermyon_spin_2_0_0_redis_method_connection_srem(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *key, http_trigger_list_string_t *values, uint32_t *ret, fermyon_spin_2_0_0_redis_error_t *err); +// Execute an arbitrary Redis command and receive the result. +extern bool fermyon_spin_2_0_0_redis_method_connection_execute(fermyon_spin_2_0_0_redis_borrow_connection_t self, http_trigger_string_t *command, fermyon_spin_2_0_0_redis_list_redis_parameter_t *arguments, fermyon_spin_2_0_0_redis_list_redis_result_t *ret, fermyon_spin_2_0_0_redis_error_t *err); + +// Imported Functions from `fermyon:spin/mqtt@2.0.0` +// Open a connection to the Mqtt instance at `address`. +extern bool fermyon_spin_2_0_0_mqtt_static_connection_open(http_trigger_string_t *address, http_trigger_string_t *username, http_trigger_string_t *password, uint64_t keep_alive_interval_in_secs, fermyon_spin_2_0_0_mqtt_own_connection_t *ret, fermyon_spin_2_0_0_mqtt_error_t *err); +// Publish an Mqtt message to the specified `topic`. +extern bool fermyon_spin_2_0_0_mqtt_method_connection_publish(fermyon_spin_2_0_0_mqtt_borrow_connection_t self, http_trigger_string_t *topic, fermyon_spin_2_0_0_mqtt_payload_t *payload, fermyon_spin_2_0_0_mqtt_qos_t qos, fermyon_spin_2_0_0_mqtt_error_t *err); + +// Imported Functions from `fermyon:spin/postgres@2.0.0` +// Open a connection to the Postgres instance at `address`. +extern bool fermyon_spin_2_0_0_postgres_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_postgres_own_connection_t *ret, fermyon_spin_2_0_0_postgres_error_t *err); +// Query the database. +extern bool fermyon_spin_2_0_0_postgres_method_connection_query(fermyon_spin_2_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_postgres_list_parameter_value_t *params, fermyon_spin_2_0_0_postgres_row_set_t *ret, fermyon_spin_2_0_0_postgres_error_t *err); +// Execute command to the database. +extern bool fermyon_spin_2_0_0_postgres_method_connection_execute(fermyon_spin_2_0_0_postgres_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_postgres_list_parameter_value_t *params, uint64_t *ret, fermyon_spin_2_0_0_postgres_error_t *err); + +// Imported Functions from `fermyon:spin/mysql@2.0.0` +// Open a connection to the MySQL instance at `address`. +extern bool fermyon_spin_2_0_0_mysql_static_connection_open(http_trigger_string_t *address, fermyon_spin_2_0_0_mysql_own_connection_t *ret, fermyon_spin_2_0_0_mysql_error_t *err); +// query the database: select +extern bool fermyon_spin_2_0_0_mysql_method_connection_query(fermyon_spin_2_0_0_mysql_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_mysql_list_parameter_value_t *params, fermyon_spin_2_0_0_mysql_row_set_t *ret, fermyon_spin_2_0_0_mysql_error_t *err); +// execute command to the database: insert, update, delete +extern bool fermyon_spin_2_0_0_mysql_method_connection_execute(fermyon_spin_2_0_0_mysql_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_mysql_list_parameter_value_t *params, fermyon_spin_2_0_0_mysql_error_t *err); + +// Imported Functions from `fermyon:spin/sqlite@2.0.0` +// Open a connection to a named database instance. +// +// If `database` is "default", the default instance is opened. +// +// `error::no-such-database` will be raised if the `name` is not recognized. +extern bool fermyon_spin_2_0_0_sqlite_static_connection_open(http_trigger_string_t *database, fermyon_spin_2_0_0_sqlite_own_connection_t *ret, fermyon_spin_2_0_0_sqlite_error_t *err); +// Execute a statement returning back data if there is any +extern bool fermyon_spin_2_0_0_sqlite_method_connection_execute(fermyon_spin_2_0_0_sqlite_borrow_connection_t self, http_trigger_string_t *statement, fermyon_spin_2_0_0_sqlite_list_value_t *parameters, fermyon_spin_2_0_0_sqlite_query_result_t *ret, fermyon_spin_2_0_0_sqlite_error_t *err); + +// Imported Functions from `fermyon:spin/key-value@2.0.0` +// Open the store with the specified label. +// +// `label` must refer to a store allowed in the spin.toml manifest. +// +// `error::no-such-store` will be raised if the `label` is not recognized. +extern bool fermyon_spin_2_0_0_key_value_static_store_open(http_trigger_string_t *label, fermyon_spin_2_0_0_key_value_own_store_t *ret, fermyon_spin_2_0_0_key_value_error_t *err); +// Get the value associated with the specified `key` +// +// Returns `ok(none)` if the key does not exist. +extern bool fermyon_spin_2_0_0_key_value_method_store_get(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, http_trigger_option_list_u8_t *ret, fermyon_spin_2_0_0_key_value_error_t *err); +// Set the `value` associated with the specified `key` overwriting any existing value. +extern bool fermyon_spin_2_0_0_key_value_method_store_set(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, http_trigger_list_u8_t *value, fermyon_spin_2_0_0_key_value_error_t *err); +// Delete the tuple with the specified `key` +// +// No error is raised if a tuple did not previously exist for `key`. +extern bool fermyon_spin_2_0_0_key_value_method_store_delete(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, fermyon_spin_2_0_0_key_value_error_t *err); +// Return whether a tuple exists for the specified `key` +extern bool fermyon_spin_2_0_0_key_value_method_store_exists(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_string_t *key, bool *ret, fermyon_spin_2_0_0_key_value_error_t *err); +// Return a list of all the keys +extern bool fermyon_spin_2_0_0_key_value_method_store_get_keys(fermyon_spin_2_0_0_key_value_borrow_store_t self, http_trigger_list_string_t *ret, fermyon_spin_2_0_0_key_value_error_t *err); + +// Imported Functions from `fermyon:spin/variables@2.0.0` +// Get an application variable value for the current component. +// +// The name must match one defined in in the component manifest. +extern bool fermyon_spin_2_0_0_variables_get(http_trigger_string_t *name, http_trigger_string_t *ret, fermyon_spin_2_0_0_variables_error_t *err); + +// Imported Functions from `wasi:cli/environment@0.2.0` +// Get the POSIX-style environment variables. +// +// Each environment variable is provided as a pair of string variable names +// and string value. +// +// Morally, these are a value import, but until value imports are available +// in the component model, this import function should return the same +// values each time it is called. +extern void wasi_cli_0_2_0_environment_get_environment(http_trigger_list_tuple2_string_string_t *ret); +// Get the POSIX-style arguments to the program. +extern void wasi_cli_0_2_0_environment_get_arguments(http_trigger_list_string_t *ret); +// Return a path that programs should use as their initial current working +// directory, interpreting `.` as shorthand for this. +extern bool wasi_cli_0_2_0_environment_initial_cwd(http_trigger_string_t *ret); + +// Imported Functions from `wasi:cli/exit@0.2.0` +// Exit the current instance and any linked instances. +extern void wasi_cli_0_2_0_exit_exit(wasi_cli_0_2_0_exit_result_void_void_t *status); + +// Imported Functions from `wasi:cli/stdin@0.2.0` +extern wasi_cli_0_2_0_stdin_own_input_stream_t wasi_cli_0_2_0_stdin_get_stdin(void); + +// Imported Functions from `wasi:cli/stdout@0.2.0` +extern wasi_cli_0_2_0_stdout_own_output_stream_t wasi_cli_0_2_0_stdout_get_stdout(void); + +// Imported Functions from `wasi:cli/stderr@0.2.0` +extern wasi_cli_0_2_0_stderr_own_output_stream_t wasi_cli_0_2_0_stderr_get_stderr(void); + +// Imported Functions from `wasi:cli/terminal-stdin@0.2.0` +// If stdin is connected to a terminal, return a `terminal-input` handle +// allowing further interaction with it. +extern bool wasi_cli_0_2_0_terminal_stdin_get_terminal_stdin(wasi_cli_0_2_0_terminal_stdin_own_terminal_input_t *ret); + +// Imported Functions from `wasi:cli/terminal-stdout@0.2.0` +// If stdout is connected to a terminal, return a `terminal-output` handle +// allowing further interaction with it. +extern bool wasi_cli_0_2_0_terminal_stdout_get_terminal_stdout(wasi_cli_0_2_0_terminal_stdout_own_terminal_output_t *ret); + +// Imported Functions from `wasi:cli/terminal-stderr@0.2.0` +// If stderr is connected to a terminal, return a `terminal-output` handle +// allowing further interaction with it. +extern bool wasi_cli_0_2_0_terminal_stderr_get_terminal_stderr(wasi_cli_0_2_0_terminal_stderr_own_terminal_output_t *ret); + +// Imported Functions from `wasi:clocks/wall-clock@0.2.0` +// Read the current value of the clock. +// +// This clock is not monotonic, therefore calling this function repeatedly +// will not necessarily produce a sequence of non-decreasing values. +// +// The returned timestamps represent the number of seconds since +// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], +// also known as [Unix Time]. +// +// The nanoseconds field of the output is always less than 1000000000. +// +// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 +// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time +extern void wasi_clocks_0_2_0_wall_clock_now(wasi_clocks_0_2_0_wall_clock_datetime_t *ret); +// Query the resolution of the clock. +// +// The nanoseconds field of the output is always less than 1000000000. +extern void wasi_clocks_0_2_0_wall_clock_resolution(wasi_clocks_0_2_0_wall_clock_datetime_t *ret); + +// Imported Functions from `wasi:filesystem/types@0.2.0` +// Return a stream for reading from a file, if available. +// +// May fail with an error-code describing why the file cannot be read. +// +// Multiple read, write, and append streams may be active on the same open +// file and they do not interfere with each other. +// +// Note: This allows using `read-stream`, which is similar to `read` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_read_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_own_input_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Return a stream for writing to a file, if available. +// +// May fail with an error-code describing why the file cannot be written. +// +// Note: This allows using `write-stream`, which is similar to `write` in +// POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_write_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Return a stream for appending to a file, if available. +// +// May fail with an error-code describing why the file cannot be appended. +// +// Note: This allows using `write-stream`, which is similar to `write` with +// `O_APPEND` in in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_append_via_stream(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Provide file advisory information on a descriptor. +// +// This is similar to `posix_fadvise` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_advise(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_filesize_t length, wasi_filesystem_0_2_0_types_advice_t advice, wasi_filesystem_0_2_0_types_error_code_t *err); +// Synchronize the data of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fdatasync` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_sync_data(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_error_code_t *err); +// Get flags associated with a descriptor. +// +// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. +// +// Note: This returns the value that was the `fs_flags` value returned +// from `fdstat_get` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_get_flags(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_flags_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Get the dynamic type of a descriptor. +// +// Note: This returns the same value as the `type` field of the `fd-stat` +// returned by `stat`, `stat-at` and similar. +// +// Note: This returns similar flags to the `st_mode & S_IFMT` value provided +// by `fstat` in POSIX. +// +// Note: This returns the value that was the `fs_filetype` value returned +// from `fdstat_get` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_get_type(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_type_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Adjust the size of an open file. If this increases the file's size, the +// extra bytes are filled with zeros. +// +// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_set_size(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t size, wasi_filesystem_0_2_0_types_error_code_t *err); +// Adjust the timestamps of an open file or directory. +// +// Note: This is similar to `futimens` in POSIX. +// +// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_set_times(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_types_error_code_t *err); +// Read from a descriptor, without using and updating the descriptor's offset. +// +// This function returns a list of bytes containing the data that was +// read, along with a bool which, when true, indicates that the end of the +// file was reached. The returned list will contain up to `length` bytes; it +// may return fewer than requested, if the end of the file is reached or +// if the I/O operation is interrupted. +// +// In the future, this may change to return a `stream`. +// +// Note: This is similar to `pread` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_read(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_filesize_t length, wasi_filesystem_0_2_0_types_filesize_t offset, http_trigger_tuple2_list_u8_bool_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Write to a descriptor, without using and updating the descriptor's offset. +// +// It is valid to write past the end of a file; the file is extended to the +// extent of the write, with bytes between the previous end and the start of +// the write set to zero. +// +// In the future, this may change to take a `stream`. +// +// Note: This is similar to `pwrite` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_write(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_list_u8_t *buffer, wasi_filesystem_0_2_0_types_filesize_t offset, wasi_filesystem_0_2_0_types_filesize_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Read directory entries from a directory. +// +// On filesystems where directories contain entries referring to themselves +// and their parents, often named `.` and `..` respectively, these entries +// are omitted. +// +// This always returns a new stream which starts at the beginning of the +// directory. Multiple streams may be active on the same directory, and they +// do not interfere with each other. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_read_directory(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_own_directory_entry_stream_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Synchronize the data and metadata of a file to disk. +// +// This function succeeds with no effect if the file descriptor is not +// opened for writing. +// +// Note: This is similar to `fsync` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_sync(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_error_code_t *err); +// Create a directory. +// +// Note: This is similar to `mkdirat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_create_directory_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Return the attributes of an open file or directory. +// +// Note: This is similar to `fstat` in POSIX, except that it does not return +// device and inode information. For testing whether two descriptors refer to +// the same underlying filesystem object, use `is-same-object`. To obtain +// additional data that can be used do determine whether a file has been +// modified, use `metadata-hash`. +// +// Note: This was called `fd_filestat_get` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_stat(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Return the attributes of a file or directory. +// +// Note: This is similar to `fstatat` in POSIX, except that it does not +// return device and inode information. See the `stat` description for a +// discussion of alternatives. +// +// Note: This was called `path_filestat_get` in earlier versions of WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_stat_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Adjust the timestamps of a file or directory. +// +// Note: This is similar to `utimensat` in POSIX. +// +// Note: This was called `path_filestat_set_times` in earlier versions of +// WASI. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_set_times_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_types_error_code_t *err); +// Create a hard link. +// +// Note: This is similar to `linkat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_link_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t old_path_flags, http_trigger_string_t *old_path, wasi_filesystem_0_2_0_types_borrow_descriptor_t new_descriptor, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Open a file or directory. +// +// The returned descriptor is not guaranteed to be the lowest-numbered +// descriptor not currently open/ it is randomized to prevent applications +// from depending on making assumptions about indexes, since this is +// error-prone in multi-threaded contexts. The returned descriptor is +// guaranteed to be less than 2**31. +// +// If `flags` contains `descriptor-flags::mutate-directory`, and the base +// descriptor doesn't have `descriptor-flags::mutate-directory` set, +// `open-at` fails with `error-code::read-only`. +// +// If `flags` contains `write` or `mutate-directory`, or `open-flags` +// contains `truncate` or `create`, and the base descriptor doesn't have +// `descriptor-flags::mutate-directory` set, `open-at` fails with +// `error-code::read-only`. +// +// Note: This is similar to `openat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_open_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_open_flags_t open_flags, wasi_filesystem_0_2_0_types_descriptor_flags_t flags, wasi_filesystem_0_2_0_types_own_descriptor_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Read the contents of a symbolic link. +// +// If the contents contain an absolute or rooted path in the underlying +// filesystem, this function fails with `error-code::not-permitted`. +// +// Note: This is similar to `readlinkat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_readlink_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, http_trigger_string_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Remove a directory. +// +// Return `error-code::not-empty` if the directory is not empty. +// +// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_remove_directory_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Rename a filesystem object. +// +// Note: This is similar to `renameat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_rename_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *old_path, wasi_filesystem_0_2_0_types_borrow_descriptor_t new_descriptor, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Create a symbolic link (also known as a "symlink"). +// +// If `old-path` starts with `/`, the function fails with +// `error-code::not-permitted`. +// +// Note: This is similar to `symlinkat` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_symlink_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *old_path, http_trigger_string_t *new_path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Unlink a filesystem object that is not a directory. +// +// Return `error-code::is-directory` if the path refers to a directory. +// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_unlink_file_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_error_code_t *err); +// Test whether two descriptors refer to the same filesystem object. +// +// In POSIX, this corresponds to testing whether the two descriptors have the +// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. +// wasi-filesystem does not expose device and inode numbers, so this function +// may be used instead. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_is_same_object(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_borrow_descriptor_t other); +// Return a hash of the metadata associated with a filesystem object referred +// to by a descriptor. +// +// This returns a hash of the last-modification timestamp and file size, and +// may also include the inode number, device number, birth timestamp, and +// other metadata fields that may change when the file is modified or +// replaced. It may also include a secret value chosen by the +// implementation and not otherwise exposed. +// +// Implementations are encourated to provide the following properties: +// +// - If the file is not modified or replaced, the computed hash value should +// usually not change. +// - If the object is modified or replaced, the computed hash value should +// usually change. +// - The inputs to the hash should not be easily computable from the +// computed hash. +// +// However, none of these is required. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Return a hash of the metadata associated with a filesystem object referred +// to by a directory descriptor and a relative path. +// +// This performs the same hash computation as `metadata-hash`. +extern bool wasi_filesystem_0_2_0_types_method_descriptor_metadata_hash_at(wasi_filesystem_0_2_0_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_types_path_flags_t path_flags, http_trigger_string_t *path, wasi_filesystem_0_2_0_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Read a single directory entry from a `directory-entry-stream`. +extern bool wasi_filesystem_0_2_0_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t self, wasi_filesystem_0_2_0_types_option_directory_entry_t *ret, wasi_filesystem_0_2_0_types_error_code_t *err); +// Attempts to extract a filesystem-related `error-code` from the stream +// `error` provided. +// +// Stream operations which return `stream-error::last-operation-failed` +// have a payload with more information about the operation that failed. +// This payload can be passed through to this function to see if there's +// filesystem-related information about the error to return. +// +// Note that this function is fallible because not all stream-related +// errors are filesystem-related errors. +extern bool wasi_filesystem_0_2_0_types_filesystem_error_code(wasi_filesystem_0_2_0_types_borrow_error_t err_, wasi_filesystem_0_2_0_types_error_code_t *ret); + +// Imported Functions from `wasi:filesystem/preopens@0.2.0` +// Return the set of preopened directories, and their path. +extern void wasi_filesystem_0_2_0_preopens_get_directories(wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t *ret); + +// Imported Functions from `wasi:sockets/instance-network@0.2.0` +// Get a handle to the default network. +extern wasi_sockets_0_2_0_instance_network_own_network_t wasi_sockets_0_2_0_instance_network_instance_network(void); + +// Imported Functions from `wasi:sockets/udp@0.2.0` +// Bind the socket to a specific network on the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which +// network interface(s) to bind to. +// If the port is zero, the socket will be bound to a random free port. +// +// # Typical errors +// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) +// - `address-in-use`: Address is already in use. (EADDRINUSE) +// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) +// - `not-in-progress`: A `bind` operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// Unlike in POSIX, in WASI the bind operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `bind` as part of either `start-bind` or `finish-bind`. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_start_bind(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_borrow_network_t network, wasi_sockets_0_2_0_udp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_udp_error_code_t *err); +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_finish_bind(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_error_code_t *err); +// Set up inbound & outbound communication channels, optionally to a specific peer. +// +// This function only changes the local socket configuration and does not generate any network traffic. +// On success, the `remote-address` of the socket is updated. The `local-address` may be updated as well, +// based on the best network path to `remote-address`. +// +// When a `remote-address` is provided, the returned streams are limited to communicating with that specific peer: +// - `send` can only be used to send to this destination. +// - `receive` will only return datagrams sent from the provided `remote-address`. +// +// This method may be called multiple times on the same socket to change its association, but +// only the most recently returned pair of streams will be operational. Implementations may trap if +// the streams returned by a previous invocation haven't been dropped yet before calling `stream` again. +// +// The POSIX equivalent in pseudo-code is: +// ```text +// if (was previously connected) { +// connect(s, AF_UNSPEC) +// } +// if (remote_address is Some) { +// connect(s, remote_address) +// } +// ``` +// +// Unlike in POSIX, the socket must already be explicitly bound. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-state`: The socket is not bound. +// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_stream(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_0_2_0_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Get the current bound address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_local_address(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Get the address the socket is currently streaming to. +// +// # Typical errors +// - `invalid-state`: The socket is not streaming to a specific remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_remote_address(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Whether this is a IPv4 or IPv6 socket. +// +// Equivalent to the SO_DOMAIN socket option. +extern wasi_sockets_0_2_0_udp_ip_address_family_t wasi_sockets_0_2_0_udp_method_udp_socket_address_family(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self); +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_0_2_0_udp_error_code_t *err); +// The kernel buffer space reserved for sends/receives on this socket. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// I.e. after setting a value, reading the same setting back may return a different value. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_receive_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_udp_error_code_t *err); +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_send_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +extern bool wasi_sockets_0_2_0_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_udp_error_code_t *err); +// Create a `pollable` which will resolve once the socket is ready for I/O. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +extern wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_udp_socket_subscribe(wasi_sockets_0_2_0_udp_borrow_udp_socket_t self); +// Receive messages on the socket. +// +// This function attempts to receive up to `max-results` datagrams on the socket without blocking. +// The returned list may contain fewer elements than requested, but never more. +// +// This function returns successfully with an empty list when either: +// - `max-results` is 0, or: +// - `max-results` is greater than 0, but no results are immediately available. +// This function never returns `error(would-block)`. +// +// # Typical errors +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_receive(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_0_2_0_udp_list_incoming_datagram_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Create a `pollable` which will resolve once the stream is ready to receive again. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +extern wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t self); +// Check readiness for sending. This function never blocks. +// +// Returns the number of datagrams permitted for the next call to `send`, +// or an error. Calling `send` with more datagrams than this function has +// permitted will trap. +// +// When this function returns ok(0), the `subscribe` pollable will +// become ready when this function will report at least ok(1), or an +// error. +// +// Never returns `would-block`. +extern bool wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Send messages on the socket. +// +// This function attempts to send all provided `datagrams` on the socket without blocking and +// returns how many messages were actually sent (or queued for sending). This function never +// returns `error(would-block)`. If none of the datagrams were able to be sent, `ok(0)` is returned. +// +// This function semantically behaves the same as iterating the `datagrams` list and sequentially +// sending each individual datagram until either the end of the list has been reached or the first error occurred. +// If at least one datagram has been sent successfully, this function never returns an error. +// +// If the input list is empty, the function returns `ok(0)`. +// +// Each call to `send` must be permitted by a preceding `check-send`. Implementations must trap if +// either `check-send` was not called or `datagrams` contains more items than `check-send` permitted. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) +// - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` value that does not match the address passed to `stream`. (EISCONN) +// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) +// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `connection-refused`: The connection was refused. (ECONNREFUSED) +// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) +// +// # References +// - +// - +// - +// - +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_send(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_0_2_0_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_0_2_0_udp_error_code_t *err); +// Create a `pollable` which will resolve once the stream is ready to send again. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +extern wasi_sockets_0_2_0_udp_own_pollable_t wasi_sockets_0_2_0_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t self); + +// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0` +// Create a new UDP socket. +// +// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX. +// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. +// +// This function does not require a network capability handle. This is considered to be safe because +// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is called, +// the socket is effectively an in-memory configuration object, unable to communicate with the outside world. +// +// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. +// +// # Typical errors +// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) +// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) +// +// # References: +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_udp_create_socket_create_udp_socket(wasi_sockets_0_2_0_udp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_0_2_0_udp_create_socket_error_code_t *err); + +// Imported Functions from `wasi:sockets/tcp@0.2.0` +// Bind the socket to a specific network on the provided IP address and port. +// +// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which +// network interface(s) to bind to. +// If the TCP/UDP port is zero, the socket will be bound to a random free port. +// +// Bind can be attempted multiple times on the same socket, even with +// different arguments on each iteration. But never concurrently and +// only as long as the previous bind failed. Once a bind succeeds, the +// binding can't be changed anymore. +// +// # Typical errors +// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) +// - `invalid-argument`: `local-address` is not a unicast address. (EINVAL) +// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL) +// - `invalid-state`: The socket is already bound. (EINVAL) +// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) +// - `address-in-use`: Address is already in use. (EADDRINUSE) +// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) +// - `not-in-progress`: A `bind` operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT +// state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR +// socket option should be set implicitly on all platforms, except on Windows where this is the default behavior +// and SO_REUSEADDR performs something different entirely. +// +// Unlike in POSIX, in WASI the bind operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `bind` as part of either `start-bind` or `finish-bind`. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_bind(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_borrow_network_t network, wasi_sockets_0_2_0_tcp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_bind(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Connect to a remote endpoint. +// +// On success: +// - the socket is transitioned into the `connection` state. +// - a pair of streams is returned that can be used to read & write to the connection +// +// After a failed connection attempt, the socket will be in the `closed` +// state and the only valid action left is to `drop` the socket. A single +// socket can not be used to connect more than once. +// +// # Typical errors +// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) +// - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS) +// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos) +// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows) +// - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows) +// - `invalid-argument`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`. +// - `invalid-state`: The socket is already in the `connected` state. (EISCONN) +// - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows) +// - `timeout`: Connection timed out. (ETIMEDOUT) +// - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED) +// - `connection-reset`: The connection was reset. (ECONNRESET) +// - `connection-aborted`: The connection was aborted. (ECONNABORTED) +// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) +// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) +// - `not-in-progress`: A connect operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// The POSIX equivalent of `start-connect` is the regular `connect` syscall. +// Because all WASI sockets are non-blocking this is expected to return +// EINPROGRESS, which should be translated to `ok()` in WASI. +// +// The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT` +// with a timeout of 0 on the socket descriptor. Followed by a check for +// the `SO_ERROR` socket option, in case the poll signaled readiness. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_connect(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_borrow_network_t network, wasi_sockets_0_2_0_tcp_ip_socket_address_t *remote_address, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_connect(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Start listening for new connections. +// +// Transitions the socket into the `listening` state. +// +// Unlike POSIX, the socket must already be explicitly bound. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ) +// - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD) +// - `invalid-state`: The socket is already in the `listening` state. +// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) +// - `not-in-progress`: A listen operation is not in progress. +// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) +// +// # Implementors note +// Unlike in POSIX, in WASI the listen operation is async. This enables +// interactive WASI hosts to inject permission prompts. Runtimes that +// don't want to make use of this ability can simply call the native +// `listen` as part of either `start-listen` or `finish-listen`. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_start_listen(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_finish_listen(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Accept a new client socket. +// +// The returned socket is bound and in the `connected` state. The following properties are inherited from the listener socket: +// - `address-family` +// - `keep-alive-enabled` +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// - `hop-limit` +// - `receive-buffer-size` +// - `send-buffer-size` +// +// On success, this function returns the newly accepted client socket along with +// a pair of streams that can be used to read & write to the connection. +// +// # Typical errors +// - `invalid-state`: Socket is not in the `listening` state. (EINVAL) +// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN) +// - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED) +// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_accept(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Get the bound local address. +// +// POSIX mentions: +// > If the socket has not been bound to a local name, the value +// > stored in the object pointed to by `address` is unspecified. +// +// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. +// +// # Typical errors +// - `invalid-state`: The socket is not bound to any local address. +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_local_address(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Get the remote address. +// +// # Typical errors +// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_remote_address(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Whether the socket is in the `listening` state. +// +// Equivalent to the SO_ACCEPTCONN socket option. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_is_listening(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self); +// Whether this is a IPv4 or IPv6 socket. +// +// Equivalent to the SO_DOMAIN socket option. +extern wasi_sockets_0_2_0_tcp_ip_address_family_t wasi_sockets_0_2_0_tcp_method_tcp_socket_address_family(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self); +// Hints the desired listen queue size. Implementations are free to ignore this. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// +// # Typical errors +// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. +// - `invalid-argument`: (set) The provided value was 0. +// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Enables or disables keepalive. +// +// The keepalive behavior can be adjusted using: +// - `keep-alive-idle-time` +// - `keep-alive-interval` +// - `keep-alive-count` +// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. +// +// Equivalent to the SO_KEEPALIVE socket option. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Amount of time the connection has to be idle before TCP starts sending keepalive packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// I.e. after setting a value, reading the same setting back may return a different value. +// +// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// The time between keepalive packets. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// I.e. after setting a value, reading the same setting back may return a different value. +// +// Equivalent to the TCP_KEEPINTVL socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_duration_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// The maximum amount of keepalive packets TCP should send before aborting the connection. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// I.e. after setting a value, reading the same setting back may return a different value. +// +// Equivalent to the TCP_KEEPCNT socket option. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// +// # Typical errors +// - `invalid-argument`: (set) The TTL value must be 1 or higher. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_hop_limit(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// The kernel buffer space reserved for sends/receives on this socket. +// +// If the provided value is 0, an `invalid-argument` error is returned. +// Any other value will never cause an error, but it might be silently clamped and/or rounded. +// I.e. after setting a value, reading the same setting back may return a different value. +// +// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. +// +// # Typical errors +// - `invalid-argument`: (set) The provided value was 0. +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_tcp_error_code_t *err); +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_tcp_error_code_t *err); +// Create a `pollable` which can be used to poll for, or block on, +// completion of any of the asynchronous operations of this socket. +// +// When `finish-bind`, `finish-listen`, `finish-connect` or `accept` +// return `error(would-block)`, this pollable can be used to wait for +// their success or failure, after which the method can be retried. +// +// The pollable is not limited to the async operation that happens to be +// in progress at the time of calling `subscribe` (if any). Theoretically, +// `subscribe` only has to be called once per socket and can then be +// (re)used for the remainder of the socket's lifetime. +// +// See +// for a more information. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +extern wasi_sockets_0_2_0_tcp_own_pollable_t wasi_sockets_0_2_0_tcp_method_tcp_socket_subscribe(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self); +// Initiate a graceful shutdown. +// +// - `receive`: The socket is not expecting to receive any data from +// the peer. The `input-stream` associated with this socket will be +// closed. Any data still in the receive queue at time of calling +// this method will be discarded. +// - `send`: The socket has no more data to send to the peer. The `output-stream` +// associated with this socket will be closed and a FIN packet will be sent. +// - `both`: Same effect as `receive` & `send` combined. +// +// This function is idempotent. Shutting a down a direction more than once +// has no effect and returns `ok`. +// +// The shutdown function does not close (drop) the socket. +// +// # Typical errors +// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_method_tcp_socket_shutdown(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_tcp_shutdown_type_t shutdown_type, wasi_sockets_0_2_0_tcp_error_code_t *err); + +// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0` +// Create a new TCP socket. +// +// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. +// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. +// +// This function does not require a network capability handle. This is considered to be safe because +// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect` +// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world. +// +// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. +// +// # Typical errors +// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) +// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) +// +// # References +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_tcp_create_socket_create_tcp_socket(wasi_sockets_0_2_0_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_0_2_0_tcp_create_socket_error_code_t *err); + +// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0` +// Resolve an internet host name to a list of IP addresses. +// +// Unicode domain names are automatically converted to ASCII using IDNA encoding. +// If the input is an IP address string, the address is parsed and returned +// as-is without making any external requests. +// +// See the wasi-socket proposal README.md for a comparison with getaddrinfo. +// +// This function never blocks. It either immediately fails or immediately +// returns successfully with a `resolve-address-stream` that can be used +// to (asynchronously) fetch the results. +// +// # Typical errors +// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. +// +// # References: +// - +// - +// - +// - +extern bool wasi_sockets_0_2_0_ip_name_lookup_resolve_addresses(wasi_sockets_0_2_0_ip_name_lookup_borrow_network_t network, http_trigger_string_t *name, wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_0_2_0_ip_name_lookup_error_code_t *err); +// Returns the next address from the resolver. +// +// This function should be called multiple times. On each call, it will +// return the next address in connection order preference. If all +// addresses have been exhausted, this function returns `none`. +// +// This function never returns IPv4-mapped IPv6 addresses. +// +// # Typical errors +// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) +// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) +// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) +// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) +extern bool wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_0_2_0_ip_name_lookup_error_code_t *err); +// Create a `pollable` which will resolve once the stream is ready for I/O. +// +// Note: this function is here for WASI Preview2 only. +// It's planned to be removed when `future` is natively supported in Preview3. +extern wasi_sockets_0_2_0_ip_name_lookup_own_pollable_t wasi_sockets_0_2_0_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t self); + +// Imported Functions from `wasi:random/random@0.2.0` +// Return `len` cryptographically-secure random or pseudo-random bytes. +// +// This function must produce data at least as cryptographically secure and +// fast as an adequately seeded cryptographically-secure pseudo-random +// number generator (CSPRNG). It must not block, from the perspective of +// the calling program, under any circumstances, including on the first +// request and on requests for numbers of bytes. The returned data must +// always be unpredictable. +// +// This function must always return fresh data. Deterministic environments +// must omit this function, rather than implementing it with deterministic +// data. +extern void wasi_random_0_2_0_random_get_random_bytes(uint64_t len, http_trigger_list_u8_t *ret); +// Return a cryptographically-secure random or pseudo-random `u64` value. +// +// This function returns the same type of data as `get-random-bytes`, +// represented as a `u64`. +extern uint64_t wasi_random_0_2_0_random_get_random_u64(void); + +// Imported Functions from `wasi:random/insecure@0.2.0` +// Return `len` insecure pseudo-random bytes. +// +// This function is not cryptographically secure. Do not use it for +// anything related to security. +// +// There are no requirements on the values of the returned bytes, however +// implementations are encouraged to return evenly distributed values with +// a long period. +extern void wasi_random_0_2_0_insecure_get_insecure_random_bytes(uint64_t len, http_trigger_list_u8_t *ret); +// Return an insecure pseudo-random `u64` value. +// +// This function returns the same type of pseudo-random data as +// `get-insecure-random-bytes`, represented as a `u64`. +extern uint64_t wasi_random_0_2_0_insecure_get_insecure_random_u64(void); + +// Imported Functions from `wasi:random/insecure-seed@0.2.0` +// Return a 128-bit value that may contain a pseudo-random value. +// +// The returned value is not required to be computed from a CSPRNG, and may +// even be entirely deterministic. Host implementations are encouraged to +// provide pseudo-random values to any program exposed to +// attacker-controlled content, to enable DoS protection built into many +// languages' hash-map implementations. +// +// This function is intended to only be called once, by a source language +// to initialize Denial Of Service (DoS) protection in its hash-map +// implementation. +// +// # Expected future evolution +// +// This will likely be changed to a value import, to prevent it from being +// called multiple times and potentially used for purposes other than DoS +// protection. +extern void wasi_random_0_2_0_insecure_seed_insecure_seed(http_trigger_tuple2_u64_u64_t *ret); + +// Imported Functions from `wasi:keyvalue/store@0.2.0-draft2` +// Get the bucket with the specified identifier. +// +// `identifier` must refer to a bucket provided by the host. +// +// `error::no-such-store` will be raised if the `identifier` is not recognized. +extern bool wasi_keyvalue_store_open(http_trigger_string_t *identifier, wasi_keyvalue_store_own_bucket_t *ret, wasi_keyvalue_store_error_t *err); +// Get the value associated with the specified `key` +// +// The value is returned as an option. If the key-value pair exists in the +// store, it returns `Ok(value)`. If the key does not exist in the +// store, it returns `Ok(none)`. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_store_method_bucket_get(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, http_trigger_option_list_u8_t *ret, wasi_keyvalue_store_error_t *err); +// Set the value associated with the key in the store. If the key already +// exists in the store, it overwrites the value. +// +// If the key does not exist in the store, it creates a new key-value pair. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_store_method_bucket_set(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, http_trigger_list_u8_t *value, wasi_keyvalue_store_error_t *err); +// Delete the key-value pair associated with the key in the store. +// +// If the key does not exist in the store, it does nothing. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_store_method_bucket_delete(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, wasi_keyvalue_store_error_t *err); +// Check if the key exists in the store. +// +// If the key exists in the store, it returns `Ok(true)`. If the key does +// not exist in the store, it returns `Ok(false)`. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_store_method_bucket_exists(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *key, bool *ret, wasi_keyvalue_store_error_t *err); +// Get all the keys in the store with an optional cursor (for use in pagination). It +// returns a list of keys. Please note that for most KeyValue implementations, this is a +// can be a very expensive operation and so it should be used judiciously. Implementations +// can return any number of keys in a single response, but they should never attempt to +// send more data than is reasonable (i.e. on a small edge device, this may only be a few +// KB, while on a large machine this could be several MB). Any response should also return +// a cursor that can be used to fetch the next page of keys. See the `key-response` record +// for more information. +// +// Note that the keys are not guaranteed to be returned in any particular order. +// +// If the store is empty, it returns an empty list. +// +// MAY show an out-of-date list of keys if there are concurrent writes to the store. +// +// If any error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_store_method_bucket_list_keys(wasi_keyvalue_store_borrow_bucket_t self, http_trigger_string_t *maybe_cursor, wasi_keyvalue_store_key_response_t *ret, wasi_keyvalue_store_error_t *err); + +// Imported Functions from `wasi:keyvalue/atomics@0.2.0-draft2` +// Construct a new CAS operation. Implementors can map the underlying functionality +// (transactions, versions, etc) as desired. +extern bool wasi_keyvalue_atomics_static_cas_new(wasi_keyvalue_atomics_borrow_bucket_t bucket, http_trigger_string_t *key, wasi_keyvalue_atomics_own_cas_t *ret, wasi_keyvalue_atomics_error_t *err); +// Get the current value of the key (if it exists). This allows for avoiding reads if all +// that is needed to ensure the atomicity of the operation +extern bool wasi_keyvalue_atomics_method_cas_current(wasi_keyvalue_atomics_borrow_cas_t self, http_trigger_option_list_u8_t *ret, wasi_keyvalue_atomics_error_t *err); +// Atomically increment the value associated with the key in the store by the given delta. It +// returns the new value. +// +// If the key does not exist in the store, it creates a new key-value pair with the value set +// to the given delta. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_atomics_increment(wasi_keyvalue_atomics_borrow_bucket_t bucket, http_trigger_string_t *key, int64_t delta, int64_t *ret, wasi_keyvalue_atomics_error_t *err); +// Perform the swap on a CAS operation. This consumes the CAS handle and returns an error if +// the CAS operation failed. +extern bool wasi_keyvalue_atomics_swap(wasi_keyvalue_atomics_own_cas_t cas, http_trigger_list_u8_t *value, wasi_keyvalue_atomics_cas_error_t *err); + +// Imported Functions from `wasi:keyvalue/batch@0.2.0-draft2` +// Get the key-value pairs associated with the keys in the store. It returns a list of +// key-value pairs. +// +// If any of the keys do not exist in the store, it returns a `none` value for that pair in the +// list. +// +// MAY show an out-of-date value if there are concurrent writes to the store. +// +// If any other error occurs, it returns an `Err(error)`. +extern bool wasi_keyvalue_batch_get_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_string_t *keys, http_trigger_list_tuple2_string_option_list_u8_t *ret, wasi_keyvalue_batch_error_t *err); +// Set the values associated with the keys in the store. If the key already exists in the +// store, it overwrites the value. +// +// Note that the key-value pairs are not guaranteed to be set in the order they are provided. +// +// If any of the keys do not exist in the store, it creates a new key-value pair. +// +// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not +// rollback the key-value pairs that were already set. Thus, this batch operation does not +// guarantee atomicity, implying that some key-value pairs could be set while others might +// fail. +// +// Other concurrent operations may also be able to see the partial results. +extern bool wasi_keyvalue_batch_set_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_tuple2_string_list_u8_t *key_values, wasi_keyvalue_batch_error_t *err); +// Delete the key-value pairs associated with the keys in the store. +// +// Note that the key-value pairs are not guaranteed to be deleted in the order they are +// provided. +// +// If any of the keys do not exist in the store, it skips the key. +// +// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not +// rollback the key-value pairs that were already deleted. Thus, this batch operation does not +// guarantee atomicity, implying that some key-value pairs could be deleted while others might +// fail. +// +// Other concurrent operations may also be able to see the partial results. +extern bool wasi_keyvalue_batch_delete_many(wasi_keyvalue_batch_borrow_bucket_t bucket, http_trigger_list_string_t *keys, wasi_keyvalue_batch_error_t *err); + +// Exported Functions from `wasi:http/incoming-handler@0.2.0` +void exports_wasi_http_0_2_0_incoming_handler_handle(exports_wasi_http_0_2_0_incoming_handler_own_incoming_request_t request, exports_wasi_http_0_2_0_incoming_handler_own_response_outparam_t response_out); + +// Helper Functions + +void spin_postgres_3_0_0_postgres_error_free(spin_postgres_3_0_0_postgres_error_t *ptr); + +void http_trigger_list_u8_free(http_trigger_list_u8_t *ptr); + +void spin_postgres_3_0_0_postgres_db_value_free(spin_postgres_3_0_0_postgres_db_value_t *ptr); + +void spin_postgres_3_0_0_postgres_parameter_value_free(spin_postgres_3_0_0_postgres_parameter_value_t *ptr); + +void spin_postgres_3_0_0_postgres_column_free(spin_postgres_3_0_0_postgres_column_t *ptr); + +void spin_postgres_3_0_0_postgres_row_free(spin_postgres_3_0_0_postgres_row_t *ptr); + +void spin_postgres_3_0_0_postgres_list_column_free(spin_postgres_3_0_0_postgres_list_column_t *ptr); + +void spin_postgres_3_0_0_postgres_list_row_free(spin_postgres_3_0_0_postgres_list_row_t *ptr); + +void spin_postgres_3_0_0_postgres_row_set_free(spin_postgres_3_0_0_postgres_row_set_t *ptr); + +extern void spin_postgres_3_0_0_postgres_connection_drop_own(spin_postgres_3_0_0_postgres_own_connection_t handle); + +extern void spin_postgres_3_0_0_postgres_connection_drop_borrow(spin_postgres_3_0_0_postgres_borrow_connection_t handle); + +extern spin_postgres_3_0_0_postgres_borrow_connection_t spin_postgres_3_0_0_postgres_borrow_connection(spin_postgres_3_0_0_postgres_own_connection_t handle); + +void spin_postgres_3_0_0_postgres_result_own_connection_error_free(spin_postgres_3_0_0_postgres_result_own_connection_error_t *ptr); + +void spin_postgres_3_0_0_postgres_list_parameter_value_free(spin_postgres_3_0_0_postgres_list_parameter_value_t *ptr); + +void spin_postgres_3_0_0_postgres_result_row_set_error_free(spin_postgres_3_0_0_postgres_result_row_set_error_t *ptr); + +void spin_postgres_3_0_0_postgres_result_u64_error_free(spin_postgres_3_0_0_postgres_result_u64_error_t *ptr); + +void http_trigger_option_string_free(http_trigger_option_string_t *ptr); + +void http_trigger_tuple2_string_string_free(http_trigger_tuple2_string_string_t *ptr); + +void http_trigger_list_tuple2_string_string_free(http_trigger_list_tuple2_string_string_t *ptr); + +void spin_postgres_4_0_0_postgres_db_error_free(spin_postgres_4_0_0_postgres_db_error_t *ptr); + +void spin_postgres_4_0_0_postgres_query_error_free(spin_postgres_4_0_0_postgres_query_error_t *ptr); + +void spin_postgres_4_0_0_postgres_error_free(spin_postgres_4_0_0_postgres_error_t *ptr); + +void spin_postgres_4_0_0_postgres_db_data_type_free(spin_postgres_4_0_0_postgres_db_data_type_t *ptr); + +void spin_postgres_4_0_0_postgres_column_free(spin_postgres_4_0_0_postgres_column_t *ptr); + +void spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_s32_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s32_range_bound_kind_option_tuple2_s32_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_s64_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_s64_range_bound_kind_option_tuple2_s64_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_string_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_option_tuple2_string_range_bound_kind_t *ptr); + +void spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_free(spin_postgres_4_0_0_postgres_tuple2_option_tuple2_string_range_bound_kind_option_tuple2_string_range_bound_kind_t *ptr); + +void http_trigger_option_s32_free(http_trigger_option_s32_t *ptr); + +void http_trigger_list_option_s32_free(http_trigger_list_option_s32_t *ptr); + +void http_trigger_option_s64_free(http_trigger_option_s64_t *ptr); + +void http_trigger_list_option_s64_free(http_trigger_list_option_s64_t *ptr); + +void http_trigger_list_option_string_free(http_trigger_list_option_string_t *ptr); + +void spin_postgres_4_0_0_postgres_db_value_free(spin_postgres_4_0_0_postgres_db_value_t *ptr); + +void spin_postgres_4_0_0_postgres_parameter_value_free(spin_postgres_4_0_0_postgres_parameter_value_t *ptr); + +void spin_postgres_4_0_0_postgres_row_free(spin_postgres_4_0_0_postgres_row_t *ptr); + +void spin_postgres_4_0_0_postgres_list_column_free(spin_postgres_4_0_0_postgres_list_column_t *ptr); + +void spin_postgres_4_0_0_postgres_list_row_free(spin_postgres_4_0_0_postgres_list_row_t *ptr); + +void spin_postgres_4_0_0_postgres_row_set_free(spin_postgres_4_0_0_postgres_row_set_t *ptr); + +extern void spin_postgres_4_0_0_postgres_connection_drop_own(spin_postgres_4_0_0_postgres_own_connection_t handle); + +extern void spin_postgres_4_0_0_postgres_connection_drop_borrow(spin_postgres_4_0_0_postgres_borrow_connection_t handle); + +extern spin_postgres_4_0_0_postgres_borrow_connection_t spin_postgres_4_0_0_postgres_borrow_connection(spin_postgres_4_0_0_postgres_own_connection_t handle); + +void spin_postgres_4_0_0_postgres_result_own_connection_error_free(spin_postgres_4_0_0_postgres_result_own_connection_error_t *ptr); + +void spin_postgres_4_0_0_postgres_list_parameter_value_free(spin_postgres_4_0_0_postgres_list_parameter_value_t *ptr); + +void spin_postgres_4_0_0_postgres_result_row_set_error_free(spin_postgres_4_0_0_postgres_result_row_set_error_t *ptr); + +void spin_postgres_4_0_0_postgres_result_u64_error_free(spin_postgres_4_0_0_postgres_result_u64_error_t *ptr); + +extern void spin_sqlite_sqlite_connection_drop_own(spin_sqlite_sqlite_own_connection_t handle); + +extern void spin_sqlite_sqlite_connection_drop_borrow(spin_sqlite_sqlite_borrow_connection_t handle); + +extern spin_sqlite_sqlite_borrow_connection_t spin_sqlite_sqlite_borrow_connection(spin_sqlite_sqlite_own_connection_t handle); + +void spin_sqlite_sqlite_error_free(spin_sqlite_sqlite_error_t *ptr); + +void spin_sqlite_sqlite_value_free(spin_sqlite_sqlite_value_t *ptr); + +void spin_sqlite_sqlite_list_value_free(spin_sqlite_sqlite_list_value_t *ptr); + +void spin_sqlite_sqlite_row_result_free(spin_sqlite_sqlite_row_result_t *ptr); + +void http_trigger_list_string_free(http_trigger_list_string_t *ptr); + +void spin_sqlite_sqlite_list_row_result_free(spin_sqlite_sqlite_list_row_result_t *ptr); + +void spin_sqlite_sqlite_query_result_free(spin_sqlite_sqlite_query_result_t *ptr); + +void spin_sqlite_sqlite_result_own_connection_error_free(spin_sqlite_sqlite_result_own_connection_error_t *ptr); + +void spin_sqlite_sqlite_result_query_result_error_free(spin_sqlite_sqlite_result_query_result_error_t *ptr); + +void wasi_config_store_error_free(wasi_config_store_error_t *ptr); + +void wasi_config_store_result_option_string_error_free(wasi_config_store_result_option_string_error_t *ptr); + +void wasi_config_store_result_list_tuple2_string_string_error_free(wasi_config_store_result_list_tuple2_string_string_error_t *ptr); + +extern void wasi_io_0_2_0_poll_pollable_drop_own(wasi_io_0_2_0_poll_own_pollable_t handle); + +extern void wasi_io_0_2_0_poll_pollable_drop_borrow(wasi_io_0_2_0_poll_borrow_pollable_t handle); + +extern wasi_io_0_2_0_poll_borrow_pollable_t wasi_io_0_2_0_poll_borrow_pollable(wasi_io_0_2_0_poll_own_pollable_t handle); + +void wasi_io_0_2_0_poll_list_borrow_pollable_free(wasi_io_0_2_0_poll_list_borrow_pollable_t *ptr); + +void http_trigger_list_u32_free(http_trigger_list_u32_t *ptr); + +extern void wasi_io_0_2_0_error_error_drop_own(wasi_io_0_2_0_error_own_error_t handle); + +extern void wasi_io_0_2_0_error_error_drop_borrow(wasi_io_0_2_0_error_borrow_error_t handle); + +extern wasi_io_0_2_0_error_borrow_error_t wasi_io_0_2_0_error_borrow_error(wasi_io_0_2_0_error_own_error_t handle); + +void wasi_io_0_2_0_streams_stream_error_free(wasi_io_0_2_0_streams_stream_error_t *ptr); + +extern void wasi_io_0_2_0_streams_input_stream_drop_own(wasi_io_0_2_0_streams_own_input_stream_t handle); + +extern void wasi_io_0_2_0_streams_input_stream_drop_borrow(wasi_io_0_2_0_streams_borrow_input_stream_t handle); + +extern wasi_io_0_2_0_streams_borrow_input_stream_t wasi_io_0_2_0_streams_borrow_input_stream(wasi_io_0_2_0_streams_own_input_stream_t handle); + +extern void wasi_io_0_2_0_streams_output_stream_drop_own(wasi_io_0_2_0_streams_own_output_stream_t handle); + +extern void wasi_io_0_2_0_streams_output_stream_drop_borrow(wasi_io_0_2_0_streams_borrow_output_stream_t handle); + +extern wasi_io_0_2_0_streams_borrow_output_stream_t wasi_io_0_2_0_streams_borrow_output_stream(wasi_io_0_2_0_streams_own_output_stream_t handle); + +void wasi_io_0_2_0_streams_result_list_u8_stream_error_free(wasi_io_0_2_0_streams_result_list_u8_stream_error_t *ptr); + +void wasi_io_0_2_0_streams_result_u64_stream_error_free(wasi_io_0_2_0_streams_result_u64_stream_error_t *ptr); + +void wasi_io_0_2_0_streams_result_void_stream_error_free(wasi_io_0_2_0_streams_result_void_stream_error_t *ptr); + +void wasi_http_0_2_0_types_method_free(wasi_http_0_2_0_types_method_t *ptr); + +void wasi_http_0_2_0_types_scheme_free(wasi_http_0_2_0_types_scheme_t *ptr); + +void http_trigger_option_u16_free(http_trigger_option_u16_t *ptr); + +void wasi_http_0_2_0_types_dns_error_payload_free(wasi_http_0_2_0_types_dns_error_payload_t *ptr); + +void http_trigger_option_u8_free(http_trigger_option_u8_t *ptr); + +void wasi_http_0_2_0_types_tls_alert_received_payload_free(wasi_http_0_2_0_types_tls_alert_received_payload_t *ptr); + +void http_trigger_option_u32_free(http_trigger_option_u32_t *ptr); + +void wasi_http_0_2_0_types_field_size_payload_free(wasi_http_0_2_0_types_field_size_payload_t *ptr); + +void http_trigger_option_u64_free(http_trigger_option_u64_t *ptr); + +void wasi_http_0_2_0_types_option_field_size_payload_free(wasi_http_0_2_0_types_option_field_size_payload_t *ptr); + +void wasi_http_0_2_0_types_error_code_free(wasi_http_0_2_0_types_error_code_t *ptr); + +void wasi_http_0_2_0_types_header_error_free(wasi_http_0_2_0_types_header_error_t *ptr); + +void wasi_http_0_2_0_types_field_key_free(wasi_http_0_2_0_types_field_key_t *ptr); + +void wasi_http_0_2_0_types_field_value_free(wasi_http_0_2_0_types_field_value_t *ptr); + +extern void wasi_http_0_2_0_types_fields_drop_own(wasi_http_0_2_0_types_own_fields_t handle); + +extern void wasi_http_0_2_0_types_fields_drop_borrow(wasi_http_0_2_0_types_borrow_fields_t handle); + +extern wasi_http_0_2_0_types_borrow_fields_t wasi_http_0_2_0_types_borrow_fields(wasi_http_0_2_0_types_own_fields_t handle); + +extern void wasi_http_0_2_0_types_incoming_request_drop_own(wasi_http_0_2_0_types_own_incoming_request_t handle); + +extern void wasi_http_0_2_0_types_incoming_request_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_request_t handle); + +extern wasi_http_0_2_0_types_borrow_incoming_request_t wasi_http_0_2_0_types_borrow_incoming_request(wasi_http_0_2_0_types_own_incoming_request_t handle); + +extern void wasi_http_0_2_0_types_outgoing_request_drop_own(wasi_http_0_2_0_types_own_outgoing_request_t handle); + +extern void wasi_http_0_2_0_types_outgoing_request_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_request_t handle); + +extern wasi_http_0_2_0_types_borrow_outgoing_request_t wasi_http_0_2_0_types_borrow_outgoing_request(wasi_http_0_2_0_types_own_outgoing_request_t handle); + +extern void wasi_http_0_2_0_types_request_options_drop_own(wasi_http_0_2_0_types_own_request_options_t handle); + +extern void wasi_http_0_2_0_types_request_options_drop_borrow(wasi_http_0_2_0_types_borrow_request_options_t handle); + +extern wasi_http_0_2_0_types_borrow_request_options_t wasi_http_0_2_0_types_borrow_request_options(wasi_http_0_2_0_types_own_request_options_t handle); + +extern void wasi_http_0_2_0_types_response_outparam_drop_own(wasi_http_0_2_0_types_own_response_outparam_t handle); + +extern void wasi_http_0_2_0_types_response_outparam_drop_borrow(wasi_http_0_2_0_types_borrow_response_outparam_t handle); + +extern wasi_http_0_2_0_types_borrow_response_outparam_t wasi_http_0_2_0_types_borrow_response_outparam(wasi_http_0_2_0_types_own_response_outparam_t handle); + +extern void wasi_http_0_2_0_types_incoming_response_drop_own(wasi_http_0_2_0_types_own_incoming_response_t handle); + +extern void wasi_http_0_2_0_types_incoming_response_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_response_t handle); + +extern wasi_http_0_2_0_types_borrow_incoming_response_t wasi_http_0_2_0_types_borrow_incoming_response(wasi_http_0_2_0_types_own_incoming_response_t handle); + +extern void wasi_http_0_2_0_types_incoming_body_drop_own(wasi_http_0_2_0_types_own_incoming_body_t handle); + +extern void wasi_http_0_2_0_types_incoming_body_drop_borrow(wasi_http_0_2_0_types_borrow_incoming_body_t handle); + +extern wasi_http_0_2_0_types_borrow_incoming_body_t wasi_http_0_2_0_types_borrow_incoming_body(wasi_http_0_2_0_types_own_incoming_body_t handle); + +extern void wasi_http_0_2_0_types_future_trailers_drop_own(wasi_http_0_2_0_types_own_future_trailers_t handle); + +extern void wasi_http_0_2_0_types_future_trailers_drop_borrow(wasi_http_0_2_0_types_borrow_future_trailers_t handle); + +extern wasi_http_0_2_0_types_borrow_future_trailers_t wasi_http_0_2_0_types_borrow_future_trailers(wasi_http_0_2_0_types_own_future_trailers_t handle); + +extern void wasi_http_0_2_0_types_outgoing_response_drop_own(wasi_http_0_2_0_types_own_outgoing_response_t handle); + +extern void wasi_http_0_2_0_types_outgoing_response_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_response_t handle); + +extern wasi_http_0_2_0_types_borrow_outgoing_response_t wasi_http_0_2_0_types_borrow_outgoing_response(wasi_http_0_2_0_types_own_outgoing_response_t handle); + +extern void wasi_http_0_2_0_types_outgoing_body_drop_own(wasi_http_0_2_0_types_own_outgoing_body_t handle); + +extern void wasi_http_0_2_0_types_outgoing_body_drop_borrow(wasi_http_0_2_0_types_borrow_outgoing_body_t handle); + +extern wasi_http_0_2_0_types_borrow_outgoing_body_t wasi_http_0_2_0_types_borrow_outgoing_body(wasi_http_0_2_0_types_own_outgoing_body_t handle); + +extern void wasi_http_0_2_0_types_future_incoming_response_drop_own(wasi_http_0_2_0_types_own_future_incoming_response_t handle); + +extern void wasi_http_0_2_0_types_future_incoming_response_drop_borrow(wasi_http_0_2_0_types_borrow_future_incoming_response_t handle); + +extern wasi_http_0_2_0_types_borrow_future_incoming_response_t wasi_http_0_2_0_types_borrow_future_incoming_response(wasi_http_0_2_0_types_own_future_incoming_response_t handle); + +void wasi_http_0_2_0_types_option_error_code_free(wasi_http_0_2_0_types_option_error_code_t *ptr); + +void http_trigger_tuple2_field_key_field_value_free(http_trigger_tuple2_field_key_field_value_t *ptr); + +void http_trigger_list_tuple2_field_key_field_value_free(http_trigger_list_tuple2_field_key_field_value_t *ptr); + +void wasi_http_0_2_0_types_result_own_fields_header_error_free(wasi_http_0_2_0_types_result_own_fields_header_error_t *ptr); + +void http_trigger_list_field_value_free(http_trigger_list_field_value_t *ptr); + +void wasi_http_0_2_0_types_result_void_header_error_free(wasi_http_0_2_0_types_result_void_header_error_t *ptr); + +void wasi_http_0_2_0_types_option_scheme_free(wasi_http_0_2_0_types_option_scheme_t *ptr); + +void wasi_http_0_2_0_types_result_own_incoming_body_void_free(wasi_http_0_2_0_types_result_own_incoming_body_void_t *ptr); + +void wasi_http_0_2_0_types_result_own_outgoing_body_void_free(wasi_http_0_2_0_types_result_own_outgoing_body_void_t *ptr); + +void wasi_http_0_2_0_types_result_void_void_free(wasi_http_0_2_0_types_result_void_void_t *ptr); + +void http_trigger_option_duration_free(http_trigger_option_duration_t *ptr); + +void wasi_http_0_2_0_types_result_own_outgoing_response_error_code_free(wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t *ptr); + +void wasi_http_0_2_0_types_result_own_input_stream_void_free(wasi_http_0_2_0_types_result_own_input_stream_void_t *ptr); + +void wasi_http_0_2_0_types_option_own_trailers_free(wasi_http_0_2_0_types_option_own_trailers_t *ptr); + +void wasi_http_0_2_0_types_result_option_own_trailers_error_code_free(wasi_http_0_2_0_types_result_option_own_trailers_error_code_t *ptr); + +void wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_free(wasi_http_0_2_0_types_result_result_option_own_trailers_error_code_void_t *ptr); + +void wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_free(wasi_http_0_2_0_types_option_result_result_option_own_trailers_error_code_void_t *ptr); + +void wasi_http_0_2_0_types_result_own_output_stream_void_free(wasi_http_0_2_0_types_result_own_output_stream_void_t *ptr); + +void wasi_http_0_2_0_types_result_void_error_code_free(wasi_http_0_2_0_types_result_void_error_code_t *ptr); + +void wasi_http_0_2_0_types_result_own_incoming_response_error_code_free(wasi_http_0_2_0_types_result_own_incoming_response_error_code_t *ptr); + +void wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_free(wasi_http_0_2_0_types_result_result_own_incoming_response_error_code_void_t *ptr); + +void wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_free(wasi_http_0_2_0_types_option_result_result_own_incoming_response_error_code_void_t *ptr); + +void wasi_http_0_2_0_outgoing_handler_error_code_free(wasi_http_0_2_0_outgoing_handler_error_code_t *ptr); + +void wasi_http_0_2_0_outgoing_handler_option_own_request_options_free(wasi_http_0_2_0_outgoing_handler_option_own_request_options_t *ptr); + +void wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_free(wasi_http_0_2_0_outgoing_handler_result_own_future_incoming_response_error_code_t *ptr); + +void fermyon_spin_2_0_0_llm_inferencing_model_free(fermyon_spin_2_0_0_llm_inferencing_model_t *ptr); + +void fermyon_spin_2_0_0_llm_error_free(fermyon_spin_2_0_0_llm_error_t *ptr); + +void fermyon_spin_2_0_0_llm_inferencing_result_free(fermyon_spin_2_0_0_llm_inferencing_result_t *ptr); + +void fermyon_spin_2_0_0_llm_embedding_model_free(fermyon_spin_2_0_0_llm_embedding_model_t *ptr); + +void http_trigger_list_f32_free(http_trigger_list_f32_t *ptr); + +void http_trigger_list_list_f32_free(http_trigger_list_list_f32_t *ptr); + +void fermyon_spin_2_0_0_llm_embeddings_result_free(fermyon_spin_2_0_0_llm_embeddings_result_t *ptr); + +void fermyon_spin_2_0_0_llm_option_inferencing_params_free(fermyon_spin_2_0_0_llm_option_inferencing_params_t *ptr); + +void fermyon_spin_2_0_0_llm_result_inferencing_result_error_free(fermyon_spin_2_0_0_llm_result_inferencing_result_error_t *ptr); + +void fermyon_spin_2_0_0_llm_result_embeddings_result_error_free(fermyon_spin_2_0_0_llm_result_embeddings_result_error_t *ptr); + +void fermyon_spin_2_0_0_redis_error_free(fermyon_spin_2_0_0_redis_error_t *ptr); + +extern void fermyon_spin_2_0_0_redis_connection_drop_own(fermyon_spin_2_0_0_redis_own_connection_t handle); + +extern void fermyon_spin_2_0_0_redis_connection_drop_borrow(fermyon_spin_2_0_0_redis_borrow_connection_t handle); + +extern fermyon_spin_2_0_0_redis_borrow_connection_t fermyon_spin_2_0_0_redis_borrow_connection(fermyon_spin_2_0_0_redis_own_connection_t handle); + +void fermyon_spin_2_0_0_redis_payload_free(fermyon_spin_2_0_0_redis_payload_t *ptr); + +void fermyon_spin_2_0_0_redis_redis_parameter_free(fermyon_spin_2_0_0_redis_redis_parameter_t *ptr); + +void fermyon_spin_2_0_0_redis_redis_result_free(fermyon_spin_2_0_0_redis_redis_result_t *ptr); + +void fermyon_spin_2_0_0_redis_result_own_connection_error_free(fermyon_spin_2_0_0_redis_result_own_connection_error_t *ptr); + +void fermyon_spin_2_0_0_redis_result_void_error_free(fermyon_spin_2_0_0_redis_result_void_error_t *ptr); + +void http_trigger_option_payload_free(http_trigger_option_payload_t *ptr); + +void fermyon_spin_2_0_0_redis_result_option_payload_error_free(fermyon_spin_2_0_0_redis_result_option_payload_error_t *ptr); + +void fermyon_spin_2_0_0_redis_result_s64_error_free(fermyon_spin_2_0_0_redis_result_s64_error_t *ptr); + +void fermyon_spin_2_0_0_redis_result_u32_error_free(fermyon_spin_2_0_0_redis_result_u32_error_t *ptr); + +void fermyon_spin_2_0_0_redis_result_list_string_error_free(fermyon_spin_2_0_0_redis_result_list_string_error_t *ptr); + +void fermyon_spin_2_0_0_redis_list_redis_parameter_free(fermyon_spin_2_0_0_redis_list_redis_parameter_t *ptr); + +void fermyon_spin_2_0_0_redis_list_redis_result_free(fermyon_spin_2_0_0_redis_list_redis_result_t *ptr); + +void fermyon_spin_2_0_0_redis_result_list_redis_result_error_free(fermyon_spin_2_0_0_redis_result_list_redis_result_error_t *ptr); + +void fermyon_spin_2_0_0_mqtt_error_free(fermyon_spin_2_0_0_mqtt_error_t *ptr); + +extern void fermyon_spin_2_0_0_mqtt_connection_drop_own(fermyon_spin_2_0_0_mqtt_own_connection_t handle); + +extern void fermyon_spin_2_0_0_mqtt_connection_drop_borrow(fermyon_spin_2_0_0_mqtt_borrow_connection_t handle); + +extern fermyon_spin_2_0_0_mqtt_borrow_connection_t fermyon_spin_2_0_0_mqtt_borrow_connection(fermyon_spin_2_0_0_mqtt_own_connection_t handle); + +void fermyon_spin_2_0_0_mqtt_payload_free(fermyon_spin_2_0_0_mqtt_payload_t *ptr); + +void fermyon_spin_2_0_0_mqtt_result_own_connection_error_free(fermyon_spin_2_0_0_mqtt_result_own_connection_error_t *ptr); + +void fermyon_spin_2_0_0_mqtt_result_void_error_free(fermyon_spin_2_0_0_mqtt_result_void_error_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_error_free(fermyon_spin_2_0_0_rdbms_types_error_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_db_value_free(fermyon_spin_2_0_0_rdbms_types_db_value_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_parameter_value_free(fermyon_spin_2_0_0_rdbms_types_parameter_value_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_column_free(fermyon_spin_2_0_0_rdbms_types_column_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_row_free(fermyon_spin_2_0_0_rdbms_types_row_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_list_column_free(fermyon_spin_2_0_0_rdbms_types_list_column_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_list_row_free(fermyon_spin_2_0_0_rdbms_types_list_row_t *ptr); + +void fermyon_spin_2_0_0_rdbms_types_row_set_free(fermyon_spin_2_0_0_rdbms_types_row_set_t *ptr); + +void fermyon_spin_2_0_0_postgres_parameter_value_free(fermyon_spin_2_0_0_postgres_parameter_value_t *ptr); + +void fermyon_spin_2_0_0_postgres_row_set_free(fermyon_spin_2_0_0_postgres_row_set_t *ptr); + +void fermyon_spin_2_0_0_postgres_error_free(fermyon_spin_2_0_0_postgres_error_t *ptr); + +extern void fermyon_spin_2_0_0_postgres_connection_drop_own(fermyon_spin_2_0_0_postgres_own_connection_t handle); + +extern void fermyon_spin_2_0_0_postgres_connection_drop_borrow(fermyon_spin_2_0_0_postgres_borrow_connection_t handle); + +extern fermyon_spin_2_0_0_postgres_borrow_connection_t fermyon_spin_2_0_0_postgres_borrow_connection(fermyon_spin_2_0_0_postgres_own_connection_t handle); + +void fermyon_spin_2_0_0_postgres_result_own_connection_error_free(fermyon_spin_2_0_0_postgres_result_own_connection_error_t *ptr); + +void fermyon_spin_2_0_0_postgres_list_parameter_value_free(fermyon_spin_2_0_0_postgres_list_parameter_value_t *ptr); + +void fermyon_spin_2_0_0_postgres_result_row_set_error_free(fermyon_spin_2_0_0_postgres_result_row_set_error_t *ptr); + +void fermyon_spin_2_0_0_postgres_result_u64_error_free(fermyon_spin_2_0_0_postgres_result_u64_error_t *ptr); + +void fermyon_spin_2_0_0_mysql_parameter_value_free(fermyon_spin_2_0_0_mysql_parameter_value_t *ptr); + +void fermyon_spin_2_0_0_mysql_row_set_free(fermyon_spin_2_0_0_mysql_row_set_t *ptr); + +void fermyon_spin_2_0_0_mysql_error_free(fermyon_spin_2_0_0_mysql_error_t *ptr); + +extern void fermyon_spin_2_0_0_mysql_connection_drop_own(fermyon_spin_2_0_0_mysql_own_connection_t handle); + +extern void fermyon_spin_2_0_0_mysql_connection_drop_borrow(fermyon_spin_2_0_0_mysql_borrow_connection_t handle); + +extern fermyon_spin_2_0_0_mysql_borrow_connection_t fermyon_spin_2_0_0_mysql_borrow_connection(fermyon_spin_2_0_0_mysql_own_connection_t handle); + +void fermyon_spin_2_0_0_mysql_result_own_connection_error_free(fermyon_spin_2_0_0_mysql_result_own_connection_error_t *ptr); + +void fermyon_spin_2_0_0_mysql_list_parameter_value_free(fermyon_spin_2_0_0_mysql_list_parameter_value_t *ptr); + +void fermyon_spin_2_0_0_mysql_result_row_set_error_free(fermyon_spin_2_0_0_mysql_result_row_set_error_t *ptr); + +void fermyon_spin_2_0_0_mysql_result_void_error_free(fermyon_spin_2_0_0_mysql_result_void_error_t *ptr); + +extern void fermyon_spin_2_0_0_sqlite_connection_drop_own(fermyon_spin_2_0_0_sqlite_own_connection_t handle); + +extern void fermyon_spin_2_0_0_sqlite_connection_drop_borrow(fermyon_spin_2_0_0_sqlite_borrow_connection_t handle); + +extern fermyon_spin_2_0_0_sqlite_borrow_connection_t fermyon_spin_2_0_0_sqlite_borrow_connection(fermyon_spin_2_0_0_sqlite_own_connection_t handle); + +void fermyon_spin_2_0_0_sqlite_error_free(fermyon_spin_2_0_0_sqlite_error_t *ptr); + +void fermyon_spin_2_0_0_sqlite_value_free(fermyon_spin_2_0_0_sqlite_value_t *ptr); + +void fermyon_spin_2_0_0_sqlite_list_value_free(fermyon_spin_2_0_0_sqlite_list_value_t *ptr); + +void fermyon_spin_2_0_0_sqlite_row_result_free(fermyon_spin_2_0_0_sqlite_row_result_t *ptr); + +void fermyon_spin_2_0_0_sqlite_list_row_result_free(fermyon_spin_2_0_0_sqlite_list_row_result_t *ptr); + +void fermyon_spin_2_0_0_sqlite_query_result_free(fermyon_spin_2_0_0_sqlite_query_result_t *ptr); + +void fermyon_spin_2_0_0_sqlite_result_own_connection_error_free(fermyon_spin_2_0_0_sqlite_result_own_connection_error_t *ptr); + +void fermyon_spin_2_0_0_sqlite_result_query_result_error_free(fermyon_spin_2_0_0_sqlite_result_query_result_error_t *ptr); + +extern void fermyon_spin_2_0_0_key_value_store_drop_own(fermyon_spin_2_0_0_key_value_own_store_t handle); + +extern void fermyon_spin_2_0_0_key_value_store_drop_borrow(fermyon_spin_2_0_0_key_value_borrow_store_t handle); + +extern fermyon_spin_2_0_0_key_value_borrow_store_t fermyon_spin_2_0_0_key_value_borrow_store(fermyon_spin_2_0_0_key_value_own_store_t handle); + +void fermyon_spin_2_0_0_key_value_error_free(fermyon_spin_2_0_0_key_value_error_t *ptr); + +void fermyon_spin_2_0_0_key_value_result_own_store_error_free(fermyon_spin_2_0_0_key_value_result_own_store_error_t *ptr); + +void http_trigger_option_list_u8_free(http_trigger_option_list_u8_t *ptr); + +void fermyon_spin_2_0_0_key_value_result_option_list_u8_error_free(fermyon_spin_2_0_0_key_value_result_option_list_u8_error_t *ptr); + +void fermyon_spin_2_0_0_key_value_result_void_error_free(fermyon_spin_2_0_0_key_value_result_void_error_t *ptr); + +void fermyon_spin_2_0_0_key_value_result_bool_error_free(fermyon_spin_2_0_0_key_value_result_bool_error_t *ptr); + +void fermyon_spin_2_0_0_key_value_result_list_string_error_free(fermyon_spin_2_0_0_key_value_result_list_string_error_t *ptr); + +void fermyon_spin_2_0_0_variables_error_free(fermyon_spin_2_0_0_variables_error_t *ptr); + +void fermyon_spin_2_0_0_variables_result_string_error_free(fermyon_spin_2_0_0_variables_result_string_error_t *ptr); + +void wasi_cli_0_2_0_exit_result_void_void_free(wasi_cli_0_2_0_exit_result_void_void_t *ptr); + +extern void wasi_cli_0_2_0_terminal_input_terminal_input_drop_own(wasi_cli_0_2_0_terminal_input_own_terminal_input_t handle); + +extern void wasi_cli_0_2_0_terminal_input_terminal_input_drop_borrow(wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t handle); + +extern wasi_cli_0_2_0_terminal_input_borrow_terminal_input_t wasi_cli_0_2_0_terminal_input_borrow_terminal_input(wasi_cli_0_2_0_terminal_input_own_terminal_input_t handle); + +extern void wasi_cli_0_2_0_terminal_output_terminal_output_drop_own(wasi_cli_0_2_0_terminal_output_own_terminal_output_t handle); + +extern void wasi_cli_0_2_0_terminal_output_terminal_output_drop_borrow(wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t handle); + +extern wasi_cli_0_2_0_terminal_output_borrow_terminal_output_t wasi_cli_0_2_0_terminal_output_borrow_terminal_output(wasi_cli_0_2_0_terminal_output_own_terminal_output_t handle); + +void wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_free(wasi_cli_0_2_0_terminal_stdin_option_own_terminal_input_t *ptr); + +void wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_free(wasi_cli_0_2_0_terminal_stdout_option_own_terminal_output_t *ptr); + +void wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_free(wasi_cli_0_2_0_terminal_stderr_option_own_terminal_output_t *ptr); + +void wasi_filesystem_0_2_0_types_option_datetime_free(wasi_filesystem_0_2_0_types_option_datetime_t *ptr); + +void wasi_filesystem_0_2_0_types_descriptor_stat_free(wasi_filesystem_0_2_0_types_descriptor_stat_t *ptr); + +void wasi_filesystem_0_2_0_types_new_timestamp_free(wasi_filesystem_0_2_0_types_new_timestamp_t *ptr); + +void wasi_filesystem_0_2_0_types_directory_entry_free(wasi_filesystem_0_2_0_types_directory_entry_t *ptr); + +extern void wasi_filesystem_0_2_0_types_descriptor_drop_own(wasi_filesystem_0_2_0_types_own_descriptor_t handle); + +extern void wasi_filesystem_0_2_0_types_descriptor_drop_borrow(wasi_filesystem_0_2_0_types_borrow_descriptor_t handle); + +extern wasi_filesystem_0_2_0_types_borrow_descriptor_t wasi_filesystem_0_2_0_types_borrow_descriptor(wasi_filesystem_0_2_0_types_own_descriptor_t handle); + +extern void wasi_filesystem_0_2_0_types_directory_entry_stream_drop_own(wasi_filesystem_0_2_0_types_own_directory_entry_stream_t handle); + +extern void wasi_filesystem_0_2_0_types_directory_entry_stream_drop_borrow(wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t handle); + +extern wasi_filesystem_0_2_0_types_borrow_directory_entry_stream_t wasi_filesystem_0_2_0_types_borrow_directory_entry_stream(wasi_filesystem_0_2_0_types_own_directory_entry_stream_t handle); + +void wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_input_stream_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_output_stream_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_void_error_code_free(wasi_filesystem_0_2_0_types_result_void_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_flags_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_type_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_0_2_0_types_result_tuple2_list_u8_bool_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_filesize_error_code_free(wasi_filesystem_0_2_0_types_result_filesize_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_0_2_0_types_result_own_directory_entry_stream_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_free(wasi_filesystem_0_2_0_types_result_descriptor_stat_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_free(wasi_filesystem_0_2_0_types_result_own_descriptor_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_string_error_code_free(wasi_filesystem_0_2_0_types_result_string_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_free(wasi_filesystem_0_2_0_types_result_metadata_hash_value_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_option_directory_entry_free(wasi_filesystem_0_2_0_types_option_directory_entry_t *ptr); + +void wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_free(wasi_filesystem_0_2_0_types_result_option_directory_entry_error_code_t *ptr); + +void wasi_filesystem_0_2_0_types_option_error_code_free(wasi_filesystem_0_2_0_types_option_error_code_t *ptr); + +void wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_preopens_tuple2_own_descriptor_string_t *ptr); + +void wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_preopens_list_tuple2_own_descriptor_string_t *ptr); + +extern void wasi_sockets_0_2_0_network_network_drop_own(wasi_sockets_0_2_0_network_own_network_t handle); + +extern void wasi_sockets_0_2_0_network_network_drop_borrow(wasi_sockets_0_2_0_network_borrow_network_t handle); + +extern wasi_sockets_0_2_0_network_borrow_network_t wasi_sockets_0_2_0_network_borrow_network(wasi_sockets_0_2_0_network_own_network_t handle); + +void wasi_sockets_0_2_0_network_ip_address_free(wasi_sockets_0_2_0_network_ip_address_t *ptr); + +void wasi_sockets_0_2_0_network_ip_socket_address_free(wasi_sockets_0_2_0_network_ip_socket_address_t *ptr); + +void wasi_sockets_0_2_0_udp_ip_socket_address_free(wasi_sockets_0_2_0_udp_ip_socket_address_t *ptr); + +void wasi_sockets_0_2_0_udp_incoming_datagram_free(wasi_sockets_0_2_0_udp_incoming_datagram_t *ptr); + +void wasi_sockets_0_2_0_udp_option_ip_socket_address_free(wasi_sockets_0_2_0_udp_option_ip_socket_address_t *ptr); + +void wasi_sockets_0_2_0_udp_outgoing_datagram_free(wasi_sockets_0_2_0_udp_outgoing_datagram_t *ptr); + +extern void wasi_sockets_0_2_0_udp_udp_socket_drop_own(wasi_sockets_0_2_0_udp_own_udp_socket_t handle); + +extern void wasi_sockets_0_2_0_udp_udp_socket_drop_borrow(wasi_sockets_0_2_0_udp_borrow_udp_socket_t handle); + +extern wasi_sockets_0_2_0_udp_borrow_udp_socket_t wasi_sockets_0_2_0_udp_borrow_udp_socket(wasi_sockets_0_2_0_udp_own_udp_socket_t handle); + +extern void wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop_own(wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t handle); + +extern void wasi_sockets_0_2_0_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t handle); + +extern wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream_t wasi_sockets_0_2_0_udp_borrow_incoming_datagram_stream(wasi_sockets_0_2_0_udp_own_incoming_datagram_stream_t handle); + +extern void wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop_own(wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t handle); + +extern void wasi_sockets_0_2_0_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t handle); + +extern wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream_t wasi_sockets_0_2_0_udp_borrow_outgoing_datagram_stream(wasi_sockets_0_2_0_udp_own_outgoing_datagram_stream_t handle); + +void wasi_sockets_0_2_0_udp_result_void_error_code_free(wasi_sockets_0_2_0_udp_result_void_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_0_2_0_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_udp_result_ip_socket_address_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_result_u8_error_code_free(wasi_sockets_0_2_0_udp_result_u8_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_result_u64_error_code_free(wasi_sockets_0_2_0_udp_result_u64_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_list_incoming_datagram_free(wasi_sockets_0_2_0_udp_list_incoming_datagram_t *ptr); + +void wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_0_2_0_udp_result_list_incoming_datagram_error_code_t *ptr); + +void wasi_sockets_0_2_0_udp_list_outgoing_datagram_free(wasi_sockets_0_2_0_udp_list_outgoing_datagram_t *ptr); + +void wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_0_2_0_udp_create_socket_result_own_udp_socket_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_ip_socket_address_free(wasi_sockets_0_2_0_tcp_ip_socket_address_t *ptr); + +extern void wasi_sockets_0_2_0_tcp_tcp_socket_drop_own(wasi_sockets_0_2_0_tcp_own_tcp_socket_t handle); + +extern void wasi_sockets_0_2_0_tcp_tcp_socket_drop_borrow(wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t handle); + +extern wasi_sockets_0_2_0_tcp_borrow_tcp_socket_t wasi_sockets_0_2_0_tcp_borrow_tcp_socket(wasi_sockets_0_2_0_tcp_own_tcp_socket_t handle); + +void wasi_sockets_0_2_0_tcp_result_void_error_code_free(wasi_sockets_0_2_0_tcp_result_void_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_tcp_result_ip_socket_address_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_bool_error_code_free(wasi_sockets_0_2_0_tcp_result_bool_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_duration_error_code_free(wasi_sockets_0_2_0_tcp_result_duration_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_u32_error_code_free(wasi_sockets_0_2_0_tcp_result_u32_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_u8_error_code_free(wasi_sockets_0_2_0_tcp_result_u8_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_result_u64_error_code_free(wasi_sockets_0_2_0_tcp_result_u64_error_code_t *ptr); + +void wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_0_2_0_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr); + +void wasi_sockets_0_2_0_ip_name_lookup_ip_address_free(wasi_sockets_0_2_0_ip_name_lookup_ip_address_t *ptr); + +extern void wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t handle); + +extern void wasi_sockets_0_2_0_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t handle); + +extern wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_0_2_0_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_0_2_0_ip_name_lookup_own_resolve_address_stream_t handle); + +void wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_0_2_0_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr); + +void wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_free(wasi_sockets_0_2_0_ip_name_lookup_option_ip_address_t *ptr); + +void wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_0_2_0_ip_name_lookup_result_option_ip_address_error_code_t *ptr); + +void wasi_keyvalue_store_error_free(wasi_keyvalue_store_error_t *ptr); + +extern void wasi_keyvalue_store_bucket_drop_own(wasi_keyvalue_store_own_bucket_t handle); + +extern void wasi_keyvalue_store_bucket_drop_borrow(wasi_keyvalue_store_borrow_bucket_t handle); + +extern wasi_keyvalue_store_borrow_bucket_t wasi_keyvalue_store_borrow_bucket(wasi_keyvalue_store_own_bucket_t handle); + +void wasi_keyvalue_store_result_own_bucket_error_free(wasi_keyvalue_store_result_own_bucket_error_t *ptr); + +void wasi_keyvalue_store_result_option_list_u8_error_free(wasi_keyvalue_store_result_option_list_u8_error_t *ptr); + +void wasi_keyvalue_store_result_void_error_free(wasi_keyvalue_store_result_void_error_t *ptr); + +void wasi_keyvalue_store_result_bool_error_free(wasi_keyvalue_store_result_bool_error_t *ptr); + +void wasi_keyvalue_store_result_key_response_error_free(wasi_keyvalue_store_result_key_response_error_t *ptr); + +void wasi_keyvalue_atomics_error_free(wasi_keyvalue_atomics_error_t *ptr); + +extern void wasi_keyvalue_atomics_cas_drop_own(wasi_keyvalue_atomics_own_cas_t handle); + +extern void wasi_keyvalue_atomics_cas_drop_borrow(wasi_keyvalue_atomics_borrow_cas_t handle); + +extern wasi_keyvalue_atomics_borrow_cas_t wasi_keyvalue_atomics_borrow_cas(wasi_keyvalue_atomics_own_cas_t handle); + +void wasi_keyvalue_atomics_cas_error_free(wasi_keyvalue_atomics_cas_error_t *ptr); + +void wasi_keyvalue_atomics_result_own_cas_error_free(wasi_keyvalue_atomics_result_own_cas_error_t *ptr); + +void wasi_keyvalue_atomics_result_option_list_u8_error_free(wasi_keyvalue_atomics_result_option_list_u8_error_t *ptr); + +void wasi_keyvalue_atomics_result_s64_error_free(wasi_keyvalue_atomics_result_s64_error_t *ptr); + +void wasi_keyvalue_atomics_result_void_cas_error_free(wasi_keyvalue_atomics_result_void_cas_error_t *ptr); + +void wasi_keyvalue_batch_error_free(wasi_keyvalue_batch_error_t *ptr); + +void http_trigger_tuple2_string_option_list_u8_free(http_trigger_tuple2_string_option_list_u8_t *ptr); + +void http_trigger_list_tuple2_string_option_list_u8_free(http_trigger_list_tuple2_string_option_list_u8_t *ptr); + +void wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_free(wasi_keyvalue_batch_result_list_tuple2_string_option_list_u8_error_t *ptr); + +void http_trigger_tuple2_string_list_u8_free(http_trigger_tuple2_string_list_u8_t *ptr); + +void http_trigger_list_tuple2_string_list_u8_free(http_trigger_list_tuple2_string_list_u8_t *ptr); + +void wasi_keyvalue_batch_result_void_error_free(wasi_keyvalue_batch_result_void_error_t *ptr); + +// Sets the string `ret` to reference the input string `s` without copying it +void http_trigger_string_set(http_trigger_string_t *ret, const char*s); + +// Creates a copy of the input nul-terminated string `s` and +// stores it into the component model string `ret`. +void http_trigger_string_dup(http_trigger_string_t *ret, const char*s); + +// Creates a copy of the input string `s` with length `len` and +// stores it into the component model string `ret`. +// The length is specified in code units (bytes for UTF-8, 16-bit values for UTF-16). +void http_trigger_string_dup_n(http_trigger_string_t *ret, const char*s, size_t len); + +// Deallocates the string pointed to by `ret`, deallocating +// the memory behind the string. +void http_trigger_string_free(http_trigger_string_t *ret); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/templates/http-c/content/bindings/http_trigger_component_type.o b/templates/http-c/content/bindings/http_trigger_component_type.o new file mode 100644 index 0000000000..73b8dbad0b Binary files /dev/null and b/templates/http-c/content/bindings/http_trigger_component_type.o differ diff --git a/templates/http-c/content/main.c b/templates/http-c/content/main.c index 44081e4020..69b8d823ea 100644 --- a/templates/http-c/content/main.c +++ b/templates/http-c/content/main.c @@ -1,7 +1,45 @@ -#include -#include +#include "bindings/http_trigger.h" -int main() { - printf("content-type: text/plain\n\n"); - printf("Hello from %s\n", getenv("SERVER_SOFTWARE")); +void exports_wasi_http_0_2_0_incoming_handler_handle( + exports_wasi_http_0_2_0_incoming_handler_own_incoming_request_t request, + exports_wasi_http_0_2_0_incoming_handler_own_response_outparam_t response_out +) { + wasi_http_0_2_0_types_borrow_incoming_request_t req_b = wasi_http_0_2_0_types_borrow_incoming_request(request); + + wasi_http_0_2_0_types_own_headers_t headers = wasi_http_0_2_0_types_constructor_fields(); + wasi_http_0_2_0_types_own_outgoing_response_t resp = wasi_http_0_2_0_types_constructor_outgoing_response(headers); + wasi_http_0_2_0_types_borrow_outgoing_response_t resp_b = wasi_http_0_2_0_types_borrow_outgoing_response(resp); + + wasi_http_0_2_0_types_own_outgoing_body_t ogbod; + if (!wasi_http_0_2_0_types_method_outgoing_response_body(resp_b, &ogbod)) { + return; + } + wasi_http_0_2_0_types_borrow_outgoing_body_t ogbod_b = wasi_http_0_2_0_types_borrow_outgoing_body(ogbod); + + wasi_http_0_2_0_types_result_own_outgoing_response_error_code_t respe = { + .is_err = false, + .val = resp, + }; + wasi_http_0_2_0_types_static_response_outparam_set(response_out, &respe); + + http_trigger_string_t pq; + if (wasi_http_0_2_0_types_method_incoming_request_path_with_query(req_b, &pq)) { + wasi_http_0_2_0_types_own_output_stream_t out_stm; + if (wasi_http_0_2_0_types_method_outgoing_body_write(ogbod_b, &out_stm)) { + wasi_io_0_2_0_streams_borrow_output_stream_t out_stm_b = wasi_io_0_2_0_streams_borrow_output_stream(out_stm); + wasi_io_0_2_0_streams_stream_error_t err; + + http_trigger_list_u8_t contents = { .ptr = pq.ptr, .len = pq.len }; + wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush(out_stm_b, &contents, &err); + + char* nl = "\n"; + http_trigger_list_u8_t nl_contents = { .ptr = (uint8_t*)nl, .len = 1 }; + wasi_io_0_2_0_streams_method_output_stream_blocking_write_and_flush(out_stm_b, &nl_contents, &err); + + wasi_io_0_2_0_streams_output_stream_drop_own(out_stm); + } + } + + wasi_http_0_2_0_types_error_code_t err_code; + wasi_http_0_2_0_types_static_outgoing_body_finish(ogbod, NULL, &err_code); } diff --git a/templates/http-c/content/spin.toml b/templates/http-c/content/spin.toml index 09f3272c12..786890b4e6 100644 --- a/templates/http-c/content/spin.toml +++ b/templates/http-c/content/spin.toml @@ -11,11 +11,10 @@ description = "{{project-description}}" [[trigger.http]] route = "{{http-path}}" component = "{{project-name | kebab_case}}" -executor = { type = "wagi" } [component.{{project-name | kebab_case}}] source = "main.wasm" allowed_outbound_hosts = [] [component.{{project-name | kebab_case}}.build] -command = "zig build-exe -O ReleaseSmall -target wasm32-wasi main.c -lc" +command = "$WASI_SDK_PATH/bin/wasm32-wasip2-clang --sysroot=$WASI_SDK_PATH/share/wasi-sysroot main.c bindings/http_trigger.c bindings/http_trigger_component_type.o -mexec-model=reactor -o main.wasm" watch = ["**/*.c"] diff --git a/templates/http-c/metadata/spin-template.toml b/templates/http-c/metadata/spin-template.toml index d3f4d105f2..c0e2639535 100644 --- a/templates/http-c/metadata/spin-template.toml +++ b/templates/http-c/metadata/spin-template.toml @@ -1,6 +1,6 @@ manifest_version = "1" id = "http-c" -description = "HTTP request handler using C and the Zig toolchain" +description = "HTTP request handler using WASI P2, C and the WASI-SDK toolchain" tags = ["http", "c"] [parameters] diff --git a/templates/http-cpp/content/.gitignore b/templates/http-cpp/content/.gitignore new file mode 100644 index 0000000000..b565010470 --- /dev/null +++ b/templates/http-cpp/content/.gitignore @@ -0,0 +1,2 @@ +main.wasm +.spin/ diff --git a/templates/http-cpp/content/README.md b/templates/http-cpp/content/README.md new file mode 100644 index 0000000000..fa6f50a708 --- /dev/null +++ b/templates/http-cpp/content/README.md @@ -0,0 +1,23 @@ +# Prerequisites + +You will need: + +* The WASI SDK + * Installation: https://github.com/WebAssembly/wasi-sdk#install + * Releases: https://github.com/WebAssembly/wasi-sdk/releases + +# Building + +* Set the `WASI_SDK_PATH` environment variable to the root of your WASI SDK installation (per the installation instructions at https://github.com/WebAssembly/wasi-sdk#install) +* Run `spin build` + +# WASI and Spin host bindings + +The `bindings` directory contains generated bindings for Spin. If you need to regenerate bindings: + +* Install `wit-bindgen` (https://github.com/bytecodealliance/wit-bindgen#cli-installation) - requires Rust (https://rust-lang.org/tools/install/) +* Copy the `wit` directory from https://github.com/spinframework/spin into this folder +* Delete the existing `bindings` directory +* Run `wit-bindgen cpp ./wit/ --out-dir bindings -w http-trigger` + +However, C++ bindings for WASI P3 and other async APIs are not yet available, so if you do need to regenerate bindings, it is currently recommended that you **NOT** do so from Spin `HEAD`. diff --git a/templates/http-cpp/content/bindings/http_trigger.cpp b/templates/http-cpp/content/bindings/http_trigger.cpp new file mode 100644 index 0000000000..3064c26088 --- /dev/null +++ b/templates/http-cpp/content/bindings/http_trigger.cpp @@ -0,0 +1,11154 @@ +// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT! + +// Ensure that the *_component_type.o object is linked in +#ifdef __wasm32__ +extern "C" void __component_type_object_force_link_http_trigger(void); +__attribute__((used)) +void __component_type_object_force_link_http_trigger_public_use_in_this_compilation_unit(void) { + __component_type_object_force_link_http_trigger(); +} +#endif +#include "http_trigger_cpp.h" +#include // realloc + +extern "C" void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size); + +__attribute__((__weak__, __export_name__("cabi_realloc"))) +void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { + (void) old_size; + if (new_size == 0) return (void*) align; + void *ret = realloc(ptr, new_size); + if (!ret) abort(); + return ret; +} + + +extern "C" __attribute__((import_module("spin:postgres/postgres@3.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("spin:postgres/postgres@3.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:postgres/postgres@3.0.0"))) +__attribute__((import_name("[method]connection.query"))) +void __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BmethodX5DconnectionX2Equery(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:postgres/postgres@3.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:postgres/postgres@4.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("spin:postgres/postgres@4.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:postgres/postgres@4.0.0"))) +__attribute__((import_name("[method]connection.query"))) +void __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BmethodX5DconnectionX2Equery(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:postgres/postgres@4.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:sqlite/sqlite@3.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("spin:sqlite/sqlite@3.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:sqlite/sqlite@3.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("spin:sqlite/sqlite@3.0.0"))) +__attribute__((import_name("[method]connection.last-insert-rowid"))) +int64_t __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Elast_insert_rowid(int32_t); +extern "C" __attribute__((import_module("spin:sqlite/sqlite@3.0.0"))) +__attribute__((import_name("[method]connection.changes"))) +int64_t __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Echanges(int32_t); +extern "C" __attribute__((import_module("wasi:config/store@0.2.0-draft-2024-09-27"))) +__attribute__((import_name("get"))) +void __wasm_import_wasiX3AconfigX2FstoreX400X2E2X2E0_draft_2024_09_27X00get(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:config/store@0.2.0-draft-2024-09-27"))) +__attribute__((import_name("get-all"))) +void __wasm_import_wasiX3AconfigX2FstoreX400X2E2X2E0_draft_2024_09_27X00get_all(uint8_t *); +extern "C" __attribute__((import_module("wasi:io/poll@0.2.0"))) +__attribute__((import_name("[resource-drop]pollable"))) +void __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5Bresource_dropX5Dpollable(int32_t); +extern "C" __attribute__((import_module("wasi:io/poll@0.2.0"))) +__attribute__((import_name("[method]pollable.ready"))) +int32_t __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5BmethodX5DpollableX2Eready(int32_t); +extern "C" __attribute__((import_module("wasi:io/poll@0.2.0"))) +__attribute__((import_name("[method]pollable.block"))) +void __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5BmethodX5DpollableX2Eblock(int32_t); +extern "C" __attribute__((import_module("wasi:io/poll@0.2.0"))) +__attribute__((import_name("poll"))) +void __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00poll(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:clocks/monotonic-clock@0.2.0"))) +__attribute__((import_name("now"))) +int64_t __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00now(); +extern "C" __attribute__((import_module("wasi:clocks/monotonic-clock@0.2.0"))) +__attribute__((import_name("resolution"))) +int64_t __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00resolution(); +extern "C" __attribute__((import_module("wasi:clocks/monotonic-clock@0.2.0"))) +__attribute__((import_name("subscribe-instant"))) +int32_t __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00subscribe_instant(int64_t); +extern "C" __attribute__((import_module("wasi:clocks/monotonic-clock@0.2.0"))) +__attribute__((import_name("subscribe-duration"))) +int32_t __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00subscribe_duration(int64_t); +extern "C" __attribute__((import_module("wasi:io/error@0.2.0"))) +__attribute__((import_name("[resource-drop]error"))) +void __wasm_import_wasiX3AioX2FerrorX400X2E2X2E0X00X5Bresource_dropX5Derror(int32_t); +extern "C" __attribute__((import_module("wasi:io/error@0.2.0"))) +__attribute__((import_name("[method]error.to-debug-string"))) +void __wasm_import_wasiX3AioX2FerrorX400X2E2X2E0X00X5BmethodX5DerrorX2Eto_debug_string(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[resource-drop]input-stream"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5Bresource_dropX5Dinput_stream(int32_t); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]input-stream.read"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eread(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]input-stream.blocking-read"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eblocking_read(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]input-stream.skip"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eskip(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]input-stream.blocking-skip"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eblocking_skip(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]input-stream.subscribe"))) +int32_t __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[resource-drop]output-stream"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5Bresource_dropX5Doutput_stream(int32_t); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.check-write"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Echeck_write(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.write"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Ewrite(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.blocking-write-and-flush"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_write_and_flush(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.flush"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eflush(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.blocking-flush"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_flush(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.subscribe"))) +int32_t __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.write-zeroes"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Ewrite_zeroes(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.blocking-write-zeroes-and-flush"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_write_zeroes_and_flush(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.splice"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Esplice(int32_t, int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:io/streams@0.2.0"))) +__attribute__((import_name("[method]output-stream.blocking-splice"))) +void __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_splice(int32_t, int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]fields"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfields(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[constructor]fields"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Dfields(); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[static]fields.from-list"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5DfieldsX2Efrom_list(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.get"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eget(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.has"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Ehas(int32_t, uint8_t *, size_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.set"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eset(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.delete"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Edelete(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.append"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eappend(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.entries"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eentries(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]fields.clone"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eclone(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]future-trailers"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfuture_trailers(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]future-trailers.subscribe"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_trailersX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]future-trailers.get"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_trailersX2Eget(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]incoming-body"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_body(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-body.stream"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_bodyX2Estream(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[static]incoming-body.finish"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Dincoming_bodyX2Efinish(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]incoming-request"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_request(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.method"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Emethod(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.path-with-query"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Epath_with_query(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.scheme"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Escheme(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.authority"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Eauthority(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.headers"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Eheaders(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-request.consume"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Econsume(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]outgoing-body"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_body(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-body.write"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_bodyX2Ewrite(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[static]outgoing-body.finish"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Doutgoing_bodyX2Efinish(int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]outgoing-request"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_request(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[constructor]outgoing-request"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Doutgoing_request(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.body"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Ebody(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.method"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Emethod(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.set-method"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_method(int32_t, int32_t, uint8_t *, size_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.path-with-query"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Epath_with_query(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.set-path-with-query"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_path_with_query(int32_t, int32_t, uint8_t *, size_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.scheme"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Escheme(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.set-scheme"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_scheme(int32_t, int32_t, int32_t, uint8_t *, size_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.authority"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eauthority(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.set-authority"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_authority(int32_t, int32_t, uint8_t *, size_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-request.headers"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eheaders(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]request-options"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Drequest_options(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[constructor]request-options"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Drequest_options(); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.connect-timeout"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Econnect_timeout(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.set-connect-timeout"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_connect_timeout(int32_t, int32_t, int64_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.first-byte-timeout"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Efirst_byte_timeout(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.set-first-byte-timeout"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_first_byte_timeout(int32_t, int32_t, int64_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.between-bytes-timeout"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Ebetween_bytes_timeout(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]request-options.set-between-bytes-timeout"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_between_bytes_timeout(int32_t, int32_t, int64_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]outgoing-response"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_response(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[constructor]outgoing-response"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Doutgoing_response(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-response.status-code"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Estatus_code(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-response.set-status-code"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Eset_status_code(int32_t, int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-response.headers"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Eheaders(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]outgoing-response.body"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Ebody(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]response-outparam"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dresponse_outparam(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[static]response-outparam.set"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Dresponse_outparamX2Eset(int32_t, int32_t, int32_t, int32_t, int64_t, uint8_t *, uint8_t *, size_t, int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]incoming-response"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_response(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-response.status"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Estatus(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-response.headers"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Eheaders(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]incoming-response.consume"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Econsume(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[resource-drop]future-incoming-response"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfuture_incoming_response(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]future-incoming-response.subscribe"))) +int32_t __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_incoming_responseX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("[method]future-incoming-response.get"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_incoming_responseX2Eget(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/types@0.2.0"))) +__attribute__((import_name("http-error-code"))) +void __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00http_error_code(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:http/outgoing-handler@0.2.0"))) +__attribute__((import_name("handle"))) +void __wasm_import_wasiX3AhttpX2Foutgoing_handlerX400X2E2X2E0X00handle(int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/llm@2.0.0"))) +__attribute__((import_name("infer"))) +void __wasm_import_fermyonX3AspinX2FllmX402X2E0X2E0X00infer(uint8_t *, size_t, uint8_t *, size_t, int32_t, int32_t, float, int32_t, float, int32_t, float, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/llm@2.0.0"))) +__attribute__((import_name("generate-embeddings"))) +void __wasm_import_fermyonX3AspinX2FllmX402X2E0X2E0X00generate_embeddings(uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.publish"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Epublish(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.get"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eget(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.set"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eset(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.incr"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eincr(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.del"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Edel(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.sadd"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esadd(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.smembers"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esmembers(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.srem"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esrem(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/redis@2.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/mqtt@2.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/mqtt@2.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *, size_t, uint8_t *, size_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/mqtt@2.0.0"))) +__attribute__((import_name("[method]connection.publish"))) +void __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5BmethodX5DconnectionX2Epublish(int32_t, uint8_t *, size_t, uint8_t *, size_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/postgres@2.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/postgres@2.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/postgres@2.0.0"))) +__attribute__((import_name("[method]connection.query"))) +void __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BmethodX5DconnectionX2Equery(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/postgres@2.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/mysql@2.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/mysql@2.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/mysql@2.0.0"))) +__attribute__((import_name("[method]connection.query"))) +void __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BmethodX5DconnectionX2Equery(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/mysql@2.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/sqlite@2.0.0"))) +__attribute__((import_name("[resource-drop]connection"))) +void __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5Bresource_dropX5Dconnection(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/sqlite@2.0.0"))) +__attribute__((import_name("[static]connection.open"))) +void __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/sqlite@2.0.0"))) +__attribute__((import_name("[method]connection.execute"))) +void __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[resource-drop]store"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5Bresource_dropX5Dstore(int32_t); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[static]store.open"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BstaticX5DstoreX2Eopen(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[method]store.get"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eget(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[method]store.set"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eset(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[method]store.delete"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Edelete(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[method]store.exists"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eexists(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/key-value@2.0.0"))) +__attribute__((import_name("[method]store.get-keys"))) +void __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eget_keys(int32_t, uint8_t *); +extern "C" __attribute__((import_module("fermyon:spin/variables@2.0.0"))) +__attribute__((import_name("get"))) +void __wasm_import_fermyonX3AspinX2FvariablesX402X2E0X2E0X00get(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/environment@0.2.0"))) +__attribute__((import_name("get-environment"))) +void __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00get_environment(uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/environment@0.2.0"))) +__attribute__((import_name("get-arguments"))) +void __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00get_arguments(uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/environment@0.2.0"))) +__attribute__((import_name("initial-cwd"))) +void __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00initial_cwd(uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/exit@0.2.0"))) +__attribute__((import_name("exit"))) +void __wasm_import_wasiX3AcliX2FexitX400X2E2X2E0X00exit(int32_t); +extern "C" __attribute__((import_module("wasi:cli/stdin@0.2.0"))) +__attribute__((import_name("get-stdin"))) +int32_t __wasm_import_wasiX3AcliX2FstdinX400X2E2X2E0X00get_stdin(); +extern "C" __attribute__((import_module("wasi:cli/stdout@0.2.0"))) +__attribute__((import_name("get-stdout"))) +int32_t __wasm_import_wasiX3AcliX2FstdoutX400X2E2X2E0X00get_stdout(); +extern "C" __attribute__((import_module("wasi:cli/stderr@0.2.0"))) +__attribute__((import_name("get-stderr"))) +int32_t __wasm_import_wasiX3AcliX2FstderrX400X2E2X2E0X00get_stderr(); +extern "C" __attribute__((import_module("wasi:cli/terminal-input@0.2.0"))) +__attribute__((import_name("[resource-drop]terminal-input"))) +void __wasm_import_wasiX3AcliX2Fterminal_inputX400X2E2X2E0X00X5Bresource_dropX5Dterminal_input(int32_t); +extern "C" __attribute__((import_module("wasi:cli/terminal-output@0.2.0"))) +__attribute__((import_name("[resource-drop]terminal-output"))) +void __wasm_import_wasiX3AcliX2Fterminal_outputX400X2E2X2E0X00X5Bresource_dropX5Dterminal_output(int32_t); +extern "C" __attribute__((import_module("wasi:cli/terminal-stdin@0.2.0"))) +__attribute__((import_name("get-terminal-stdin"))) +void __wasm_import_wasiX3AcliX2Fterminal_stdinX400X2E2X2E0X00get_terminal_stdin(uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/terminal-stdout@0.2.0"))) +__attribute__((import_name("get-terminal-stdout"))) +void __wasm_import_wasiX3AcliX2Fterminal_stdoutX400X2E2X2E0X00get_terminal_stdout(uint8_t *); +extern "C" __attribute__((import_module("wasi:cli/terminal-stderr@0.2.0"))) +__attribute__((import_name("get-terminal-stderr"))) +void __wasm_import_wasiX3AcliX2Fterminal_stderrX400X2E2X2E0X00get_terminal_stderr(uint8_t *); +extern "C" __attribute__((import_module("wasi:clocks/wall-clock@0.2.0"))) +__attribute__((import_name("now"))) +void __wasm_import_wasiX3AclocksX2Fwall_clockX400X2E2X2E0X00now(uint8_t *); +extern "C" __attribute__((import_module("wasi:clocks/wall-clock@0.2.0"))) +__attribute__((import_name("resolution"))) +void __wasm_import_wasiX3AclocksX2Fwall_clockX400X2E2X2E0X00resolution(uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[resource-drop]directory-entry-stream"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Ddirectory_entry_stream(int32_t); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]directory-entry-stream.read-directory-entry"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5Ddirectory_entry_streamX2Eread_directory_entry(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[resource-drop]descriptor"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Ddescriptor(int32_t); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.read-via-stream"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread_via_stream(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.write-via-stream"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ewrite_via_stream(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.append-via-stream"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eappend_via_stream(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.advise"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eadvise(int32_t, int64_t, int64_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.sync-data"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esync_data(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.get-flags"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eget_flags(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.get-type"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eget_type(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.set-size"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.set-times"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.read"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread(int32_t, int64_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.write"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ewrite(int32_t, uint8_t *, size_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.read-directory"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread_directory(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.sync"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esync(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.create-directory-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ecreate_directory_at(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.stat"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Estat(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.stat-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Estat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.set-times-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_times_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.link-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Elink_at(int32_t, int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.open-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eopen_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.readlink-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ereadlink_at(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.remove-directory-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eremove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.rename-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Erename_at(int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.symlink-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esymlink_at(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.unlink-file-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eunlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.is-same-object"))) +int32_t __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eis_same_object(int32_t, int32_t); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.metadata-hash"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Emetadata_hash(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("[method]descriptor.metadata-hash-at"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Emetadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/types@0.2.0"))) +__attribute__((import_name("filesystem-error-code"))) +void __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00filesystem_error_code(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:filesystem/preopens@0.2.0"))) +__attribute__((import_name("get-directories"))) +void __wasm_import_wasiX3AfilesystemX2FpreopensX400X2E2X2E0X00get_directories(uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/network@0.2.0"))) +__attribute__((import_name("[resource-drop]network"))) +void __wasm_import_wasiX3AsocketsX2FnetworkX400X2E2X2E0X00X5Bresource_dropX5Dnetwork(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/instance-network@0.2.0"))) +__attribute__((import_name("instance-network"))) +int32_t __wasm_import_wasiX3AsocketsX2Finstance_networkX400X2E2X2E0X00instance_network(); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[resource-drop]incoming-datagram-stream"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Dincoming_datagram_stream(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]incoming-datagram-stream.receive"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dincoming_datagram_streamX2Ereceive(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]incoming-datagram-stream.subscribe"))) +int32_t __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dincoming_datagram_streamX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[resource-drop]outgoing-datagram-stream"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_datagram_stream(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]outgoing-datagram-stream.check-send"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Echeck_send(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]outgoing-datagram-stream.send"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Esend(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]outgoing-datagram-stream.subscribe"))) +int32_t __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[resource-drop]udp-socket"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Dudp_socket(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.start-bind"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Estart_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.finish-bind"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Efinish_bind(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.stream"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Estream(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.local-address"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Elocal_address(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.remote-address"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eremote_address(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.address-family"))) +int32_t __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eaddress_family(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.unicast-hop-limit"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eunicast_hop_limit(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.set-unicast-hop-limit"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_unicast_hop_limit(int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.receive-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Ereceive_buffer_size(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.set-receive-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_receive_buffer_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.send-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Esend_buffer_size(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.set-send-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_send_buffer_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/udp@0.2.0"))) +__attribute__((import_name("[method]udp-socket.subscribe"))) +int32_t __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/udp-create-socket@0.2.0"))) +__attribute__((import_name("create-udp-socket"))) +void __wasm_import_wasiX3AsocketsX2Fudp_create_socketX400X2E2X2E0X00create_udp_socket(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[resource-drop]tcp-socket"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5Bresource_dropX5Dtcp_socket(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.start-bind"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.finish-bind"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_bind(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.start-connect"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.finish-connect"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_connect(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.start-listen"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_listen(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.finish-listen"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_listen(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.accept"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eaccept(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.local-address"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Elocal_address(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.remote-address"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eremote_address(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.is-listening"))) +int32_t __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eis_listening(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.address-family"))) +int32_t __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eaddress_family(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-listen-backlog-size"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_listen_backlog_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.keep-alive-enabled"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_enabled(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-keep-alive-enabled"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_enabled(int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.keep-alive-idle-time"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_idle_time(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-keep-alive-idle-time"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_idle_time(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.keep-alive-interval"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_interval(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-keep-alive-interval"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_interval(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.keep-alive-count"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_count(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-keep-alive-count"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_count(int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.hop-limit"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ehop_limit(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-hop-limit"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_hop_limit(int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.receive-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ereceive_buffer_size(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-receive-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_receive_buffer_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.send-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Esend_buffer_size(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.set-send-buffer-size"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_send_buffer_size(int32_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.subscribe"))) +int32_t __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/tcp@0.2.0"))) +__attribute__((import_name("[method]tcp-socket.shutdown"))) +void __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eshutdown(int32_t, int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/tcp-create-socket@0.2.0"))) +__attribute__((import_name("create-tcp-socket"))) +void __wasm_import_wasiX3AsocketsX2Ftcp_create_socketX400X2E2X2E0X00create_tcp_socket(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/ip-name-lookup@0.2.0"))) +__attribute__((import_name("[resource-drop]resolve-address-stream"))) +void __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5Bresource_dropX5Dresolve_address_stream(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/ip-name-lookup@0.2.0"))) +__attribute__((import_name("[method]resolve-address-stream.resolve-next-address"))) +void __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5BmethodX5Dresolve_address_streamX2Eresolve_next_address(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:sockets/ip-name-lookup@0.2.0"))) +__attribute__((import_name("[method]resolve-address-stream.subscribe"))) +int32_t __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5BmethodX5Dresolve_address_streamX2Esubscribe(int32_t); +extern "C" __attribute__((import_module("wasi:sockets/ip-name-lookup@0.2.0"))) +__attribute__((import_name("resolve-addresses"))) +void __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00resolve_addresses(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:random/random@0.2.0"))) +__attribute__((import_name("get-random-bytes"))) +void __wasm_import_wasiX3ArandomX2FrandomX400X2E2X2E0X00get_random_bytes(int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:random/random@0.2.0"))) +__attribute__((import_name("get-random-u64"))) +int64_t __wasm_import_wasiX3ArandomX2FrandomX400X2E2X2E0X00get_random_u64(); +extern "C" __attribute__((import_module("wasi:random/insecure@0.2.0"))) +__attribute__((import_name("get-insecure-random-bytes"))) +void __wasm_import_wasiX3ArandomX2FinsecureX400X2E2X2E0X00get_insecure_random_bytes(int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:random/insecure@0.2.0"))) +__attribute__((import_name("get-insecure-random-u64"))) +int64_t __wasm_import_wasiX3ArandomX2FinsecureX400X2E2X2E0X00get_insecure_random_u64(); +extern "C" __attribute__((import_module("wasi:random/insecure-seed@0.2.0"))) +__attribute__((import_name("insecure-seed"))) +void __wasm_import_wasiX3ArandomX2Finsecure_seedX400X2E2X2E0X00insecure_seed(uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[resource-drop]bucket"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5Bresource_dropX5Dbucket(int32_t); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[method]bucket.get"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eget(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[method]bucket.set"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eset(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[method]bucket.delete"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Edelete(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[method]bucket.exists"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eexists(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("[method]bucket.list-keys"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Elist_keys(int32_t, int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/store@0.2.0-draft2"))) +__attribute__((import_name("open"))) +void __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00open(uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/atomics@0.2.0-draft2"))) +__attribute__((import_name("[resource-drop]cas"))) +void __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5Bresource_dropX5Dcas(int32_t); +extern "C" __attribute__((import_module("wasi:keyvalue/atomics@0.2.0-draft2"))) +__attribute__((import_name("[static]cas.new"))) +void __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5BstaticX5DcasX2Enew(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/atomics@0.2.0-draft2"))) +__attribute__((import_name("[method]cas.current"))) +void __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5BmethodX5DcasX2Ecurrent(int32_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/atomics@0.2.0-draft2"))) +__attribute__((import_name("increment"))) +void __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00increment(int32_t, uint8_t *, size_t, int64_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/atomics@0.2.0-draft2"))) +__attribute__((import_name("swap"))) +void __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00swap(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/batch@0.2.0-draft2"))) +__attribute__((import_name("get-many"))) +void __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00get_many(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/batch@0.2.0-draft2"))) +__attribute__((import_name("set-many"))) +void __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00set_many(int32_t, uint8_t *, size_t, uint8_t *); +extern "C" __attribute__((import_module("wasi:keyvalue/batch@0.2.0-draft2"))) +__attribute__((import_name("delete-many"))) +void __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00delete_many(int32_t, uint8_t *, size_t, uint8_t *); +spin::postgres3_0_0::postgres::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected spin::postgres3_0_0::postgres::Connection::Open(std::string_view address) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result9_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result9_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant8_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 1: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 2: { auto _len5 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = postgres::Error{{postgres::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len5)}}}; +} break; +case 3: { auto _len6 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len6)}}}; +} break; +case 4: { auto _len7 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len7)}}}; +} break; +} +postgres::Error variant8 = std::move(*variant8_opt); + +result9_opt.emplace(std::unexpected{std::move(variant8)}); +} +std::expected result9 = std::move(*result9_opt); +auto result10 = std::move(result9); +return result10; +} +std::expected spin::postgres3_0_0::postgres::Connection::Query(std::string_view statement, std::span params) const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * 24; + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((float*)(_base + 8)) = (float(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((double*)(_base + 8)) = (double(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + auto&& _vec9 = payload8; + auto _ptr9 = (uint8_t*)(_vec9.data()); + auto _len9 = (size_t)(_vec9.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len9; + *((uint8_t**)(_base + 8)) = _ptr9; + break; + } + case 8: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + auto&& _vec11 = payload10; + auto _ptr11 = (uint8_t*)(_vec11.data()); + auto _len11 = (size_t)(_vec11.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len11; + *((uint8_t**)(_base + 8)) = _ptr11; + break; + } + case 9: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload12))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload12))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload12))); + break; + } + case 10: { + auto& payload13 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((int8_t*)(_base + 8)) = (int32_t(std::get<0>(payload13))); + *((int8_t*)(_base + 9)) = (int32_t(std::get<1>(payload13))); + *((int8_t*)(_base + 10)) = (int32_t(std::get<2>(payload13))); + *((int32_t*)(_base + 12)) = (int32_t(std::get<3>(payload13))); + break; + } + case 11: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload14))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload14))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload14))); + *((int8_t*)(_base + 14)) = (int32_t(std::get<3>(payload14))); + *((int8_t*)(_base + 15)) = (int32_t(std::get<4>(payload14))); + *((int8_t*)(_base + 16)) = (int32_t(std::get<5>(payload14))); + *((int32_t*)(_base + 20)) = (int32_t(std::get<6>(payload14))); + break; + } + case 12: { + auto& payload15 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + *((int64_t*)(_base + 8)) = (int64_t(payload15)); + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BmethodX5DconnectionX2Equery((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result40_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + auto _base20 = *((uint8_t**) (ptr18 + sizeof(void*))); + auto _len20 = *((size_t*) (ptr18 + (2*sizeof(void*)))); + auto _result20 = wit::vector::allocate(_len20); + for (unsigned i=0; i<_len20; ++i) { + auto _base = _base20 + i * (3*sizeof(void*)); + auto _len19 = *((size_t*) (_base + sizeof(void*))); + + auto _e20 = postgres::Column{wit::string((char const*)(*((uint8_t**) (_base + 0))), _len19), (postgres::DbDataType)(int32_t) (*((uint8_t*) (_base + (2*sizeof(void*))))), }; + _result20.initialize(i, std::move(_e20)); + } + auto _base33 = *((uint8_t**) (ptr18 + (3*sizeof(void*)))); + auto _len33 = *((size_t*) (ptr18 + (4*sizeof(void*)))); + auto _result33 = wit::vector>::allocate(_len33); + for (unsigned i=0; i<_len33; ++i) { + auto _base = _base33 + i * (2*sizeof(void*)); + auto _base32 = *((uint8_t**) (_base + 0)); + auto _len32 = *((size_t*) (_base + sizeof(void*))); + auto _result32 = wit::vector::allocate(_len32); + for (unsigned i=0; i<_len32; ++i) { + auto _base = _base32 + i * 24; + std::optional variant31_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Boolean{(bool((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 1: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Int8{(int8_t((int32_t) (*((int8_t*) (_base + 8)))))}}}; + } break; + case 2: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Int16{(int16_t((int32_t) (*((int16_t*) (_base + 8)))))}}}; + } break; + case 3: { int32_t l21 = *((int32_t const*)(_base + 8)); + + variant31_opt = postgres::DbValue{{postgres::DbValue::Int32{(int32_t(l21))}}}; + } break; + case 4: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Int64{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 5: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Floating32{(float(*((float*) (_base + 8))))}}}; + } break; + case 6: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Floating64{(double(*((double*) (_base + 8))))}}}; + } break; + case 7: { auto _len22 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant31_opt = postgres::DbValue{{postgres::DbValue::Str{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len22)}}}; + } break; + case 8: { auto _len23 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant31_opt = postgres::DbValue{{postgres::DbValue::Binary{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len23)}}}; + } break; + case 9: { int32_t l24 = *((int32_t const*)(_base + 8)); + auto tuple25 = std::tuple((int32_t(l24)), (uint8_t((int32_t) (*((uint8_t*) (_base + 12))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 13)))))); + + variant31_opt = postgres::DbValue{{postgres::DbValue::Date{std::move(tuple25)}}}; + } break; + case 10: { int32_t l26 = *((int32_t const*)(_base + 12)); + auto tuple27 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (_base + 8))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 9))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 10))))), (uint32_t(l26))); + + variant31_opt = postgres::DbValue{{postgres::DbValue::Time{std::move(tuple27)}}}; +} break; +case 11: { int32_t l28 = *((int32_t const*)(_base + 8)); +int32_t l29 = *((int32_t const*)(_base + 20)); +auto tuple30 = std::tuple((int32_t(l28)), (uint8_t((int32_t) (*((uint8_t*) (_base + 12))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 13))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 14))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 15))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 16))))), (uint32_t(l29))); + +variant31_opt = postgres::DbValue{{postgres::DbValue::Datetime{std::move(tuple30)}}}; +} break; +case 12: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Timestamp{(int64_t(*((int64_t*) (_base + 8))))}}}; +} break; +case 13: { + variant31_opt = postgres::DbValue{{postgres::DbValue::DbNull{}}}; +} break; +case 14: { + variant31_opt = postgres::DbValue{{postgres::DbValue::Unsupported{}}}; +} break; +} +postgres::DbValue variant31 = std::move(*variant31_opt); +auto _e32 = std::move(variant31); +_result32.initialize(i, std::move(_e32)); +} +auto _e33 = std::move(_result32); +_result33.initialize(i, std::move(_e33)); +} + +result40_opt.emplace(std::expected(postgres::RowSet{std::move(_result20), std::move(_result33), })); +} else { +std::optional variant39_opt; +switch ((int32_t) (*((uint8_t*) (ptr18 + sizeof(void*))))) { + case 0: { auto _len34 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant39_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len34)}}}; +} break; +case 1: { auto _len35 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant39_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len35)}}}; +} break; +case 2: { auto _len36 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant39_opt = postgres::Error{{postgres::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len36)}}}; +} break; +case 3: { auto _len37 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant39_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len37)}}}; +} break; +case 4: { auto _len38 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant39_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len38)}}}; +} break; +} +postgres::Error variant39 = std::move(*variant39_opt); + +result40_opt.emplace(std::unexpected{std::move(variant39)}); +} +std::expected result40 = std::move(*result40_opt); +auto result41 = std::move(result40); +return result41; +} +std::expected spin::postgres3_0_0::postgres::Connection::Execute(std::string_view statement, std::span params) const +{ + uint64_t ret_area[((16+2*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * 24; + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((float*)(_base + 8)) = (float(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((double*)(_base + 8)) = (double(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + auto&& _vec9 = payload8; + auto _ptr9 = (uint8_t*)(_vec9.data()); + auto _len9 = (size_t)(_vec9.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len9; + *((uint8_t**)(_base + 8)) = _ptr9; + break; + } + case 8: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + auto&& _vec11 = payload10; + auto _ptr11 = (uint8_t*)(_vec11.data()); + auto _len11 = (size_t)(_vec11.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len11; + *((uint8_t**)(_base + 8)) = _ptr11; + break; + } + case 9: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload12))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload12))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload12))); + break; + } + case 10: { + auto& payload13 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((int8_t*)(_base + 8)) = (int32_t(std::get<0>(payload13))); + *((int8_t*)(_base + 9)) = (int32_t(std::get<1>(payload13))); + *((int8_t*)(_base + 10)) = (int32_t(std::get<2>(payload13))); + *((int32_t*)(_base + 12)) = (int32_t(std::get<3>(payload13))); + break; + } + case 11: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload14))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload14))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload14))); + *((int8_t*)(_base + 14)) = (int32_t(std::get<3>(payload14))); + *((int8_t*)(_base + 15)) = (int32_t(std::get<4>(payload14))); + *((int8_t*)(_base + 16)) = (int32_t(std::get<5>(payload14))); + *((int32_t*)(_base + 20)) = (int32_t(std::get<6>(payload14))); + break; + } + case 12: { + auto& payload15 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + *((int64_t*)(_base + 8)) = (int64_t(payload15)); + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX403X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result25_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + + result25_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr18 + 8)))))); + } else { + std::optional variant24_opt; + switch ((int32_t) (*((uint8_t*) (ptr18 + 8)))) { + case 0: { auto _len19 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len19)}}}; + } break; + case 1: { auto _len20 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len20)}}}; + } break; + case 2: { auto _len21 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = postgres::Error{{postgres::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len21)}}}; +} break; +case 3: { auto _len22 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + +variant24_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len22)}}}; +} break; +case 4: { auto _len23 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + +variant24_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len23)}}}; +} break; +} +postgres::Error variant24 = std::move(*variant24_opt); + +result25_opt.emplace(std::unexpected{std::move(variant24)}); +} +std::expected result25 = std::move(*result25_opt); +auto result26 = std::move(result25); +return result26; +} +spin::postgres3_0_0::postgres::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +spin::postgres4_0_0::postgres::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected spin::postgres4_0_0::postgres::Connection::Open(std::string_view address) +{ + uintptr_t ret_area[((16*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result20_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result20_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant19_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant19_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 1: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant19_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 2: { std::optional variant16_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + (2*sizeof(void*)))))) { + case 0: { auto _len5 = *((size_t*) (ptr1 + (4*sizeof(void*)))); + + + variant16_opt = postgres::QueryError{{postgres::QueryError::Text{wit::string((char const*)(*((uint8_t**) (ptr1 + (3*sizeof(void*))))), _len5)}}}; + } break; + case 1: { auto _len6 = *((size_t*) (ptr1 + (4*sizeof(void*)))); + + auto _len7 = *((size_t*) (ptr1 + (6*sizeof(void*)))); + + auto _len8 = *((size_t*) (ptr1 + (8*sizeof(void*)))); + + auto _len9 = *((size_t*) (ptr1 + (10*sizeof(void*)))); + + std::optional option11; + if ((int32_t) (*((uint8_t*) (ptr1 + (11*sizeof(void*)))))) { + auto _len10 = *((size_t*) (ptr1 + (13*sizeof(void*)))); + + + option11.emplace(wit::string((char const*)(*((uint8_t**) (ptr1 + (12*sizeof(void*))))), _len10)); + } + auto _base15 = *((uint8_t**) (ptr1 + (14*sizeof(void*)))); + auto _len15 = *((size_t*) (ptr1 + (15*sizeof(void*)))); + auto _result15 = wit::vector>::allocate(_len15); + for (unsigned i=0; i<_len15; ++i) { + auto _base = _base15 + i * (4*sizeof(void*)); + auto _len12 = *((size_t*) (_base + sizeof(void*))); + + auto _len13 = *((size_t*) (_base + (3*sizeof(void*)))); + + auto tuple14 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len12), wit::string((char const*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len13)); + auto _e15 = std::move(tuple14); + _result15.initialize(i, std::move(_e15)); + } + + variant16_opt = postgres::QueryError{{postgres::QueryError::DbError{postgres::DbError{wit::string((char const*)(*((uint8_t**) (ptr1 + (3*sizeof(void*))))), _len6), wit::string((char const*)(*((uint8_t**) (ptr1 + (5*sizeof(void*))))), _len7), wit::string((char const*)(*((uint8_t**) (ptr1 + (7*sizeof(void*))))), _len8), wit::string((char const*)(*((uint8_t**) (ptr1 + (9*sizeof(void*))))), _len9), std::move(option11), std::move(_result15), }}}}; +} break; +} +postgres::QueryError variant16 = std::move(*variant16_opt); + +variant19_opt = postgres::Error{{postgres::Error::QueryFailed{std::move(variant16)}}}; +} break; +case 3: { auto _len17 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant19_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len17)}}}; +} break; +case 4: { auto _len18 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant19_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len18)}}}; +} break; +} +postgres::Error variant19 = std::move(*variant19_opt); + +result20_opt.emplace(std::unexpected{std::move(variant19)}); +} +std::expected result20 = std::move(*result20_opt); +auto result21 = std::move(result20); +return result21; +} +std::expected spin::postgres4_0_0::postgres::Connection::Query(std::string_view statement, std::span params) const +{ + uintptr_t ret_area[((16*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec59 = params; + auto _ptr59 = (uint8_t*)(_vec59.data()); + auto _len59 = (size_t)(_vec59.size()); + for (size_t i = 0; i < _len59; ++i) { + auto _base = _ptr59 + i * (40+4*sizeof(void*)); + auto&& _iter_elem = _vec59[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((float*)(_base + 8)) = (float(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((double*)(_base + 8)) = (double(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + auto&& _vec9 = payload8; + auto _ptr9 = (uint8_t*)(_vec9.data()); + auto _len9 = (size_t)(_vec9.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len9; + *((uint8_t**)(_base + 8)) = _ptr9; + break; + } + case 8: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + auto&& _vec11 = payload10; + auto _ptr11 = (uint8_t*)(_vec11.data()); + auto _len11 = (size_t)(_vec11.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len11; + *((uint8_t**)(_base + 8)) = _ptr11; + break; + } + case 9: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload12))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload12))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload12))); + break; + } + case 10: { + auto& payload13 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((int8_t*)(_base + 8)) = (int32_t(std::get<0>(payload13))); + *((int8_t*)(_base + 9)) = (int32_t(std::get<1>(payload13))); + *((int8_t*)(_base + 10)) = (int32_t(std::get<2>(payload13))); + *((int32_t*)(_base + 12)) = (int32_t(std::get<3>(payload13))); + break; + } + case 11: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload14))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload14))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload14))); + *((int8_t*)(_base + 14)) = (int32_t(std::get<3>(payload14))); + *((int8_t*)(_base + 15)) = (int32_t(std::get<4>(payload14))); + *((int8_t*)(_base + 16)) = (int32_t(std::get<5>(payload14))); + *((int32_t*)(_base + 20)) = (int32_t(std::get<6>(payload14))); + break; + } + case 12: { + auto& payload15 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + *((int64_t*)(_base + 8)) = (int64_t(payload15)); + break; + } + case 13: { + auto& payload16 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(13)); + auto&& _vec17 = payload16; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len17; + *((uint8_t**)(_base + 8)) = _ptr17; + break; + } + case 14: { + auto& payload18 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(14)); + auto&& _vec19 = payload18; + auto _ptr19 = (uint8_t*)(_vec19.data()); + auto _len19 = (size_t)(_vec19.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len19; + *((uint8_t**)(_base + 8)) = _ptr19; + break; + } + case 15: { + auto& payload20 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(15)); + auto&& _vec21 = payload20; + auto _ptr21 = (uint8_t*)(_vec21.data()); + auto _len21 = (size_t)(_vec21.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len21; + *((uint8_t**)(_base + 8)) = _ptr21; + break; + } + case 16: { + auto& payload22 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(16)); + if ((std::get<0>(payload22)).has_value()) { + std::tuple payload24 = (std::move(std::get<0>(payload22))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + *((int32_t*)(_base + 12)) = (int32_t(std::get<0>(payload24))); + *((int8_t*)(_base + 16)) = int32_t(std::get<1>(payload24)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload22)).has_value()) { + std::tuple payload26 = (std::move(std::get<1>(payload22))).value(); + *((int8_t*)(_base + 20)) = (int32_t(1)); + *((int32_t*)(_base + 24)) = (int32_t(std::get<0>(payload26))); + *((int8_t*)(_base + 28)) = int32_t(std::get<1>(payload26)); + } else { + *((int8_t*)(_base + 20)) = (int32_t(0)); + } + break; + } + case 17: { + auto& payload27 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(17)); + if ((std::get<0>(payload27)).has_value()) { + std::tuple payload29 = (std::move(std::get<0>(payload27))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + *((int64_t*)(_base + 16)) = (int64_t(std::get<0>(payload29))); + *((int8_t*)(_base + 24)) = int32_t(std::get<1>(payload29)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload27)).has_value()) { + std::tuple payload31 = (std::move(std::get<1>(payload27))).value(); + *((int8_t*)(_base + 32)) = (int32_t(1)); + *((int64_t*)(_base + 40)) = (int64_t(std::get<0>(payload31))); + *((int8_t*)(_base + 48)) = int32_t(std::get<1>(payload31)); + } else { + *((int8_t*)(_base + 32)) = (int32_t(0)); + } + break; + } + case 18: { + auto& payload32 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(18)); + if ((std::get<0>(payload32)).has_value()) { + std::tuple payload34 = (std::move(std::get<0>(payload32))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + auto&& _vec35 = std::get<0>(payload34); + auto _ptr35 = (uint8_t*)(_vec35.data()); + auto _len35 = (size_t)(_vec35.size()); + *((size_t*)(_base + (8+2*sizeof(void*)))) = _len35; + *((uint8_t**)(_base + (8+1*sizeof(void*)))) = _ptr35; + *((int8_t*)(_base + (8+3*sizeof(void*)))) = int32_t(std::get<1>(payload34)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload32)).has_value()) { + std::tuple payload37 = (std::move(std::get<1>(payload32))).value(); + *((int8_t*)(_base + (8+4*sizeof(void*)))) = (int32_t(1)); + auto&& _vec38 = std::get<0>(payload37); + auto _ptr38 = (uint8_t*)(_vec38.data()); + auto _len38 = (size_t)(_vec38.size()); + *((size_t*)(_base + (8+6*sizeof(void*)))) = _len38; + *((uint8_t**)(_base + (8+5*sizeof(void*)))) = _ptr38; + *((int8_t*)(_base + (8+7*sizeof(void*)))) = int32_t(std::get<1>(payload37)); + } else { + *((int8_t*)(_base + (8+4*sizeof(void*)))) = (int32_t(0)); + } + break; + } + case 19: { + auto& payload39 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(19)); + auto&& _vec42 = payload39; + auto _ptr42 = (uint8_t*)(_vec42.data()); + auto _len42 = (size_t)(_vec42.size()); + for (size_t i = 0; i < _len42; ++i) { + auto _base = _ptr42 + i * 8; + auto&& _iter_elem = _vec42[i]; + if ((_iter_elem).has_value()) { + int32_t payload41 = (std::move(_iter_elem)).value(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int32_t*)(_base + 4)) = (int32_t(payload41)); + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len42; + *((uint8_t**)(_base + 8)) = _ptr42; + break; + } + case 20: { + auto& payload43 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(20)); + auto&& _vec46 = payload43; + auto _ptr46 = (uint8_t*)(_vec46.data()); + auto _len46 = (size_t)(_vec46.size()); + for (size_t i = 0; i < _len46; ++i) { + auto _base = _ptr46 + i * 16; + auto&& _iter_elem = _vec46[i]; + if ((_iter_elem).has_value()) { + int64_t payload45 = (std::move(_iter_elem)).value(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int64_t*)(_base + 8)) = (int64_t(payload45)); + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len46; + *((uint8_t**)(_base + 8)) = _ptr46; + break; + } + case 21: { + auto& payload47 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(21)); + auto&& _vec51 = payload47; + auto _ptr51 = (uint8_t*)(_vec51.data()); + auto _len51 = (size_t)(_vec51.size()); + for (size_t i = 0; i < _len51; ++i) { + auto _base = _ptr51 + i * (3*sizeof(void*)); + auto&& _iter_elem = _vec51[i]; + if ((_iter_elem).has_value()) { + std::string_view payload49 = (std::move(_iter_elem)).value().get_view(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + auto&& _vec50 = payload49; + auto _ptr50 = (uint8_t*)(_vec50.data()); + auto _len50 = (size_t)(_vec50.size()); + *((size_t*)(_base + (2*sizeof(void*)))) = _len50; + *((uint8_t**)(_base + sizeof(void*))) = _ptr50; + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len51; + *((uint8_t**)(_base + 8)) = _ptr51; + break; + } + case 22: { + auto& payload52 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(22)); + auto&& _vec56 = payload52; + auto _ptr56 = (uint8_t*)(_vec56.data()); + auto _len56 = (size_t)(_vec56.size()); + for (size_t i = 0; i < _len56; ++i) { + auto _base = _ptr56 + i * (3*sizeof(void*)); + auto&& _iter_elem = _vec56[i]; + if ((_iter_elem).has_value()) { + std::string_view payload54 = (std::move(_iter_elem)).value().get_view(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + auto&& _vec55 = payload54; + auto _ptr55 = (uint8_t*)(_vec55.data()); + auto _len55 = (size_t)(_vec55.size()); + *((size_t*)(_base + (2*sizeof(void*)))) = _len55; + *((uint8_t**)(_base + sizeof(void*))) = _ptr55; + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len56; + *((uint8_t**)(_base + 8)) = _ptr56; + break; + } + case 23: { + auto& payload57 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(23)); + *((int64_t*)(_base + 8)) = (int64_t((payload57).micros)); + *((int32_t*)(_base + 16)) = (int32_t((payload57).days)); + *((int32_t*)(_base + 20)) = (int32_t((payload57).months)); + break; + } + case 24: { + *((int8_t*)(_base + 0)) = (int32_t(24)); + break; + } + } + + } + uint8_t* ptr60 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BmethodX5DconnectionX2Equery((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr59), std::move(_len59), std::move(ptr60)); + std::optional> result131_opt; + if ((int32_t) (*((uint8_t*) (ptr60 + 0)))==0) { + auto _base64 = *((uint8_t**) (ptr60 + sizeof(void*))); + auto _len64 = *((size_t*) (ptr60 + (2*sizeof(void*)))); + auto _result64 = wit::vector::allocate(_len64); + for (unsigned i=0; i<_len64; ++i) { + auto _base = _base64 + i * (5*sizeof(void*)); + auto _len61 = *((size_t*) (_base + sizeof(void*))); + + std::optional variant63_opt; + switch ((int32_t) (*((uint8_t*) (_base + (2*sizeof(void*)))))) { + case 0: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Boolean{}}}; + } break; + case 1: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Int8{}}}; + } break; + case 2: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Int16{}}}; + } break; + case 3: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Int32{}}}; + } break; + case 4: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Int64{}}}; + } break; + case 5: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Floating32{}}}; + } break; + case 6: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Floating64{}}}; + } break; + case 7: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Str{}}}; + } break; + case 8: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Binary{}}}; + } break; + case 9: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Date{}}}; + } break; + case 10: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Time{}}}; + } break; + case 11: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Datetime{}}}; + } break; + case 12: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Timestamp{}}}; + } break; + case 13: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Uuid{}}}; + } break; + case 14: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Jsonb{}}}; + } break; + case 15: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Decimal{}}}; + } break; + case 16: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::RangeInt32{}}}; + } break; + case 17: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::RangeInt64{}}}; + } break; + case 18: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::RangeDecimal{}}}; + } break; + case 19: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::ArrayInt32{}}}; + } break; + case 20: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::ArrayInt64{}}}; + } break; + case 21: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::ArrayDecimal{}}}; + } break; + case 22: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::ArrayStr{}}}; + } break; + case 23: { + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Interval{}}}; + } break; + case 24: { auto _len62 = *((size_t*) (_base + (4*sizeof(void*)))); + + + variant63_opt = postgres::DbDataType{{postgres::DbDataType::Other{wit::string((char const*)(*((uint8_t**) (_base + (3*sizeof(void*))))), _len62)}}}; + } break; + } + postgres::DbDataType variant63 = std::move(*variant63_opt); + auto _e64 = postgres::Column{wit::string((char const*)(*((uint8_t**) (_base + 0))), _len61), std::move(variant63), }; + _result64.initialize(i, std::move(_e64)); + } + auto _base113 = *((uint8_t**) (ptr60 + (3*sizeof(void*)))); + auto _len113 = *((size_t*) (ptr60 + (4*sizeof(void*)))); + auto _result113 = wit::vector>::allocate(_len113); + for (unsigned i=0; i<_len113; ++i) { + auto _base = _base113 + i * (2*sizeof(void*)); + auto _base112 = *((uint8_t**) (_base + 0)); + auto _len112 = *((size_t*) (_base + sizeof(void*))); + auto _result112 = wit::vector::allocate(_len112); + for (unsigned i=0; i<_len112; ++i) { + auto _base = _base112 + i * (40+4*sizeof(void*)); + std::optional variant111_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Boolean{(bool((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 1: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Int8{(int8_t((int32_t) (*((int8_t*) (_base + 8)))))}}}; + } break; + case 2: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Int16{(int16_t((int32_t) (*((int16_t*) (_base + 8)))))}}}; + } break; + case 3: { int32_t l65 = *((int32_t const*)(_base + 8)); + + variant111_opt = postgres::DbValue{{postgres::DbValue::Int32{(int32_t(l65))}}}; + } break; + case 4: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Int64{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 5: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Floating32{(float(*((float*) (_base + 8))))}}}; + } break; + case 6: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Floating64{(double(*((double*) (_base + 8))))}}}; + } break; + case 7: { auto _len66 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant111_opt = postgres::DbValue{{postgres::DbValue::Str{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len66)}}}; + } break; + case 8: { auto _len67 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant111_opt = postgres::DbValue{{postgres::DbValue::Binary{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len67)}}}; + } break; + case 9: { int32_t l68 = *((int32_t const*)(_base + 8)); + auto tuple69 = std::tuple((int32_t(l68)), (uint8_t((int32_t) (*((uint8_t*) (_base + 12))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 13)))))); + + variant111_opt = postgres::DbValue{{postgres::DbValue::Date{std::move(tuple69)}}}; +} break; +case 10: { int32_t l70 = *((int32_t const*)(_base + 12)); +auto tuple71 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (_base + 8))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 9))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 10))))), (uint32_t(l70))); + +variant111_opt = postgres::DbValue{{postgres::DbValue::Time{std::move(tuple71)}}}; +} break; +case 11: { int32_t l72 = *((int32_t const*)(_base + 8)); +int32_t l73 = *((int32_t const*)(_base + 20)); +auto tuple74 = std::tuple((int32_t(l72)), (uint8_t((int32_t) (*((uint8_t*) (_base + 12))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 13))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 14))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 15))))), (uint8_t((int32_t) (*((uint8_t*) (_base + 16))))), (uint32_t(l73))); + +variant111_opt = postgres::DbValue{{postgres::DbValue::Datetime{std::move(tuple74)}}}; +} break; +case 12: { + variant111_opt = postgres::DbValue{{postgres::DbValue::Timestamp{(int64_t(*((int64_t*) (_base + 8))))}}}; +} break; +case 13: { auto _len75 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + +variant111_opt = postgres::DbValue{{postgres::DbValue::Uuid{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len75)}}}; +} break; +case 14: { auto _len76 = *((size_t*) (_base + (8+1*sizeof(void*)))); + +variant111_opt = postgres::DbValue{{postgres::DbValue::Jsonb{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len76)}}}; +} break; +case 15: { auto _len77 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + +variant111_opt = postgres::DbValue{{postgres::DbValue::Decimal{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len77)}}}; +} break; +case 16: { std::optional> option80; +if ((int32_t) (*((uint8_t*) (_base + 8)))) { + int32_t l78 = *((int32_t const*)(_base + 12)); + auto tuple79 = std::tuple((int32_t(l78)), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + 16)))); + + option80.emplace(std::move(tuple79)); +} +std::optional> option83; +if ((int32_t) (*((uint8_t*) (_base + 20)))) { + int32_t l81 = *((int32_t const*)(_base + 24)); + auto tuple82 = std::tuple((int32_t(l81)), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + 28)))); + + option83.emplace(std::move(tuple82)); +} +auto tuple84 = std::tuple>, std::optional>>(std::move(option80), std::move(option83)); + +variant111_opt = postgres::DbValue{{postgres::DbValue::RangeInt32{std::move(tuple84)}}}; +} break; +case 17: { std::optional> option86; +if ((int32_t) (*((uint8_t*) (_base + 8)))) { + auto tuple85 = std::tuple((int64_t(*((int64_t*) (_base + 16)))), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + 24)))); + + option86.emplace(std::move(tuple85)); +} +std::optional> option88; +if ((int32_t) (*((uint8_t*) (_base + 32)))) { + auto tuple87 = std::tuple((int64_t(*((int64_t*) (_base + 40)))), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + 48)))); + + option88.emplace(std::move(tuple87)); +} +auto tuple89 = std::tuple>, std::optional>>(std::move(option86), std::move(option88)); + +variant111_opt = postgres::DbValue{{postgres::DbValue::RangeInt64{std::move(tuple89)}}}; +} break; +case 18: { std::optional> option92; +if ((int32_t) (*((uint8_t*) (_base + 8)))) { + auto _len90 = *((size_t*) (_base + (8+2*sizeof(void*)))); + + auto tuple91 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + (8+1*sizeof(void*))))), _len90), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + (8+3*sizeof(void*)))))); + + option92.emplace(std::move(tuple91)); +} +std::optional> option95; +if ((int32_t) (*((uint8_t*) (_base + (8+4*sizeof(void*)))))) { + auto _len93 = *((size_t*) (_base + (8+6*sizeof(void*)))); + + auto tuple94 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + (8+5*sizeof(void*))))), _len93), (postgres::RangeBoundKind)(int32_t) (*((uint8_t*) (_base + (8+7*sizeof(void*)))))); + + option95.emplace(std::move(tuple94)); +} +auto tuple96 = std::tuple>, std::optional>>(std::move(option92), std::move(option95)); + +variant111_opt = postgres::DbValue{{postgres::DbValue::RangeDecimal{std::move(tuple96)}}}; +} break; +case 19: { auto _base99 = *((uint8_t**) (_base + 8)); +auto _len99 = *((size_t*) (_base + (8+1*sizeof(void*)))); +auto _result99 = wit::vector>::allocate(_len99); +for (unsigned i=0; i<_len99; ++i) { + auto _base = _base99 + i * 8; + std::optional option98; + if ((int32_t) (*((uint8_t*) (_base + 0)))) { + int32_t l97 = *((int32_t const*)(_base + 4)); + + option98.emplace((int32_t(l97))); + } + auto _e99 = std::move(option98); + _result99.initialize(i, std::move(_e99)); +} + +variant111_opt = postgres::DbValue{{postgres::DbValue::ArrayInt32{std::move(_result99)}}}; +} break; +case 20: { auto _base101 = *((uint8_t**) (_base + 8)); +auto _len101 = *((size_t*) (_base + (8+1*sizeof(void*)))); +auto _result101 = wit::vector>::allocate(_len101); +for (unsigned i=0; i<_len101; ++i) { + auto _base = _base101 + i * 16; + std::optional option100; + if ((int32_t) (*((uint8_t*) (_base + 0)))) { + + option100.emplace((int64_t(*((int64_t*) (_base + 8))))); + } + auto _e101 = std::move(option100); + _result101.initialize(i, std::move(_e101)); +} + +variant111_opt = postgres::DbValue{{postgres::DbValue::ArrayInt64{std::move(_result101)}}}; +} break; +case 21: { auto _base104 = *((uint8_t**) (_base + 8)); +auto _len104 = *((size_t*) (_base + (8+1*sizeof(void*)))); +auto _result104 = wit::vector>::allocate(_len104); +for (unsigned i=0; i<_len104; ++i) { + auto _base = _base104 + i * (3*sizeof(void*)); + std::optional option103; + if ((int32_t) (*((uint8_t*) (_base + 0)))) { + auto _len102 = *((size_t*) (_base + (2*sizeof(void*)))); + + + option103.emplace(wit::string((char const*)(*((uint8_t**) (_base + sizeof(void*)))), _len102)); + } + auto _e104 = std::move(option103); + _result104.initialize(i, std::move(_e104)); +} + +variant111_opt = postgres::DbValue{{postgres::DbValue::ArrayDecimal{std::move(_result104)}}}; +} break; +case 22: { auto _base107 = *((uint8_t**) (_base + 8)); +auto _len107 = *((size_t*) (_base + (8+1*sizeof(void*)))); +auto _result107 = wit::vector>::allocate(_len107); +for (unsigned i=0; i<_len107; ++i) { + auto _base = _base107 + i * (3*sizeof(void*)); + std::optional option106; + if ((int32_t) (*((uint8_t*) (_base + 0)))) { + auto _len105 = *((size_t*) (_base + (2*sizeof(void*)))); + + + option106.emplace(wit::string((char const*)(*((uint8_t**) (_base + sizeof(void*)))), _len105)); + } + auto _e107 = std::move(option106); + _result107.initialize(i, std::move(_e107)); +} + +variant111_opt = postgres::DbValue{{postgres::DbValue::ArrayStr{std::move(_result107)}}}; +} break; +case 23: { int32_t l108 = *((int32_t const*)(_base + 16)); +int32_t l109 = *((int32_t const*)(_base + 20)); + +variant111_opt = postgres::DbValue{{postgres::DbValue::Interval{postgres::Interval{(int64_t(*((int64_t*) (_base + 8)))), (int32_t(l108)), (int32_t(l109)), }}}}; +} break; +case 24: { + variant111_opt = postgres::DbValue{{postgres::DbValue::DbNull{}}}; +} break; +case 25: { auto _len110 = *((size_t*) (_base + (8+1*sizeof(void*)))); + +variant111_opt = postgres::DbValue{{postgres::DbValue::Unsupported{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len110)}}}; +} break; +} +postgres::DbValue variant111 = std::move(*variant111_opt); +auto _e112 = std::move(variant111); +_result112.initialize(i, std::move(_e112)); +} +auto _e113 = std::move(_result112); +_result113.initialize(i, std::move(_e113)); +} + +result131_opt.emplace(std::expected(postgres::RowSet{std::move(_result64), std::move(_result113), })); +} else { +std::optional variant130_opt; +switch ((int32_t) (*((uint8_t*) (ptr60 + sizeof(void*))))) { + case 0: { auto _len114 = *((size_t*) (ptr60 + (3*sizeof(void*)))); + + + variant130_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr60 + (2*sizeof(void*))))), _len114)}}}; +} break; +case 1: { auto _len115 = *((size_t*) (ptr60 + (3*sizeof(void*)))); + + +variant130_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr60 + (2*sizeof(void*))))), _len115)}}}; +} break; +case 2: { std::optional variant127_opt; +switch ((int32_t) (*((uint8_t*) (ptr60 + (2*sizeof(void*)))))) { + case 0: { auto _len116 = *((size_t*) (ptr60 + (4*sizeof(void*)))); + + + variant127_opt = postgres::QueryError{{postgres::QueryError::Text{wit::string((char const*)(*((uint8_t**) (ptr60 + (3*sizeof(void*))))), _len116)}}}; +} break; +case 1: { auto _len117 = *((size_t*) (ptr60 + (4*sizeof(void*)))); + +auto _len118 = *((size_t*) (ptr60 + (6*sizeof(void*)))); + +auto _len119 = *((size_t*) (ptr60 + (8*sizeof(void*)))); + +auto _len120 = *((size_t*) (ptr60 + (10*sizeof(void*)))); + +std::optional option122; +if ((int32_t) (*((uint8_t*) (ptr60 + (11*sizeof(void*)))))) { + auto _len121 = *((size_t*) (ptr60 + (13*sizeof(void*)))); + + + option122.emplace(wit::string((char const*)(*((uint8_t**) (ptr60 + (12*sizeof(void*))))), _len121)); +} +auto _base126 = *((uint8_t**) (ptr60 + (14*sizeof(void*)))); +auto _len126 = *((size_t*) (ptr60 + (15*sizeof(void*)))); +auto _result126 = wit::vector>::allocate(_len126); +for (unsigned i=0; i<_len126; ++i) { + auto _base = _base126 + i * (4*sizeof(void*)); + auto _len123 = *((size_t*) (_base + sizeof(void*))); + + auto _len124 = *((size_t*) (_base + (3*sizeof(void*)))); + + auto tuple125 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len123), wit::string((char const*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len124)); + auto _e126 = std::move(tuple125); + _result126.initialize(i, std::move(_e126)); +} + +variant127_opt = postgres::QueryError{{postgres::QueryError::DbError{postgres::DbError{wit::string((char const*)(*((uint8_t**) (ptr60 + (3*sizeof(void*))))), _len117), wit::string((char const*)(*((uint8_t**) (ptr60 + (5*sizeof(void*))))), _len118), wit::string((char const*)(*((uint8_t**) (ptr60 + (7*sizeof(void*))))), _len119), wit::string((char const*)(*((uint8_t**) (ptr60 + (9*sizeof(void*))))), _len120), std::move(option122), std::move(_result126), }}}}; +} break; +} +postgres::QueryError variant127 = std::move(*variant127_opt); + +variant130_opt = postgres::Error{{postgres::Error::QueryFailed{std::move(variant127)}}}; +} break; +case 3: { auto _len128 = *((size_t*) (ptr60 + (3*sizeof(void*)))); + + +variant130_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr60 + (2*sizeof(void*))))), _len128)}}}; +} break; +case 4: { auto _len129 = *((size_t*) (ptr60 + (3*sizeof(void*)))); + + +variant130_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr60 + (2*sizeof(void*))))), _len129)}}}; +} break; +} +postgres::Error variant130 = std::move(*variant130_opt); + +result131_opt.emplace(std::unexpected{std::move(variant130)}); +} +std::expected result131 = std::move(*result131_opt); +auto result132 = std::move(result131); +return result132; +} +std::expected spin::postgres4_0_0::postgres::Connection::Execute(std::string_view statement, std::span params) const +{ + uint64_t ret_area[((16+14*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec59 = params; + auto _ptr59 = (uint8_t*)(_vec59.data()); + auto _len59 = (size_t)(_vec59.size()); + for (size_t i = 0; i < _len59; ++i) { + auto _base = _ptr59 + i * (40+4*sizeof(void*)); + auto&& _iter_elem = _vec59[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((float*)(_base + 8)) = (float(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((double*)(_base + 8)) = (double(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + auto&& _vec9 = payload8; + auto _ptr9 = (uint8_t*)(_vec9.data()); + auto _len9 = (size_t)(_vec9.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len9; + *((uint8_t**)(_base + 8)) = _ptr9; + break; + } + case 8: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + auto&& _vec11 = payload10; + auto _ptr11 = (uint8_t*)(_vec11.data()); + auto _len11 = (size_t)(_vec11.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len11; + *((uint8_t**)(_base + 8)) = _ptr11; + break; + } + case 9: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload12))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload12))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload12))); + break; + } + case 10: { + auto& payload13 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((int8_t*)(_base + 8)) = (int32_t(std::get<0>(payload13))); + *((int8_t*)(_base + 9)) = (int32_t(std::get<1>(payload13))); + *((int8_t*)(_base + 10)) = (int32_t(std::get<2>(payload13))); + *((int32_t*)(_base + 12)) = (int32_t(std::get<3>(payload13))); + break; + } + case 11: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + *((int32_t*)(_base + 8)) = (int32_t(std::get<0>(payload14))); + *((int8_t*)(_base + 12)) = (int32_t(std::get<1>(payload14))); + *((int8_t*)(_base + 13)) = (int32_t(std::get<2>(payload14))); + *((int8_t*)(_base + 14)) = (int32_t(std::get<3>(payload14))); + *((int8_t*)(_base + 15)) = (int32_t(std::get<4>(payload14))); + *((int8_t*)(_base + 16)) = (int32_t(std::get<5>(payload14))); + *((int32_t*)(_base + 20)) = (int32_t(std::get<6>(payload14))); + break; + } + case 12: { + auto& payload15 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + *((int64_t*)(_base + 8)) = (int64_t(payload15)); + break; + } + case 13: { + auto& payload16 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(13)); + auto&& _vec17 = payload16; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len17; + *((uint8_t**)(_base + 8)) = _ptr17; + break; + } + case 14: { + auto& payload18 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(14)); + auto&& _vec19 = payload18; + auto _ptr19 = (uint8_t*)(_vec19.data()); + auto _len19 = (size_t)(_vec19.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len19; + *((uint8_t**)(_base + 8)) = _ptr19; + break; + } + case 15: { + auto& payload20 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(15)); + auto&& _vec21 = payload20; + auto _ptr21 = (uint8_t*)(_vec21.data()); + auto _len21 = (size_t)(_vec21.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len21; + *((uint8_t**)(_base + 8)) = _ptr21; + break; + } + case 16: { + auto& payload22 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(16)); + if ((std::get<0>(payload22)).has_value()) { + std::tuple payload24 = (std::move(std::get<0>(payload22))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + *((int32_t*)(_base + 12)) = (int32_t(std::get<0>(payload24))); + *((int8_t*)(_base + 16)) = int32_t(std::get<1>(payload24)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload22)).has_value()) { + std::tuple payload26 = (std::move(std::get<1>(payload22))).value(); + *((int8_t*)(_base + 20)) = (int32_t(1)); + *((int32_t*)(_base + 24)) = (int32_t(std::get<0>(payload26))); + *((int8_t*)(_base + 28)) = int32_t(std::get<1>(payload26)); + } else { + *((int8_t*)(_base + 20)) = (int32_t(0)); + } + break; + } + case 17: { + auto& payload27 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(17)); + if ((std::get<0>(payload27)).has_value()) { + std::tuple payload29 = (std::move(std::get<0>(payload27))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + *((int64_t*)(_base + 16)) = (int64_t(std::get<0>(payload29))); + *((int8_t*)(_base + 24)) = int32_t(std::get<1>(payload29)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload27)).has_value()) { + std::tuple payload31 = (std::move(std::get<1>(payload27))).value(); + *((int8_t*)(_base + 32)) = (int32_t(1)); + *((int64_t*)(_base + 40)) = (int64_t(std::get<0>(payload31))); + *((int8_t*)(_base + 48)) = int32_t(std::get<1>(payload31)); + } else { + *((int8_t*)(_base + 32)) = (int32_t(0)); + } + break; + } + case 18: { + auto& payload32 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(18)); + if ((std::get<0>(payload32)).has_value()) { + std::tuple payload34 = (std::move(std::get<0>(payload32))).value(); + *((int8_t*)(_base + 8)) = (int32_t(1)); + auto&& _vec35 = std::get<0>(payload34); + auto _ptr35 = (uint8_t*)(_vec35.data()); + auto _len35 = (size_t)(_vec35.size()); + *((size_t*)(_base + (8+2*sizeof(void*)))) = _len35; + *((uint8_t**)(_base + (8+1*sizeof(void*)))) = _ptr35; + *((int8_t*)(_base + (8+3*sizeof(void*)))) = int32_t(std::get<1>(payload34)); + } else { + *((int8_t*)(_base + 8)) = (int32_t(0)); + } + if ((std::get<1>(payload32)).has_value()) { + std::tuple payload37 = (std::move(std::get<1>(payload32))).value(); + *((int8_t*)(_base + (8+4*sizeof(void*)))) = (int32_t(1)); + auto&& _vec38 = std::get<0>(payload37); + auto _ptr38 = (uint8_t*)(_vec38.data()); + auto _len38 = (size_t)(_vec38.size()); + *((size_t*)(_base + (8+6*sizeof(void*)))) = _len38; + *((uint8_t**)(_base + (8+5*sizeof(void*)))) = _ptr38; + *((int8_t*)(_base + (8+7*sizeof(void*)))) = int32_t(std::get<1>(payload37)); + } else { + *((int8_t*)(_base + (8+4*sizeof(void*)))) = (int32_t(0)); + } + break; + } + case 19: { + auto& payload39 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(19)); + auto&& _vec42 = payload39; + auto _ptr42 = (uint8_t*)(_vec42.data()); + auto _len42 = (size_t)(_vec42.size()); + for (size_t i = 0; i < _len42; ++i) { + auto _base = _ptr42 + i * 8; + auto&& _iter_elem = _vec42[i]; + if ((_iter_elem).has_value()) { + int32_t payload41 = (std::move(_iter_elem)).value(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int32_t*)(_base + 4)) = (int32_t(payload41)); + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len42; + *((uint8_t**)(_base + 8)) = _ptr42; + break; + } + case 20: { + auto& payload43 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(20)); + auto&& _vec46 = payload43; + auto _ptr46 = (uint8_t*)(_vec46.data()); + auto _len46 = (size_t)(_vec46.size()); + for (size_t i = 0; i < _len46; ++i) { + auto _base = _ptr46 + i * 16; + auto&& _iter_elem = _vec46[i]; + if ((_iter_elem).has_value()) { + int64_t payload45 = (std::move(_iter_elem)).value(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int64_t*)(_base + 8)) = (int64_t(payload45)); + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len46; + *((uint8_t**)(_base + 8)) = _ptr46; + break; + } + case 21: { + auto& payload47 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(21)); + auto&& _vec51 = payload47; + auto _ptr51 = (uint8_t*)(_vec51.data()); + auto _len51 = (size_t)(_vec51.size()); + for (size_t i = 0; i < _len51; ++i) { + auto _base = _ptr51 + i * (3*sizeof(void*)); + auto&& _iter_elem = _vec51[i]; + if ((_iter_elem).has_value()) { + std::string_view payload49 = (std::move(_iter_elem)).value().get_view(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + auto&& _vec50 = payload49; + auto _ptr50 = (uint8_t*)(_vec50.data()); + auto _len50 = (size_t)(_vec50.size()); + *((size_t*)(_base + (2*sizeof(void*)))) = _len50; + *((uint8_t**)(_base + sizeof(void*))) = _ptr50; + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len51; + *((uint8_t**)(_base + 8)) = _ptr51; + break; + } + case 22: { + auto& payload52 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(22)); + auto&& _vec56 = payload52; + auto _ptr56 = (uint8_t*)(_vec56.data()); + auto _len56 = (size_t)(_vec56.size()); + for (size_t i = 0; i < _len56; ++i) { + auto _base = _ptr56 + i * (3*sizeof(void*)); + auto&& _iter_elem = _vec56[i]; + if ((_iter_elem).has_value()) { + std::string_view payload54 = (std::move(_iter_elem)).value().get_view(); + *((int8_t*)(_base + 0)) = (int32_t(1)); + auto&& _vec55 = payload54; + auto _ptr55 = (uint8_t*)(_vec55.data()); + auto _len55 = (size_t)(_vec55.size()); + *((size_t*)(_base + (2*sizeof(void*)))) = _len55; + *((uint8_t**)(_base + sizeof(void*))) = _ptr55; + } else { + *((int8_t*)(_base + 0)) = (int32_t(0)); + } + + } + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len56; + *((uint8_t**)(_base + 8)) = _ptr56; + break; + } + case 23: { + auto& payload57 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(23)); + *((int64_t*)(_base + 8)) = (int64_t((payload57).micros)); + *((int32_t*)(_base + 16)) = (int32_t((payload57).days)); + *((int32_t*)(_base + 20)) = (int32_t((payload57).months)); + break; + } + case 24: { + *((int8_t*)(_base + 0)) = (int32_t(24)); + break; + } + } + + } + uint8_t* ptr60 = (uint8_t*)(&ret_area); + __wasm_import_spinX3ApostgresX2FpostgresX404X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr59), std::move(_len59), std::move(ptr60)); + std::optional> result78_opt; + if ((int32_t) (*((uint8_t*) (ptr60 + 0)))==0) { + + result78_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr60 + 8)))))); + } else { + std::optional variant77_opt; + switch ((int32_t) (*((uint8_t*) (ptr60 + 8)))) { + case 0: { auto _len61 = *((size_t*) (ptr60 + (8+2*sizeof(void*)))); + + + variant77_opt = postgres::Error{{postgres::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+1*sizeof(void*))))), _len61)}}}; + } break; + case 1: { auto _len62 = *((size_t*) (ptr60 + (8+2*sizeof(void*)))); + + + variant77_opt = postgres::Error{{postgres::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+1*sizeof(void*))))), _len62)}}}; + } break; + case 2: { std::optional variant74_opt; + switch ((int32_t) (*((uint8_t*) (ptr60 + (8+1*sizeof(void*)))))) { + case 0: { auto _len63 = *((size_t*) (ptr60 + (8+3*sizeof(void*)))); + + + variant74_opt = postgres::QueryError{{postgres::QueryError::Text{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+2*sizeof(void*))))), _len63)}}}; + } break; + case 1: { auto _len64 = *((size_t*) (ptr60 + (8+3*sizeof(void*)))); + + auto _len65 = *((size_t*) (ptr60 + (8+5*sizeof(void*)))); + + auto _len66 = *((size_t*) (ptr60 + (8+7*sizeof(void*)))); + + auto _len67 = *((size_t*) (ptr60 + (8+9*sizeof(void*)))); + + std::optional option69; + if ((int32_t) (*((uint8_t*) (ptr60 + (8+10*sizeof(void*)))))) { + auto _len68 = *((size_t*) (ptr60 + (8+12*sizeof(void*)))); + + + option69.emplace(wit::string((char const*)(*((uint8_t**) (ptr60 + (8+11*sizeof(void*))))), _len68)); + } + auto _base73 = *((uint8_t**) (ptr60 + (8+13*sizeof(void*)))); + auto _len73 = *((size_t*) (ptr60 + (8+14*sizeof(void*)))); + auto _result73 = wit::vector>::allocate(_len73); + for (unsigned i=0; i<_len73; ++i) { + auto _base = _base73 + i * (4*sizeof(void*)); + auto _len70 = *((size_t*) (_base + sizeof(void*))); + + auto _len71 = *((size_t*) (_base + (3*sizeof(void*)))); + + auto tuple72 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len70), wit::string((char const*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len71)); + auto _e73 = std::move(tuple72); + _result73.initialize(i, std::move(_e73)); + } + + variant74_opt = postgres::QueryError{{postgres::QueryError::DbError{postgres::DbError{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+2*sizeof(void*))))), _len64), wit::string((char const*)(*((uint8_t**) (ptr60 + (8+4*sizeof(void*))))), _len65), wit::string((char const*)(*((uint8_t**) (ptr60 + (8+6*sizeof(void*))))), _len66), wit::string((char const*)(*((uint8_t**) (ptr60 + (8+8*sizeof(void*))))), _len67), std::move(option69), std::move(_result73), }}}}; +} break; +} +postgres::QueryError variant74 = std::move(*variant74_opt); + +variant77_opt = postgres::Error{{postgres::Error::QueryFailed{std::move(variant74)}}}; +} break; +case 3: { auto _len75 = *((size_t*) (ptr60 + (8+2*sizeof(void*)))); + + +variant77_opt = postgres::Error{{postgres::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+1*sizeof(void*))))), _len75)}}}; +} break; +case 4: { auto _len76 = *((size_t*) (ptr60 + (8+2*sizeof(void*)))); + + +variant77_opt = postgres::Error{{postgres::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr60 + (8+1*sizeof(void*))))), _len76)}}}; +} break; +} +postgres::Error variant77 = std::move(*variant77_opt); + +result78_opt.emplace(std::unexpected{std::move(variant77)}); +} +std::expected result78 = std::move(*result78_opt); +auto result79 = std::move(result78); +return result79; +} +spin::postgres4_0_0::postgres::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +spin::sqlite::sqlite::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected spin::sqlite::sqlite::Connection::Open(std::string_view database) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = database; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = sqlite::Error{{sqlite::Error::NoSuchDatabase{}}}; + } break; + case 1: { + variant4_opt = sqlite::Error{{sqlite::Error::AccessDenied{}}}; + } break; + case 2: { + variant4_opt = sqlite::Error{{sqlite::Error::InvalidConnection{}}}; + } break; + case 3: { + variant4_opt = sqlite::Error{{sqlite::Error::DatabaseFull{}}}; + } break; + case 4: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = sqlite::Error{{sqlite::Error::Io{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + sqlite::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected spin::sqlite::sqlite::Connection::Execute(std::string_view statement, std::span parameters) const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec8 = parameters; + auto _ptr8 = (uint8_t*)(_vec8.data()); + auto _len8 = (size_t)(_vec8.size()); + for (size_t i = 0; i < _len8; ++i) { + auto _base = _ptr8 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec8[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int64_t*)(_base + 8)) = (int64_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((double*)(_base + 8)) = (double(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + auto&& _vec4 = payload3; + auto _ptr4 = (uint8_t*)(_vec4.data()); + auto _len4 = (size_t)(_vec4.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len4; + *((uint8_t**)(_base + 8)) = _ptr4; + break; + } + case 3: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + auto&& _vec6 = payload5; + auto _ptr6 = (uint8_t*)(_vec6.data()); + auto _len6 = (size_t)(_vec6.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len6; + *((uint8_t**)(_base + 8)) = _ptr6; + break; + } + case 4: { + *((int8_t*)(_base + 0)) = (int32_t(4)); + break; + } + } + + } + uint8_t* ptr9 = (uint8_t*)(&ret_area); + __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr8), std::move(_len8), std::move(ptr9)); + std::optional> result19_opt; + if ((int32_t) (*((uint8_t*) (ptr9 + 0)))==0) { + auto _base11 = *((uint8_t**) (ptr9 + sizeof(void*))); + auto _len11 = *((size_t*) (ptr9 + (2*sizeof(void*)))); + auto _result11 = wit::vector::allocate(_len11); + for (unsigned i=0; i<_len11; ++i) { + auto _base = _base11 + i * (2*sizeof(void*)); + auto _len10 = *((size_t*) (_base + sizeof(void*))); + + auto _e11 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len10); + _result11.initialize(i, std::move(_e11)); + } + auto _base16 = *((uint8_t**) (ptr9 + (3*sizeof(void*)))); + auto _len16 = *((size_t*) (ptr9 + (4*sizeof(void*)))); + auto _result16 = wit::vector::allocate(_len16); + for (unsigned i=0; i<_len16; ++i) { + auto _base = _base16 + i * (2*sizeof(void*)); + auto _base15 = *((uint8_t**) (_base + 0)); + auto _len15 = *((size_t*) (_base + sizeof(void*))); + auto _result15 = wit::vector::allocate(_len15); + for (unsigned i=0; i<_len15; ++i) { + auto _base = _base15 + i * (8+2*sizeof(void*)); + std::optional variant14_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant14_opt = sqlite::Value{{sqlite::Value::Integer{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 1: { + variant14_opt = sqlite::Value{{sqlite::Value::Real{(double(*((double*) (_base + 8))))}}}; + } break; + case 2: { auto _len12 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant14_opt = sqlite::Value{{sqlite::Value::Text{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len12)}}}; + } break; + case 3: { auto _len13 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant14_opt = sqlite::Value{{sqlite::Value::Blob{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len13)}}}; + } break; + case 4: { + variant14_opt = sqlite::Value{{sqlite::Value::Null{}}}; + } break; + } + sqlite::Value variant14 = std::move(*variant14_opt); + auto _e15 = std::move(variant14); + _result15.initialize(i, std::move(_e15)); + } + auto _e16 = sqlite::RowResult{std::move(_result15), }; + _result16.initialize(i, std::move(_e16)); +} + +result19_opt.emplace(std::expected(sqlite::QueryResult{std::move(_result11), std::move(_result16), })); +} else { +std::optional variant18_opt; +switch ((int32_t) (*((uint8_t*) (ptr9 + sizeof(void*))))) { + case 0: { + variant18_opt = sqlite::Error{{sqlite::Error::NoSuchDatabase{}}}; + } break; + case 1: { + variant18_opt = sqlite::Error{{sqlite::Error::AccessDenied{}}}; + } break; + case 2: { + variant18_opt = sqlite::Error{{sqlite::Error::InvalidConnection{}}}; + } break; + case 3: { + variant18_opt = sqlite::Error{{sqlite::Error::DatabaseFull{}}}; + } break; + case 4: { auto _len17 = *((size_t*) (ptr9 + (3*sizeof(void*)))); + + + variant18_opt = sqlite::Error{{sqlite::Error::Io{wit::string((char const*)(*((uint8_t**) (ptr9 + (2*sizeof(void*))))), _len17)}}}; +} break; +} +sqlite::Error variant18 = std::move(*variant18_opt); + +result19_opt.emplace(std::unexpected{std::move(variant18)}); +} +std::expected result19 = std::move(*result19_opt); +auto result20 = std::move(result19); +return result20; +} +int64_t spin::sqlite::sqlite::Connection::LastInsertRowid() const +{ + auto ret = __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Elast_insert_rowid((*this).get_handle()); + return (int64_t(ret)); +} +uint64_t spin::sqlite::sqlite::Connection::Changes() const +{ + auto ret = __wasm_import_spinX3AsqliteX2FsqliteX403X2E0X2E0X00X5BmethodX5DconnectionX2Echanges((*this).get_handle()); + return (uint64_t(ret)); +} +spin::sqlite::sqlite::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected, wasi::config::store::Error> wasi::config::store::Get(std::string_view key) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AconfigX2FstoreX400X2E2X2E0_draft_2024_09_27X00get(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional, Error>> result7_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + option3.emplace(wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)); + } + + result7_opt.emplace(std::expected, Error>(std::move(option3))); + } else { + std::optional variant6_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant6_opt = Error{{Error::Upstream{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 1: { auto _len5 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant6_opt = Error{{Error::Io{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len5)}}}; + } break; +} +Error variant6 = std::move(*variant6_opt); + +result7_opt.emplace(std::unexpected{std::move(variant6)}); +} +std::expected, Error> result7 = std::move(*result7_opt); +auto result8 = std::move(result7); +return result8; +} +std::expected>, wasi::config::store::Error> wasi::config::store::GetAll() +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AconfigX2FstoreX400X2E2X2E0_draft_2024_09_27X00get_all(std::move(ptr0)); + std::optional>, Error>> result8_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _base4 = *((uint8_t**) (ptr0 + sizeof(void*))); + auto _len4 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + auto _result4 = wit::vector>::allocate(_len4); + for (unsigned i=0; i<_len4; ++i) { + auto _base = _base4 + i * (4*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + + auto _len2 = *((size_t*) (_base + (3*sizeof(void*)))); + + auto tuple3 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len1), wit::string((char const*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len2)); + auto _e4 = std::move(tuple3); + _result4.initialize(i, std::move(_e4)); + } + + result8_opt.emplace(std::expected>, Error>(std::move(_result4))); + } else { + std::optional variant7_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { auto _len5 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant7_opt = Error{{Error::Upstream{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len5)}}}; + } break; + case 1: { auto _len6 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant7_opt = Error{{Error::Io{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len6)}}}; + } break; +} +Error variant7 = std::move(*variant7_opt); + +result8_opt.emplace(std::unexpected{std::move(variant7)}); +} +std::expected>, Error> result8 = std::move(*result8_opt); +auto result9 = std::move(result8); +return result9; +} +wasi::io0_2_0::poll::Pollable::~Pollable() +{ + if (handle>=0) { + __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5Bresource_dropX5Dpollable(handle); + } +} +bool wasi::io0_2_0::poll::Pollable::Ready() const +{ + auto ret = __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5BmethodX5DpollableX2Eready((*this).get_handle()); + return (bool(ret)); +} +void wasi::io0_2_0::poll::Pollable::Block() const +{ + __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00X5BmethodX5DpollableX2Eblock((*this).get_handle()); +} +wasi::io0_2_0::poll::Pollable::Pollable(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wit::vector wasi::io0_2_0::poll::Poll(std::span const> in) +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = in; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + for (size_t i = 0; i < _len0; ++i) { + auto _base = _ptr0 + i * 4; + auto&& _iter_elem = _vec0[i]; + *((int32_t*)(_base + 0)) = _iter_elem.get().get_handle(); + + } + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FpollX400X2E2X2E0X00poll(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + auto _len2 = *((size_t*) (ptr1 + sizeof(void*))); + auto result3 = wit::vector((uint32_t*)(*((uint8_t**) (ptr1 + 0))), _len2); + return result3; +} +uint64_t wasi::clocks0_2_0::monotonic_clock::Now() +{ + auto ret = __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00now(); + return (uint64_t(ret)); +} +uint64_t wasi::clocks0_2_0::monotonic_clock::Resolution() +{ + auto ret = __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00resolution(); + return (uint64_t(ret)); +} +wasi::io0_2_0::poll::Pollable wasi::clocks0_2_0::monotonic_clock::SubscribeInstant(uint64_t when) +{ + auto ret = __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00subscribe_instant((int64_t(when))); + return wit::ResourceImportBase{ret}; +} +wasi::io0_2_0::poll::Pollable wasi::clocks0_2_0::monotonic_clock::SubscribeDuration(uint64_t when) +{ + auto ret = __wasm_import_wasiX3AclocksX2Fmonotonic_clockX400X2E2X2E0X00subscribe_duration((int64_t(when))); + return wit::ResourceImportBase{ret}; +} +wasi::io0_2_0::error::Error::~Error() +{ + if (handle>=0) { + __wasm_import_wasiX3AioX2FerrorX400X2E2X2E0X00X5Bresource_dropX5Derror(handle); + } +} +wit::string wasi::io0_2_0::error::Error::ToDebugString() const +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FerrorX400X2E2X2E0X00X5BmethodX5DerrorX2Eto_debug_string((*this).get_handle(), std::move(ptr0)); + auto _len1 = *((size_t*) (ptr0 + sizeof(void*))); + + auto result2 = wit::string((char const*)(*((uint8_t**) (ptr0 + 0))), _len1); + return result2; +} +wasi::io0_2_0::error::Error::Error(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::io0_2_0::streams::InputStream::~InputStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5Bresource_dropX5Dinput_stream(handle); + } +} +std::expected, wasi::io0_2_0::streams::StreamError> wasi::io0_2_0::streams::InputStream::Read(uint64_t len) const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eread((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional, streams::StreamError>> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + result4_opt.emplace(std::expected, streams::StreamError>(wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { int32_t l2 = *((int32_t const*)(ptr0 + (4+1*sizeof(void*)))); + + variant3_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l2}}}}; + } break; + case 1: { + variant3_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected, streams::StreamError> result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected, wasi::io0_2_0::streams::StreamError> wasi::io0_2_0::streams::InputStream::BlockingRead(uint64_t len) const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eblocking_read((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional, streams::StreamError>> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + result4_opt.emplace(std::expected, streams::StreamError>(wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { int32_t l2 = *((int32_t const*)(ptr0 + (4+1*sizeof(void*)))); + + variant3_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l2}}}}; + } break; + case 1: { + variant3_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected, streams::StreamError> result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::io0_2_0::streams::InputStream::Skip(uint64_t len) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eskip((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 12)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::InputStream::BlockingSkip(uint64_t len) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Eblocking_skip((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 12)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +wasi::io0_2_0::poll::Pollable wasi::io0_2_0::streams::InputStream::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Dinput_streamX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::io0_2_0::streams::InputStream::InputStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::io0_2_0::streams::OutputStream::~OutputStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5Bresource_dropX5Doutput_stream(handle); + } +} +std::expected wasi::io0_2_0::streams::OutputStream::CheckWrite() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Echeck_write((*this).get_handle(), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 12)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::OutputStream::Write(std::span contents) const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + auto&& _vec0 = contents; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Ewrite((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected()); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + 4)))) { + case 0: { int32_t l2 = *((int32_t const*)(ptr1 + 8)); + + variant3_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l2}}}}; + } break; + case 1: { + variant3_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::io0_2_0::streams::OutputStream::BlockingWriteAndFlush(std::span contents) const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + auto&& _vec0 = contents; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_write_and_flush((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected()); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + 4)))) { + case 0: { int32_t l2 = *((int32_t const*)(ptr1 + 8)); + + variant3_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l2}}}}; + } break; + case 1: { + variant3_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::io0_2_0::streams::OutputStream::Flush() const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eflush((*this).get_handle(), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 8)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::OutputStream::BlockingFlush() const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_flush((*this).get_handle(), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 8)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +wasi::io0_2_0::poll::Pollable wasi::io0_2_0::streams::OutputStream::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::expected wasi::io0_2_0::streams::OutputStream::WriteZeroes(uint64_t len) const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Ewrite_zeroes((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 8)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::OutputStream::BlockingWriteZeroesAndFlush(uint64_t len) const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_write_zeroes_and_flush((*this).get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 8)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::OutputStream::Splice(std::reference_wrapper src, uint64_t len) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Esplice((*this).get_handle(), src.get().get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 12)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +std::expected wasi::io0_2_0::streams::OutputStream::BlockingSplice(std::reference_wrapper src, uint64_t len) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AioX2FstreamsX400X2E2X2E0X00X5BmethodX5Doutput_streamX2Eblocking_splice((*this).get_handle(), src.get().get_handle(), (int64_t(len)), std::move(ptr0)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result3_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { int32_t l1 = *((int32_t const*)(ptr0 + 12)); + + variant2_opt = streams::StreamError{{streams::StreamError::LastOperationFailed{wit::ResourceImportBase{l1}}}}; + } break; + case 1: { + variant2_opt = streams::StreamError{{streams::StreamError::Closed{}}}; + } break; + } + streams::StreamError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); +} +std::expected result3 = std::move(*result3_opt); +auto result4 = std::move(result3); +return result4; +} +wasi::io0_2_0::streams::OutputStream::OutputStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::Fields::~Fields() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfields(handle); + } +} +wasi::http0_2_0::types::Fields::Fields() +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Dfields(); + this->handle = wit::ResourceImportBase{ret}.into_handle(); +} +std::expected wasi::http0_2_0::types::Fields::FromList(std::span> const> entries) +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + auto&& _vec2 = entries; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (4*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec0 = std::get<0>(_iter_elem); + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + auto&& _vec1 = std::get<1>(_iter_elem); + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + (3*sizeof(void*)))) = _len1; + *((uint8_t**)(_base + (2*sizeof(void*)))) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5DfieldsX2Efrom_list(std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + int32_t l4 = *((int32_t const*)(ptr3 + 4)); + + result6_opt.emplace(std::expected(wit::ResourceImportBase{l4})); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + 4)))) { + case 0: { + variant5_opt = types::HeaderError{{types::HeaderError::InvalidSyntax{}}}; + } break; + case 1: { + variant5_opt = types::HeaderError{{types::HeaderError::Forbidden{}}}; + } break; + case 2: { + variant5_opt = types::HeaderError{{types::HeaderError::Immutable{}}}; + } break; + } + types::HeaderError variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); + } + std::expected result6 = std::move(*result6_opt); + auto result7 = std::move(result6); + return result7; +} +wit::vector> wasi::http0_2_0::types::Fields::Get(std::string_view name) const +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eget((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + auto _base3 = *((uint8_t**) (ptr1 + 0)); + auto _len3 = *((size_t*) (ptr1 + sizeof(void*))); + auto _result3 = wit::vector>::allocate(_len3); + for (unsigned i=0; i<_len3; ++i) { + auto _base = _base3 + i * (2*sizeof(void*)); + auto _len2 = *((size_t*) (_base + sizeof(void*))); + auto _e3 = wit::vector((uint8_t*)(*((uint8_t**) (_base + 0))), _len2); + _result3.initialize(i, std::move(_e3)); + } + auto result4 = std::move(_result3); + return result4; +} +bool wasi::http0_2_0::types::Fields::Has(std::string_view name) const +{ + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Ehas((*this).get_handle(), std::move(_ptr0), std::move(_len0)); + return (bool(ret)); +} +std::expected wasi::http0_2_0::types::Fields::Set(std::string_view name, std::span const> value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec2 = value; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec1 = _iter_elem; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + sizeof(void*))) = _len1; + *((uint8_t**)(_base + 0)) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eset((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + 1)))) { + case 0: { + variant4_opt = types::HeaderError{{types::HeaderError::InvalidSyntax{}}}; + } break; + case 1: { + variant4_opt = types::HeaderError{{types::HeaderError::Forbidden{}}}; + } break; + case 2: { + variant4_opt = types::HeaderError{{types::HeaderError::Immutable{}}}; + } break; + } + types::HeaderError variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); + } + std::expected result5 = std::move(*result5_opt); + auto result6 = std::move(result5); + return result6; +} +std::expected wasi::http0_2_0::types::Fields::Delete(std::string_view name) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Edelete((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + 1)))) { + case 0: { + variant2_opt = types::HeaderError{{types::HeaderError::InvalidSyntax{}}}; + } break; + case 1: { + variant2_opt = types::HeaderError{{types::HeaderError::Forbidden{}}}; + } break; + case 2: { + variant2_opt = types::HeaderError{{types::HeaderError::Immutable{}}}; + } break; + } + types::HeaderError variant2 = std::move(*variant2_opt); + + result3_opt.emplace(std::unexpected{std::move(variant2)}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::http0_2_0::types::Fields::Append(std::string_view name, std::span value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = value; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eappend((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result4_opt.emplace(std::expected()); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + 1)))) { + case 0: { + variant3_opt = types::HeaderError{{types::HeaderError::InvalidSyntax{}}}; + } break; + case 1: { + variant3_opt = types::HeaderError{{types::HeaderError::Forbidden{}}}; + } break; + case 2: { + variant3_opt = types::HeaderError{{types::HeaderError::Immutable{}}}; + } break; + } + types::HeaderError variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); + } + std::expected result4 = std::move(*result4_opt); + auto result5 = std::move(result4); + return result5; +} +wit::vector>> wasi::http0_2_0::types::Fields::Entries() const +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eentries((*this).get_handle(), std::move(ptr0)); + auto _base4 = *((uint8_t**) (ptr0 + 0)); + auto _len4 = *((size_t*) (ptr0 + sizeof(void*))); + auto _result4 = wit::vector>>::allocate(_len4); + for (unsigned i=0; i<_len4; ++i) { + auto _base = _base4 + i * (4*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + + auto _len2 = *((size_t*) (_base + (3*sizeof(void*)))); + auto tuple3 = std::tuple>(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len1), wit::vector((uint8_t*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len2)); + auto _e4 = std::move(tuple3); + _result4.initialize(i, std::move(_e4)); + } + auto result5 = std::move(_result4); + return result5; +} +wasi::http0_2_0::types::Fields wasi::http0_2_0::types::Fields::Clone() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5DfieldsX2Eclone((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::http0_2_0::types::Fields::Fields(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::FutureTrailers::~FutureTrailers() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfuture_trailers(handle); + } +} +wasi::io0_2_0::poll::Pollable wasi::http0_2_0::types::FutureTrailers::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_trailersX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::optional, wasi::http0_2_0::types::ErrorCode>, wit::Void>> wasi::http0_2_0::types::FutureTrailers::Get() const +{ + uint64_t ret_area[((40+4*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_trailersX2Eget((*this).get_handle(), std::move(ptr0)); + std::optional, types::ErrorCode>, wit::Void>> option45; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + std::optional, types::ErrorCode>, wit::Void>> result44_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 8)))==0) { + std::optional, types::ErrorCode>> result43_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 16)))==0) { + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 24)))) { + int32_t l1 = *((int32_t const*)(ptr0 + 28)); + + option2.emplace(wit::ResourceImportBase{l1}); + } + + result43_opt.emplace(std::expected, types::ErrorCode>(std::move(option2))); + } else { + std::optional variant42_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 24)))) { + case 0: { + variant42_opt = types::ErrorCode{{types::ErrorCode::DnsTimeout{}}}; + } break; + case 1: { std::optional option4; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len3 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option4.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len3)); + } + std::optional option5; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + + option5.emplace((uint16_t((int32_t) (*((uint16_t*) (ptr0 + (34+3*sizeof(void*)))))))); + } + + variant42_opt = types::ErrorCode{{types::ErrorCode::DnsError{types::DnsErrorPayload{std::move(option4), std::move(option5), }}}}; + } break; + case 2: { + variant42_opt = types::ErrorCode{{types::ErrorCode::DestinationNotFound{}}}; + } break; + case 3: { + variant42_opt = types::ErrorCode{{types::ErrorCode::DestinationUnavailable{}}}; + } break; + case 4: { + variant42_opt = types::ErrorCode{{types::ErrorCode::DestinationIpProhibited{}}}; + } break; + case 5: { + variant42_opt = types::ErrorCode{{types::ErrorCode::DestinationIpUnroutable{}}}; + } break; + case 6: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionRefused{}}}; + } break; + case 7: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionTerminated{}}}; + } break; + case 8: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionTimeout{}}}; + } break; + case 9: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionReadTimeout{}}}; + } break; + case 10: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionWriteTimeout{}}}; + } break; + case 11: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConnectionLimitReached{}}}; + } break; + case 12: { + variant42_opt = types::ErrorCode{{types::ErrorCode::TlsProtocolError{}}}; + } break; + case 13: { + variant42_opt = types::ErrorCode{{types::ErrorCode::TlsCertificateError{}}}; + } break; + case 14: { std::optional option6; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option6.emplace((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 33)))))); + } + std::optional option8; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+1*sizeof(void*)))))) { + auto _len7 = *((size_t*) (ptr0 + (32+3*sizeof(void*)))); + + + option8.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+2*sizeof(void*))))), _len7)); + } + + variant42_opt = types::ErrorCode{{types::ErrorCode::TlsAlertReceived{types::TlsAlertReceivedPayload{std::move(option6), std::move(option8), }}}}; + } break; + case 15: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestDenied{}}}; + } break; + case 16: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestLengthRequired{}}}; + } break; + case 17: { std::optional option9; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option9.emplace((uint64_t(*((int64_t*) (ptr0 + 40))))); + } + + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestBodySize{std::move(option9)}}}; + } break; + case 18: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestMethodInvalid{}}}; + } break; + case 19: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriInvalid{}}}; + } break; + case 20: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriTooLong{}}}; + } break; + case 21: { std::optional option11; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l10 = *((int32_t const*)(ptr0 + 36)); + + option11.emplace((uint32_t(l10))); + } + + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSectionSize{std::move(option11)}}}; + } break; + case 22: { std::optional option16; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + std::optional option13; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+1*sizeof(void*)))))) { + auto _len12 = *((size_t*) (ptr0 + (32+3*sizeof(void*)))); + + + option13.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+2*sizeof(void*))))), _len12)); + } + std::optional option15; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+4*sizeof(void*)))))) { + int32_t l14 = *((int32_t const*)(ptr0 + (36+4*sizeof(void*)))); + + option15.emplace((uint32_t(l14))); + } + + option16.emplace(types::FieldSizePayload{std::move(option13), std::move(option15), }); + } + + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSize{std::move(option16)}}}; +} break; +case 23: { std::optional option18; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l17 = *((int32_t const*)(ptr0 + 36)); + + option18.emplace((uint32_t(l17))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSectionSize{std::move(option18)}}}; +} break; +case 24: { std::optional option20; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len19 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option20.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len19)); +} +std::optional option22; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l21 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option22.emplace((uint32_t(l21))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSize{types::FieldSizePayload{std::move(option20), std::move(option22), }}}}; +} break; +case 25: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseIncomplete{}}}; +} break; +case 26: { std::optional option24; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l23 = *((int32_t const*)(ptr0 + 36)); + + option24.emplace((uint32_t(l23))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSectionSize{std::move(option24)}}}; +} break; +case 27: { std::optional option26; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len25 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option26.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len25)); +} +std::optional option28; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l27 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option28.emplace((uint32_t(l27))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSize{types::FieldSizePayload{std::move(option26), std::move(option28), }}}}; +} break; +case 28: { std::optional option29; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option29.emplace((uint64_t(*((int64_t*) (ptr0 + 40))))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseBodySize{std::move(option29)}}}; +} break; +case 29: { std::optional option31; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l30 = *((int32_t const*)(ptr0 + 36)); + + option31.emplace((uint32_t(l30))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSectionSize{std::move(option31)}}}; +} break; +case 30: { std::optional option33; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len32 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option33.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len32)); +} +std::optional option35; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l34 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option35.emplace((uint32_t(l34))); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSize{types::FieldSizePayload{std::move(option33), std::move(option35), }}}}; +} break; +case 31: { std::optional option37; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len36 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option37.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len36)); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTransferCoding{std::move(option37)}}}; +} break; +case 32: { std::optional option39; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len38 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option39.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len38)); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseContentCoding{std::move(option39)}}}; +} break; +case 33: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTimeout{}}}; +} break; +case 34: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpUpgradeFailed{}}}; +} break; +case 35: { + variant42_opt = types::ErrorCode{{types::ErrorCode::HttpProtocolError{}}}; +} break; +case 36: { + variant42_opt = types::ErrorCode{{types::ErrorCode::LoopDetected{}}}; +} break; +case 37: { + variant42_opt = types::ErrorCode{{types::ErrorCode::ConfigurationError{}}}; +} break; +case 38: { std::optional option41; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len40 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option41.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len40)); +} + +variant42_opt = types::ErrorCode{{types::ErrorCode::InternalError{std::move(option41)}}}; +} break; +} +types::ErrorCode variant42 = std::move(*variant42_opt); + +result43_opt.emplace(std::unexpected{std::move(variant42)}); +} +std::expected, types::ErrorCode> result43 = std::move(*result43_opt); + +result44_opt.emplace(std::expected, types::ErrorCode>, wit::Void>(std::move(result43))); +} else { + +result44_opt.emplace(std::unexpected{wit::Void{}}); +} +std::expected, types::ErrorCode>, wit::Void> result44 = std::move(*result44_opt); + +option45.emplace(std::move(result44)); +} +auto result46 = std::move(option45); +return result46; +} +wasi::http0_2_0::types::FutureTrailers::FutureTrailers(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::IncomingBody::~IncomingBody() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_body(handle); + } +} +std::expected wasi::http0_2_0::types::IncomingBody::Stream() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_bodyX2Estream((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::http0_2_0::types::FutureTrailers wasi::http0_2_0::types::IncomingBody::Finish(types::IncomingBody&& this_) +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Dincoming_bodyX2Efinish(this_.into_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::http0_2_0::types::IncomingBody::IncomingBody(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::IncomingRequest::~IncomingRequest() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_request(handle); + } +} +wasi::http0_2_0::types::Method wasi::http0_2_0::types::IncomingRequest::Method() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Emethod((*this).get_handle(), std::move(ptr0)); + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + case 0: { + variant2_opt = types::Method{{types::Method::Get{}}}; + } break; + case 1: { + variant2_opt = types::Method{{types::Method::Head{}}}; + } break; + case 2: { + variant2_opt = types::Method{{types::Method::Post{}}}; + } break; + case 3: { + variant2_opt = types::Method{{types::Method::Put{}}}; + } break; + case 4: { + variant2_opt = types::Method{{types::Method::Delete{}}}; + } break; + case 5: { + variant2_opt = types::Method{{types::Method::Connect{}}}; + } break; + case 6: { + variant2_opt = types::Method{{types::Method::Options{}}}; + } break; + case 7: { + variant2_opt = types::Method{{types::Method::Trace{}}}; + } break; + case 8: { + variant2_opt = types::Method{{types::Method::Patch{}}}; + } break; + case 9: { auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + variant2_opt = types::Method{{types::Method::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)}}}; + } break; +} +types::Method variant2 = std::move(*variant2_opt); +auto result3 = std::move(variant2); +return result3; +} +std::optional wasi::http0_2_0::types::IncomingRequest::PathWithQuery() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Epath_with_query((*this).get_handle(), std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)); + } + auto result3 = std::move(option2); + return result3; +} +std::optional wasi::http0_2_0::types::IncomingRequest::Scheme() const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Escheme((*this).get_handle(), std::move(ptr0)); + std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { + variant2_opt = types::Scheme{{types::Scheme::Http{}}}; + } break; + case 1: { + variant2_opt = types::Scheme{{types::Scheme::Https{}}}; + } break; + case 2: { auto _len1 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant2_opt = types::Scheme{{types::Scheme::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len1)}}}; + } break; + } + types::Scheme variant2 = std::move(*variant2_opt); + + option3.emplace(std::move(variant2)); +} +auto result4 = std::move(option3); +return result4; +} +std::optional wasi::http0_2_0::types::IncomingRequest::Authority() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Eauthority((*this).get_handle(), std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)); + } + auto result3 = std::move(option2); + return result3; +} +wasi::http0_2_0::types::Fields wasi::http0_2_0::types::IncomingRequest::Headers() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Eheaders((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::expected wasi::http0_2_0::types::IncomingRequest::Consume() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_requestX2Econsume((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::http0_2_0::types::IncomingRequest::IncomingRequest(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::OutgoingBody::~OutgoingBody() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_body(handle); + } +} +std::expected wasi::http0_2_0::types::OutgoingBody::Write() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_bodyX2Ewrite((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::http0_2_0::types::OutgoingBody::Finish(types::OutgoingBody&& this_, std::optional trailers) +{ + uint64_t ret_area[((24+4*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + int32_t option2; + int32_t option3; + if ((trailers).has_value()) { + types::Fields payload1 = (std::move(trailers)).value(); + option2 = (int32_t(1)); + option3 = payload1.into_handle(); + } else { + option2 = (int32_t(0)); + option3 = int32_t(0); + } + uint8_t* ptr4 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Doutgoing_bodyX2Efinish(this_.into_handle(), std::move(option2), std::move(option3), std::move(ptr4)); + std::optional> result45_opt; + if ((int32_t) (*((uint8_t*) (ptr4 + 0)))==0) { + + result45_opt.emplace(std::expected()); + } else { + std::optional variant44_opt; + switch ((int32_t) (*((uint8_t*) (ptr4 + 8)))) { + case 0: { + variant44_opt = types::ErrorCode{{types::ErrorCode::DnsTimeout{}}}; + } break; + case 1: { std::optional option6; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len5 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option6.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len5)); + } + std::optional option7; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + + option7.emplace((uint16_t((int32_t) (*((uint16_t*) (ptr4 + (18+3*sizeof(void*)))))))); + } + + variant44_opt = types::ErrorCode{{types::ErrorCode::DnsError{types::DnsErrorPayload{std::move(option6), std::move(option7), }}}}; + } break; + case 2: { + variant44_opt = types::ErrorCode{{types::ErrorCode::DestinationNotFound{}}}; + } break; + case 3: { + variant44_opt = types::ErrorCode{{types::ErrorCode::DestinationUnavailable{}}}; + } break; + case 4: { + variant44_opt = types::ErrorCode{{types::ErrorCode::DestinationIpProhibited{}}}; + } break; + case 5: { + variant44_opt = types::ErrorCode{{types::ErrorCode::DestinationIpUnroutable{}}}; + } break; + case 6: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionRefused{}}}; + } break; + case 7: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionTerminated{}}}; + } break; + case 8: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionTimeout{}}}; + } break; + case 9: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionReadTimeout{}}}; + } break; + case 10: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionWriteTimeout{}}}; + } break; + case 11: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConnectionLimitReached{}}}; + } break; + case 12: { + variant44_opt = types::ErrorCode{{types::ErrorCode::TlsProtocolError{}}}; + } break; + case 13: { + variant44_opt = types::ErrorCode{{types::ErrorCode::TlsCertificateError{}}}; + } break; + case 14: { std::optional option8; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option8.emplace((uint8_t((int32_t) (*((uint8_t*) (ptr4 + 17)))))); + } + std::optional option10; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+1*sizeof(void*)))))) { + auto _len9 = *((size_t*) (ptr4 + (16+3*sizeof(void*)))); + + + option10.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+2*sizeof(void*))))), _len9)); + } + + variant44_opt = types::ErrorCode{{types::ErrorCode::TlsAlertReceived{types::TlsAlertReceivedPayload{std::move(option8), std::move(option10), }}}}; + } break; + case 15: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestDenied{}}}; + } break; + case 16: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestLengthRequired{}}}; + } break; + case 17: { std::optional option11; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option11.emplace((uint64_t(*((int64_t*) (ptr4 + 24))))); + } + + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestBodySize{std::move(option11)}}}; +} break; +case 18: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestMethodInvalid{}}}; +} break; +case 19: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriInvalid{}}}; +} break; +case 20: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriTooLong{}}}; +} break; +case 21: { std::optional option13; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l12 = *((int32_t const*)(ptr4 + 20)); + + option13.emplace((uint32_t(l12))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSectionSize{std::move(option13)}}}; +} break; +case 22: { std::optional option18; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + std::optional option15; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+1*sizeof(void*)))))) { + auto _len14 = *((size_t*) (ptr4 + (16+3*sizeof(void*)))); + + + option15.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+2*sizeof(void*))))), _len14)); + } + std::optional option17; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+4*sizeof(void*)))))) { + int32_t l16 = *((int32_t const*)(ptr4 + (20+4*sizeof(void*)))); + + option17.emplace((uint32_t(l16))); + } + + option18.emplace(types::FieldSizePayload{std::move(option15), std::move(option17), }); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSize{std::move(option18)}}}; +} break; +case 23: { std::optional option20; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l19 = *((int32_t const*)(ptr4 + 20)); + + option20.emplace((uint32_t(l19))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSectionSize{std::move(option20)}}}; +} break; +case 24: { std::optional option22; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len21 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option22.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len21)); +} +std::optional option24; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l23 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option24.emplace((uint32_t(l23))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSize{types::FieldSizePayload{std::move(option22), std::move(option24), }}}}; +} break; +case 25: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseIncomplete{}}}; +} break; +case 26: { std::optional option26; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l25 = *((int32_t const*)(ptr4 + 20)); + + option26.emplace((uint32_t(l25))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSectionSize{std::move(option26)}}}; +} break; +case 27: { std::optional option28; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len27 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option28.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len27)); +} +std::optional option30; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l29 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option30.emplace((uint32_t(l29))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSize{types::FieldSizePayload{std::move(option28), std::move(option30), }}}}; +} break; +case 28: { std::optional option31; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option31.emplace((uint64_t(*((int64_t*) (ptr4 + 24))))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseBodySize{std::move(option31)}}}; +} break; +case 29: { std::optional option33; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l32 = *((int32_t const*)(ptr4 + 20)); + + option33.emplace((uint32_t(l32))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSectionSize{std::move(option33)}}}; +} break; +case 30: { std::optional option35; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len34 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option35.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len34)); +} +std::optional option37; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l36 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option37.emplace((uint32_t(l36))); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSize{types::FieldSizePayload{std::move(option35), std::move(option37), }}}}; +} break; +case 31: { std::optional option39; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len38 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option39.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len38)); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTransferCoding{std::move(option39)}}}; +} break; +case 32: { std::optional option41; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len40 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option41.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len40)); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseContentCoding{std::move(option41)}}}; +} break; +case 33: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTimeout{}}}; +} break; +case 34: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpUpgradeFailed{}}}; +} break; +case 35: { + variant44_opt = types::ErrorCode{{types::ErrorCode::HttpProtocolError{}}}; +} break; +case 36: { + variant44_opt = types::ErrorCode{{types::ErrorCode::LoopDetected{}}}; +} break; +case 37: { + variant44_opt = types::ErrorCode{{types::ErrorCode::ConfigurationError{}}}; +} break; +case 38: { std::optional option43; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len42 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option43.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len42)); +} + +variant44_opt = types::ErrorCode{{types::ErrorCode::InternalError{std::move(option43)}}}; +} break; +} +types::ErrorCode variant44 = std::move(*variant44_opt); + +result45_opt.emplace(std::unexpected{std::move(variant44)}); +} +std::expected result45 = std::move(*result45_opt); +auto result46 = std::move(result45); +return result46; +} +wasi::http0_2_0::types::OutgoingBody::OutgoingBody(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::OutgoingRequest::~OutgoingRequest() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_request(handle); + } +} +wasi::http0_2_0::types::OutgoingRequest::OutgoingRequest(types::Fields&& headers) +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Doutgoing_request(headers.into_handle()); + this->handle = wit::ResourceImportBase{ret}.into_handle(); +} +std::expected wasi::http0_2_0::types::OutgoingRequest::Body() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Ebody((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::http0_2_0::types::Method wasi::http0_2_0::types::OutgoingRequest::Method() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Emethod((*this).get_handle(), std::move(ptr0)); + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + case 0: { + variant2_opt = types::Method{{types::Method::Get{}}}; + } break; + case 1: { + variant2_opt = types::Method{{types::Method::Head{}}}; + } break; + case 2: { + variant2_opt = types::Method{{types::Method::Post{}}}; + } break; + case 3: { + variant2_opt = types::Method{{types::Method::Put{}}}; + } break; + case 4: { + variant2_opt = types::Method{{types::Method::Delete{}}}; + } break; + case 5: { + variant2_opt = types::Method{{types::Method::Connect{}}}; + } break; + case 6: { + variant2_opt = types::Method{{types::Method::Options{}}}; + } break; + case 7: { + variant2_opt = types::Method{{types::Method::Trace{}}}; + } break; + case 8: { + variant2_opt = types::Method{{types::Method::Patch{}}}; + } break; + case 9: { auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + variant2_opt = types::Method{{types::Method::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)}}}; + } break; +} +types::Method variant2 = std::move(*variant2_opt); +auto result3 = std::move(variant2); +return result3; +} +std::expected wasi::http0_2_0::types::OutgoingRequest::SetMethod(types::Method method) const +{ + int32_t variant11; + uint8_t * variant12; + size_t variant13; + switch ((int32_t) (method).variants.index()) { + case 0: { + variant11 = (int32_t(0)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 1: { + variant11 = (int32_t(1)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 2: { + variant11 = (int32_t(2)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 3: { + variant11 = (int32_t(3)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 4: { + variant11 = (int32_t(4)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 5: { + variant11 = (int32_t(5)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 6: { + variant11 = (int32_t(6)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 7: { + variant11 = (int32_t(7)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 8: { + variant11 = (int32_t(8)); + variant12 = nullptr; + variant13 = size_t(0); + break; + } + case 9: { + auto& payload9 = std::get(method.variants).value; + auto&& _vec10 = payload9; + auto _ptr10 = (uint8_t*)(_vec10.data()); + auto _len10 = (size_t)(_vec10.size()); + variant11 = (int32_t(9)); + variant12 = _ptr10; + variant13 = _len10; + break; + } + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_method((*this).get_handle(), std::move(variant11), std::move(variant12), std::move(variant13)); + std::optional> result14_opt; + if (ret==0) { + + result14_opt.emplace(std::expected()); + } else { + + result14_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result14 = std::move(*result14_opt); + return result14; +} +std::optional wasi::http0_2_0::types::OutgoingRequest::PathWithQuery() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Epath_with_query((*this).get_handle(), std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)); + } + auto result3 = std::move(option2); + return result3; +} +std::expected wasi::http0_2_0::types::OutgoingRequest::SetPathWithQuery(std::optional path_with_query) const +{ + int32_t option3; + uint8_t * option4; + size_t option5; + if ((path_with_query).has_value()) { + std::string_view payload1 = (std::move(path_with_query)).value(); + auto&& _vec2 = payload1; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + option3 = (int32_t(1)); + option4 = _ptr2; + option5 = _len2; + } else { + option3 = (int32_t(0)); + option4 = nullptr; + option5 = size_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_path_with_query((*this).get_handle(), std::move(option3), std::move(option4), std::move(option5)); + std::optional> result6_opt; + if (ret==0) { + + result6_opt.emplace(std::expected()); + } else { + + result6_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result6 = std::move(*result6_opt); + return result6; +} +std::optional wasi::http0_2_0::types::OutgoingRequest::Scheme() const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Escheme((*this).get_handle(), std::move(ptr0)); + std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + std::optional variant2_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { + variant2_opt = types::Scheme{{types::Scheme::Http{}}}; + } break; + case 1: { + variant2_opt = types::Scheme{{types::Scheme::Https{}}}; + } break; + case 2: { auto _len1 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant2_opt = types::Scheme{{types::Scheme::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len1)}}}; + } break; + } + types::Scheme variant2 = std::move(*variant2_opt); + + option3.emplace(std::move(variant2)); +} +auto result4 = std::move(option3); +return result4; +} +std::expected wasi::http0_2_0::types::OutgoingRequest::SetScheme(std::optional scheme) const +{ + int32_t option9; + int32_t option10; + uint8_t * option11; + size_t option12; + if ((scheme).has_value()) { + types::Scheme payload1 = (std::move(scheme)).value(); + int32_t variant6; + uint8_t * variant7; + size_t variant8; + switch ((int32_t) (payload1).variants.index()) { + case 0: { + variant6 = (int32_t(0)); + variant7 = nullptr; + variant8 = size_t(0); + break; + } + case 1: { + variant6 = (int32_t(1)); + variant7 = nullptr; + variant8 = size_t(0); + break; + } + case 2: { + auto& payload4 = std::get(payload1.variants).value; + auto&& _vec5 = payload4; + auto _ptr5 = (uint8_t*)(_vec5.data()); + auto _len5 = (size_t)(_vec5.size()); + variant6 = (int32_t(2)); + variant7 = _ptr5; + variant8 = _len5; + break; + } + } + option9 = (int32_t(1)); + option10 = variant6; + option11 = variant7; + option12 = variant8; + } else { + option9 = (int32_t(0)); + option10 = int32_t(0); + option11 = nullptr; + option12 = size_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_scheme((*this).get_handle(), std::move(option9), std::move(option10), std::move(option11), std::move(option12)); + std::optional> result13_opt; + if (ret==0) { + + result13_opt.emplace(std::expected()); + } else { + + result13_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result13 = std::move(*result13_opt); + return result13; +} +std::optional wasi::http0_2_0::types::OutgoingRequest::Authority() const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eauthority((*this).get_handle(), std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)); + } + auto result3 = std::move(option2); + return result3; +} +std::expected wasi::http0_2_0::types::OutgoingRequest::SetAuthority(std::optional authority) const +{ + int32_t option3; + uint8_t * option4; + size_t option5; + if ((authority).has_value()) { + std::string_view payload1 = (std::move(authority)).value(); + auto&& _vec2 = payload1; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + option3 = (int32_t(1)); + option4 = _ptr2; + option5 = _len2; + } else { + option3 = (int32_t(0)); + option4 = nullptr; + option5 = size_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eset_authority((*this).get_handle(), std::move(option3), std::move(option4), std::move(option5)); + std::optional> result6_opt; + if (ret==0) { + + result6_opt.emplace(std::expected()); + } else { + + result6_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result6 = std::move(*result6_opt); + return result6; +} +wasi::http0_2_0::types::Fields wasi::http0_2_0::types::OutgoingRequest::Headers() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_requestX2Eheaders((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::http0_2_0::types::OutgoingRequest::OutgoingRequest(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::RequestOptions::~RequestOptions() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Drequest_options(handle); + } +} +wasi::http0_2_0::types::RequestOptions::RequestOptions() +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Drequest_options(); + this->handle = wit::ResourceImportBase{ret}.into_handle(); +} +std::optional wasi::http0_2_0::types::RequestOptions::ConnectTimeout() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Econnect_timeout((*this).get_handle(), std::move(ptr0)); + std::optional option1; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + + option1.emplace((uint64_t(*((int64_t*) (ptr0 + 8))))); + } + auto result2 = std::move(option1); + return result2; +} +std::expected wasi::http0_2_0::types::RequestOptions::SetConnectTimeout(std::optional duration) const +{ + int32_t option2; + int64_t option3; + if ((duration).has_value()) { + uint64_t payload1 = (std::move(duration)).value(); + option2 = (int32_t(1)); + option3 = (int64_t(payload1)); + } else { + option2 = (int32_t(0)); + option3 = int64_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_connect_timeout((*this).get_handle(), std::move(option2), std::move(option3)); + std::optional> result4_opt; + if (ret==0) { + + result4_opt.emplace(std::expected()); + } else { + + result4_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result4 = std::move(*result4_opt); + return result4; +} +std::optional wasi::http0_2_0::types::RequestOptions::FirstByteTimeout() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Efirst_byte_timeout((*this).get_handle(), std::move(ptr0)); + std::optional option1; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + + option1.emplace((uint64_t(*((int64_t*) (ptr0 + 8))))); + } + auto result2 = std::move(option1); + return result2; +} +std::expected wasi::http0_2_0::types::RequestOptions::SetFirstByteTimeout(std::optional duration) const +{ + int32_t option2; + int64_t option3; + if ((duration).has_value()) { + uint64_t payload1 = (std::move(duration)).value(); + option2 = (int32_t(1)); + option3 = (int64_t(payload1)); + } else { + option2 = (int32_t(0)); + option3 = int64_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_first_byte_timeout((*this).get_handle(), std::move(option2), std::move(option3)); + std::optional> result4_opt; + if (ret==0) { + + result4_opt.emplace(std::expected()); + } else { + + result4_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result4 = std::move(*result4_opt); + return result4; +} +std::optional wasi::http0_2_0::types::RequestOptions::BetweenBytesTimeout() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Ebetween_bytes_timeout((*this).get_handle(), std::move(ptr0)); + std::optional option1; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + + option1.emplace((uint64_t(*((int64_t*) (ptr0 + 8))))); + } + auto result2 = std::move(option1); + return result2; +} +std::expected wasi::http0_2_0::types::RequestOptions::SetBetweenBytesTimeout(std::optional duration) const +{ + int32_t option2; + int64_t option3; + if ((duration).has_value()) { + uint64_t payload1 = (std::move(duration)).value(); + option2 = (int32_t(1)); + option3 = (int64_t(payload1)); + } else { + option2 = (int32_t(0)); + option3 = int64_t(0); + } + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Drequest_optionsX2Eset_between_bytes_timeout((*this).get_handle(), std::move(option2), std::move(option3)); + std::optional> result4_opt; + if (ret==0) { + + result4_opt.emplace(std::expected()); + } else { + + result4_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result4 = std::move(*result4_opt); + return result4; +} +wasi::http0_2_0::types::RequestOptions::RequestOptions(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::OutgoingResponse::~OutgoingResponse() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_response(handle); + } +} +wasi::http0_2_0::types::OutgoingResponse::OutgoingResponse(types::Fields&& headers) +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BconstructorX5Doutgoing_response(headers.into_handle()); + this->handle = wit::ResourceImportBase{ret}.into_handle(); +} +uint16_t wasi::http0_2_0::types::OutgoingResponse::StatusCode() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Estatus_code((*this).get_handle()); + return (uint16_t(ret)); +} +std::expected wasi::http0_2_0::types::OutgoingResponse::SetStatusCode(uint16_t status_code) const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Eset_status_code((*this).get_handle(), (int32_t(status_code))); + std::optional> result0_opt; + if (ret==0) { + + result0_opt.emplace(std::expected()); + } else { + + result0_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result0 = std::move(*result0_opt); + return result0; +} +wasi::http0_2_0::types::Fields wasi::http0_2_0::types::OutgoingResponse::Headers() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Eheaders((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::expected wasi::http0_2_0::types::OutgoingResponse::Body() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Doutgoing_responseX2Ebody((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::http0_2_0::types::OutgoingResponse::OutgoingResponse(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::ResponseOutparam::~ResponseOutparam() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dresponse_outparam(handle); + } +} +void wasi::http0_2_0::types::ResponseOutparam::Set(types::ResponseOutparam&& param, std::expected response) +{ + int32_t result158; + int32_t result159; + int32_t result160; + int64_t result161; + uint8_t * result162; + uint8_t * result163; + size_t result164; + int32_t result165; + if ((response).has_value()) { + types::OutgoingResponse payload0 = std::move(response).value(); + result158 = (int32_t(0)); + result159 = payload0.into_handle(); + result160 = int32_t(0); + result161 = int64_t(0); + result162 = nullptr; + result163 = nullptr; + result164 = size_t(0); + result165 = int32_t(0); + } else { + types::ErrorCode payload1 = std::move(response).error(); + int32_t variant151; + int32_t variant152; + int64_t variant153; + uint8_t * variant154; + uint8_t * variant155; + size_t variant156; + int32_t variant157; + switch ((int32_t) (payload1).variants.index()) { + case 0: { + variant151 = (int32_t(0)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 1: { + auto& payload3 = std::get(payload1.variants).value; + int32_t option7; + uint8_t * option8; + size_t option9; + if (((payload3).rcode).has_value()) { + std::string_view payload5 = (std::move((payload3).rcode)).value().get_view(); + auto&& _vec6 = payload5; + auto _ptr6 = (uint8_t*)(_vec6.data()); + auto _len6 = (size_t)(_vec6.size()); + option7 = (int32_t(1)); + option8 = _ptr6; + option9 = _len6; + } else { + option7 = (int32_t(0)); + option8 = nullptr; + option9 = size_t(0); + } + int32_t option12; + int32_t option13; + if (((payload3).info_code).has_value()) { + uint16_t payload11 = (std::move((payload3).info_code)).value(); + option12 = (int32_t(1)); + option13 = (int32_t(payload11)); + } else { + option12 = (int32_t(0)); + option13 = int32_t(0); + } + variant151 = (int32_t(1)); + variant152 = option7; + variant153 = (int64_t) option8; + variant154 = (uint8_t*) option9; + variant155 = (uint8_t*) option12; + variant156 = (size_t) option13; + variant157 = int32_t(0); + break; + } + case 2: { + variant151 = (int32_t(2)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 3: { + variant151 = (int32_t(3)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 4: { + variant151 = (int32_t(4)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 5: { + variant151 = (int32_t(5)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 6: { + variant151 = (int32_t(6)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 7: { + variant151 = (int32_t(7)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 8: { + variant151 = (int32_t(8)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 9: { + variant151 = (int32_t(9)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 10: { + variant151 = (int32_t(10)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 11: { + variant151 = (int32_t(11)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 12: { + variant151 = (int32_t(12)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 13: { + variant151 = (int32_t(13)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 14: { + auto& payload26 = std::get(payload1.variants).value; + int32_t option29; + int32_t option30; + if (((payload26).alert_id).has_value()) { + uint8_t payload28 = (std::move((payload26).alert_id)).value(); + option29 = (int32_t(1)); + option30 = (int32_t(payload28)); + } else { + option29 = (int32_t(0)); + option30 = int32_t(0); + } + int32_t option34; + uint8_t * option35; + size_t option36; + if (((payload26).alert_message).has_value()) { + std::string_view payload32 = (std::move((payload26).alert_message)).value().get_view(); + auto&& _vec33 = payload32; + auto _ptr33 = (uint8_t*)(_vec33.data()); + auto _len33 = (size_t)(_vec33.size()); + option34 = (int32_t(1)); + option35 = _ptr33; + option36 = _len33; + } else { + option34 = (int32_t(0)); + option35 = nullptr; + option36 = size_t(0); + } + variant151 = (int32_t(14)); + variant152 = option29; + variant153 = (int64_t) option30; + variant154 = (uint8_t*) option34; + variant155 = option35; + variant156 = option36; + variant157 = int32_t(0); + break; + } + case 15: { + variant151 = (int32_t(15)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 16: { + variant151 = (int32_t(16)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 17: { + auto& payload39 = std::get(payload1.variants).value; + int32_t option42; + int64_t option43; + if ((payload39).has_value()) { + uint64_t payload41 = (std::move(payload39)).value(); + option42 = (int32_t(1)); + option43 = (int64_t(payload41)); + } else { + option42 = (int32_t(0)); + option43 = int64_t(0); + } + variant151 = (int32_t(17)); + variant152 = option42; + variant153 = option43; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 18: { + variant151 = (int32_t(18)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 19: { + variant151 = (int32_t(19)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 20: { + variant151 = (int32_t(20)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 21: { + auto& payload47 = std::get(payload1.variants).value; + int32_t option50; + int32_t option51; + if ((payload47).has_value()) { + uint32_t payload49 = (std::move(payload47)).value(); + option50 = (int32_t(1)); + option51 = (int32_t(payload49)); + } else { + option50 = (int32_t(0)); + option51 = int32_t(0); + } + variant151 = (int32_t(21)); + variant152 = option50; + variant153 = (int64_t) option51; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 22: { + auto& payload52 = std::get(payload1.variants).value; + int32_t option65; + int32_t option66; + uint8_t * option67; + size_t option68; + int32_t option69; + int32_t option70; + if ((payload52).has_value()) { + types::FieldSizePayload payload54 = (std::move(payload52)).value(); + int32_t option58; + uint8_t * option59; + size_t option60; + if (((payload54).field_name).has_value()) { + std::string_view payload56 = (std::move((payload54).field_name)).value().get_view(); + auto&& _vec57 = payload56; + auto _ptr57 = (uint8_t*)(_vec57.data()); + auto _len57 = (size_t)(_vec57.size()); + option58 = (int32_t(1)); + option59 = _ptr57; + option60 = _len57; + } else { + option58 = (int32_t(0)); + option59 = nullptr; + option60 = size_t(0); + } + int32_t option63; + int32_t option64; + if (((payload54).field_size).has_value()) { + uint32_t payload62 = (std::move((payload54).field_size)).value(); + option63 = (int32_t(1)); + option64 = (int32_t(payload62)); + } else { + option63 = (int32_t(0)); + option64 = int32_t(0); + } + option65 = (int32_t(1)); + option66 = option58; + option67 = option59; + option68 = option60; + option69 = option63; + option70 = option64; + } else { + option65 = (int32_t(0)); + option66 = int32_t(0); + option67 = nullptr; + option68 = size_t(0); + option69 = int32_t(0); + option70 = int32_t(0); + } + variant151 = (int32_t(22)); + variant152 = option65; + variant153 = (int64_t) option66; + variant154 = option67; + variant155 = (uint8_t*) option68; + variant156 = (size_t) option69; + variant157 = option70; + break; + } + case 23: { + auto& payload71 = std::get(payload1.variants).value; + int32_t option74; + int32_t option75; + if ((payload71).has_value()) { + uint32_t payload73 = (std::move(payload71)).value(); + option74 = (int32_t(1)); + option75 = (int32_t(payload73)); + } else { + option74 = (int32_t(0)); + option75 = int32_t(0); + } + variant151 = (int32_t(23)); + variant152 = option74; + variant153 = (int64_t) option75; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 24: { + auto& payload76 = std::get(payload1.variants).value; + int32_t option80; + uint8_t * option81; + size_t option82; + if (((payload76).field_name).has_value()) { + std::string_view payload78 = (std::move((payload76).field_name)).value().get_view(); + auto&& _vec79 = payload78; + auto _ptr79 = (uint8_t*)(_vec79.data()); + auto _len79 = (size_t)(_vec79.size()); + option80 = (int32_t(1)); + option81 = _ptr79; + option82 = _len79; + } else { + option80 = (int32_t(0)); + option81 = nullptr; + option82 = size_t(0); + } + int32_t option85; + int32_t option86; + if (((payload76).field_size).has_value()) { + uint32_t payload84 = (std::move((payload76).field_size)).value(); + option85 = (int32_t(1)); + option86 = (int32_t(payload84)); + } else { + option85 = (int32_t(0)); + option86 = int32_t(0); + } + variant151 = (int32_t(24)); + variant152 = option80; + variant153 = (int64_t) option81; + variant154 = (uint8_t*) option82; + variant155 = (uint8_t*) option85; + variant156 = (size_t) option86; + variant157 = int32_t(0); + break; + } + case 25: { + variant151 = (int32_t(25)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 26: { + auto& payload88 = std::get(payload1.variants).value; + int32_t option91; + int32_t option92; + if ((payload88).has_value()) { + uint32_t payload90 = (std::move(payload88)).value(); + option91 = (int32_t(1)); + option92 = (int32_t(payload90)); + } else { + option91 = (int32_t(0)); + option92 = int32_t(0); + } + variant151 = (int32_t(26)); + variant152 = option91; + variant153 = (int64_t) option92; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 27: { + auto& payload93 = std::get(payload1.variants).value; + int32_t option97; + uint8_t * option98; + size_t option99; + if (((payload93).field_name).has_value()) { + std::string_view payload95 = (std::move((payload93).field_name)).value().get_view(); + auto&& _vec96 = payload95; + auto _ptr96 = (uint8_t*)(_vec96.data()); + auto _len96 = (size_t)(_vec96.size()); + option97 = (int32_t(1)); + option98 = _ptr96; + option99 = _len96; + } else { + option97 = (int32_t(0)); + option98 = nullptr; + option99 = size_t(0); + } + int32_t option102; + int32_t option103; + if (((payload93).field_size).has_value()) { + uint32_t payload101 = (std::move((payload93).field_size)).value(); + option102 = (int32_t(1)); + option103 = (int32_t(payload101)); + } else { + option102 = (int32_t(0)); + option103 = int32_t(0); + } + variant151 = (int32_t(27)); + variant152 = option97; + variant153 = (int64_t) option98; + variant154 = (uint8_t*) option99; + variant155 = (uint8_t*) option102; + variant156 = (size_t) option103; + variant157 = int32_t(0); + break; + } + case 28: { + auto& payload104 = std::get(payload1.variants).value; + int32_t option107; + int64_t option108; + if ((payload104).has_value()) { + uint64_t payload106 = (std::move(payload104)).value(); + option107 = (int32_t(1)); + option108 = (int64_t(payload106)); + } else { + option107 = (int32_t(0)); + option108 = int64_t(0); + } + variant151 = (int32_t(28)); + variant152 = option107; + variant153 = option108; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 29: { + auto& payload109 = std::get(payload1.variants).value; + int32_t option112; + int32_t option113; + if ((payload109).has_value()) { + uint32_t payload111 = (std::move(payload109)).value(); + option112 = (int32_t(1)); + option113 = (int32_t(payload111)); + } else { + option112 = (int32_t(0)); + option113 = int32_t(0); + } + variant151 = (int32_t(29)); + variant152 = option112; + variant153 = (int64_t) option113; + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 30: { + auto& payload114 = std::get(payload1.variants).value; + int32_t option118; + uint8_t * option119; + size_t option120; + if (((payload114).field_name).has_value()) { + std::string_view payload116 = (std::move((payload114).field_name)).value().get_view(); + auto&& _vec117 = payload116; + auto _ptr117 = (uint8_t*)(_vec117.data()); + auto _len117 = (size_t)(_vec117.size()); + option118 = (int32_t(1)); + option119 = _ptr117; + option120 = _len117; + } else { + option118 = (int32_t(0)); + option119 = nullptr; + option120 = size_t(0); + } + int32_t option123; + int32_t option124; + if (((payload114).field_size).has_value()) { + uint32_t payload122 = (std::move((payload114).field_size)).value(); + option123 = (int32_t(1)); + option124 = (int32_t(payload122)); + } else { + option123 = (int32_t(0)); + option124 = int32_t(0); + } + variant151 = (int32_t(30)); + variant152 = option118; + variant153 = (int64_t) option119; + variant154 = (uint8_t*) option120; + variant155 = (uint8_t*) option123; + variant156 = (size_t) option124; + variant157 = int32_t(0); + break; + } + case 31: { + auto& payload125 = std::get(payload1.variants).value; + int32_t option129; + uint8_t * option130; + size_t option131; + if ((payload125).has_value()) { + std::string_view payload127 = (std::move(payload125)).value().get_view(); + auto&& _vec128 = payload127; + auto _ptr128 = (uint8_t*)(_vec128.data()); + auto _len128 = (size_t)(_vec128.size()); + option129 = (int32_t(1)); + option130 = _ptr128; + option131 = _len128; + } else { + option129 = (int32_t(0)); + option130 = nullptr; + option131 = size_t(0); + } + variant151 = (int32_t(31)); + variant152 = option129; + variant153 = (int64_t) option130; + variant154 = (uint8_t*) option131; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 32: { + auto& payload132 = std::get(payload1.variants).value; + int32_t option136; + uint8_t * option137; + size_t option138; + if ((payload132).has_value()) { + std::string_view payload134 = (std::move(payload132)).value().get_view(); + auto&& _vec135 = payload134; + auto _ptr135 = (uint8_t*)(_vec135.data()); + auto _len135 = (size_t)(_vec135.size()); + option136 = (int32_t(1)); + option137 = _ptr135; + option138 = _len135; + } else { + option136 = (int32_t(0)); + option137 = nullptr; + option138 = size_t(0); + } + variant151 = (int32_t(32)); + variant152 = option136; + variant153 = (int64_t) option137; + variant154 = (uint8_t*) option138; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 33: { + variant151 = (int32_t(33)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 34: { + variant151 = (int32_t(34)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 35: { + variant151 = (int32_t(35)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 36: { + variant151 = (int32_t(36)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 37: { + variant151 = (int32_t(37)); + variant152 = int32_t(0); + variant153 = int64_t(0); + variant154 = nullptr; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + case 38: { + auto& payload144 = std::get(payload1.variants).value; + int32_t option148; + uint8_t * option149; + size_t option150; + if ((payload144).has_value()) { + std::string_view payload146 = (std::move(payload144)).value().get_view(); + auto&& _vec147 = payload146; + auto _ptr147 = (uint8_t*)(_vec147.data()); + auto _len147 = (size_t)(_vec147.size()); + option148 = (int32_t(1)); + option149 = _ptr147; + option150 = _len147; + } else { + option148 = (int32_t(0)); + option149 = nullptr; + option150 = size_t(0); + } + variant151 = (int32_t(38)); + variant152 = option148; + variant153 = (int64_t) option149; + variant154 = (uint8_t*) option150; + variant155 = nullptr; + variant156 = size_t(0); + variant157 = int32_t(0); + break; + } + } + result158 = (int32_t(1)); + result159 = variant151; + result160 = variant152; + result161 = variant153; + result162 = variant154; + result163 = variant155; + result164 = variant156; + result165 = variant157; + } + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BstaticX5Dresponse_outparamX2Eset(param.into_handle(), std::move(result158), std::move(result159), std::move(result160), std::move(result161), std::move(result162), std::move(result163), std::move(result164), std::move(result165)); +} +wasi::http0_2_0::types::ResponseOutparam::ResponseOutparam(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::IncomingResponse::~IncomingResponse() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dincoming_response(handle); + } +} +uint16_t wasi::http0_2_0::types::IncomingResponse::Status() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Estatus((*this).get_handle()); + return (uint16_t(ret)); +} +wasi::http0_2_0::types::Fields wasi::http0_2_0::types::IncomingResponse::Headers() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Eheaders((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::expected wasi::http0_2_0::types::IncomingResponse::Consume() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dincoming_responseX2Econsume((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{wit::Void{}}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::http0_2_0::types::IncomingResponse::IncomingResponse(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::http0_2_0::types::FutureIncomingResponse::~FutureIncomingResponse() +{ + if (handle>=0) { + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Dfuture_incoming_response(handle); + } +} +wasi::io0_2_0::poll::Pollable wasi::http0_2_0::types::FutureIncomingResponse::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_incoming_responseX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::optional, wit::Void>> wasi::http0_2_0::types::FutureIncomingResponse::Get() const +{ + uint64_t ret_area[((40+4*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00X5BmethodX5Dfuture_incoming_responseX2Eget((*this).get_handle(), std::move(ptr0)); + std::optional, wit::Void>> option44; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + std::optional, wit::Void>> result43_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 8)))==0) { + std::optional> result42_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 16)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 24)); + + result42_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + std::optional variant41_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 24)))) { + case 0: { + variant41_opt = types::ErrorCode{{types::ErrorCode::DnsTimeout{}}}; + } break; + case 1: { std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len2 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option3.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len2)); + } + std::optional option4; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + + option4.emplace((uint16_t((int32_t) (*((uint16_t*) (ptr0 + (34+3*sizeof(void*)))))))); + } + + variant41_opt = types::ErrorCode{{types::ErrorCode::DnsError{types::DnsErrorPayload{std::move(option3), std::move(option4), }}}}; + } break; + case 2: { + variant41_opt = types::ErrorCode{{types::ErrorCode::DestinationNotFound{}}}; + } break; + case 3: { + variant41_opt = types::ErrorCode{{types::ErrorCode::DestinationUnavailable{}}}; + } break; + case 4: { + variant41_opt = types::ErrorCode{{types::ErrorCode::DestinationIpProhibited{}}}; + } break; + case 5: { + variant41_opt = types::ErrorCode{{types::ErrorCode::DestinationIpUnroutable{}}}; + } break; + case 6: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionRefused{}}}; + } break; + case 7: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionTerminated{}}}; + } break; + case 8: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionTimeout{}}}; + } break; + case 9: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionReadTimeout{}}}; + } break; + case 10: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionWriteTimeout{}}}; + } break; + case 11: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConnectionLimitReached{}}}; + } break; + case 12: { + variant41_opt = types::ErrorCode{{types::ErrorCode::TlsProtocolError{}}}; + } break; + case 13: { + variant41_opt = types::ErrorCode{{types::ErrorCode::TlsCertificateError{}}}; + } break; + case 14: { std::optional option5; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option5.emplace((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 33)))))); + } + std::optional option7; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+1*sizeof(void*)))))) { + auto _len6 = *((size_t*) (ptr0 + (32+3*sizeof(void*)))); + + + option7.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+2*sizeof(void*))))), _len6)); + } + + variant41_opt = types::ErrorCode{{types::ErrorCode::TlsAlertReceived{types::TlsAlertReceivedPayload{std::move(option5), std::move(option7), }}}}; + } break; + case 15: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestDenied{}}}; + } break; + case 16: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestLengthRequired{}}}; + } break; + case 17: { std::optional option8; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option8.emplace((uint64_t(*((int64_t*) (ptr0 + 40))))); + } + + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestBodySize{std::move(option8)}}}; + } break; + case 18: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestMethodInvalid{}}}; + } break; + case 19: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriInvalid{}}}; + } break; + case 20: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriTooLong{}}}; + } break; + case 21: { std::optional option10; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l9 = *((int32_t const*)(ptr0 + 36)); + + option10.emplace((uint32_t(l9))); + } + + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSectionSize{std::move(option10)}}}; + } break; + case 22: { std::optional option15; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + std::optional option12; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+1*sizeof(void*)))))) { + auto _len11 = *((size_t*) (ptr0 + (32+3*sizeof(void*)))); + + + option12.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+2*sizeof(void*))))), _len11)); + } + std::optional option14; + if ((int32_t) (*((uint8_t*) (ptr0 + (32+4*sizeof(void*)))))) { + int32_t l13 = *((int32_t const*)(ptr0 + (36+4*sizeof(void*)))); + + option14.emplace((uint32_t(l13))); + } + + option15.emplace(types::FieldSizePayload{std::move(option12), std::move(option14), }); + } + + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSize{std::move(option15)}}}; +} break; +case 23: { std::optional option17; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l16 = *((int32_t const*)(ptr0 + 36)); + + option17.emplace((uint32_t(l16))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSectionSize{std::move(option17)}}}; +} break; +case 24: { std::optional option19; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len18 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option19.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len18)); +} +std::optional option21; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l20 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option21.emplace((uint32_t(l20))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSize{types::FieldSizePayload{std::move(option19), std::move(option21), }}}}; +} break; +case 25: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseIncomplete{}}}; +} break; +case 26: { std::optional option23; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l22 = *((int32_t const*)(ptr0 + 36)); + + option23.emplace((uint32_t(l22))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSectionSize{std::move(option23)}}}; +} break; +case 27: { std::optional option25; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len24 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option25.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len24)); +} +std::optional option27; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l26 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option27.emplace((uint32_t(l26))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSize{types::FieldSizePayload{std::move(option25), std::move(option27), }}}}; +} break; +case 28: { std::optional option28; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + + option28.emplace((uint64_t(*((int64_t*) (ptr0 + 40))))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseBodySize{std::move(option28)}}}; +} break; +case 29: { std::optional option30; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l29 = *((int32_t const*)(ptr0 + 36)); + + option30.emplace((uint32_t(l29))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSectionSize{std::move(option30)}}}; +} break; +case 30: { std::optional option32; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len31 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option32.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len31)); +} +std::optional option34; +if ((int32_t) (*((uint8_t*) (ptr0 + (32+3*sizeof(void*)))))) { + int32_t l33 = *((int32_t const*)(ptr0 + (36+3*sizeof(void*)))); + + option34.emplace((uint32_t(l33))); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSize{types::FieldSizePayload{std::move(option32), std::move(option34), }}}}; +} break; +case 31: { std::optional option36; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len35 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option36.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len35)); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTransferCoding{std::move(option36)}}}; +} break; +case 32: { std::optional option38; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len37 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option38.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len37)); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseContentCoding{std::move(option38)}}}; +} break; +case 33: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTimeout{}}}; +} break; +case 34: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpUpgradeFailed{}}}; +} break; +case 35: { + variant41_opt = types::ErrorCode{{types::ErrorCode::HttpProtocolError{}}}; +} break; +case 36: { + variant41_opt = types::ErrorCode{{types::ErrorCode::LoopDetected{}}}; +} break; +case 37: { + variant41_opt = types::ErrorCode{{types::ErrorCode::ConfigurationError{}}}; +} break; +case 38: { std::optional option40; +if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + auto _len39 = *((size_t*) (ptr0 + (32+2*sizeof(void*)))); + + + option40.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (32+1*sizeof(void*))))), _len39)); +} + +variant41_opt = types::ErrorCode{{types::ErrorCode::InternalError{std::move(option40)}}}; +} break; +} +types::ErrorCode variant41 = std::move(*variant41_opt); + +result42_opt.emplace(std::unexpected{std::move(variant41)}); +} +std::expected result42 = std::move(*result42_opt); + +result43_opt.emplace(std::expected, wit::Void>(std::move(result42))); +} else { + +result43_opt.emplace(std::unexpected{wit::Void{}}); +} +std::expected, wit::Void> result43 = std::move(*result43_opt); + +option44.emplace(std::move(result43)); +} +auto result45 = std::move(option44); +return result45; +} +wasi::http0_2_0::types::FutureIncomingResponse::FutureIncomingResponse(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::optional wasi::http0_2_0::types::HttpErrorCode(std::reference_wrapper err_) +{ + uint64_t ret_area[((24+4*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2FtypesX400X2E2X2E0X00http_error_code(err_.get().get_handle(), std::move(ptr0)); + std::optional option41; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + std::optional variant40_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 8)))) { + case 0: { + variant40_opt = ErrorCode{{ErrorCode::DnsTimeout{}}}; + } break; + case 1: { std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len1 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len1)); + } + std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr0 + (16+3*sizeof(void*)))))) { + + option3.emplace((uint16_t((int32_t) (*((uint16_t*) (ptr0 + (18+3*sizeof(void*)))))))); + } + + variant40_opt = ErrorCode{{ErrorCode::DnsError{DnsErrorPayload{std::move(option2), std::move(option3), }}}}; + } break; + case 2: { + variant40_opt = ErrorCode{{ErrorCode::DestinationNotFound{}}}; + } break; + case 3: { + variant40_opt = ErrorCode{{ErrorCode::DestinationUnavailable{}}}; + } break; + case 4: { + variant40_opt = ErrorCode{{ErrorCode::DestinationIpProhibited{}}}; + } break; + case 5: { + variant40_opt = ErrorCode{{ErrorCode::DestinationIpUnroutable{}}}; + } break; + case 6: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionRefused{}}}; + } break; + case 7: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionTerminated{}}}; + } break; + case 8: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionTimeout{}}}; + } break; + case 9: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionReadTimeout{}}}; + } break; + case 10: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionWriteTimeout{}}}; + } break; + case 11: { + variant40_opt = ErrorCode{{ErrorCode::ConnectionLimitReached{}}}; + } break; + case 12: { + variant40_opt = ErrorCode{{ErrorCode::TlsProtocolError{}}}; + } break; + case 13: { + variant40_opt = ErrorCode{{ErrorCode::TlsCertificateError{}}}; + } break; + case 14: { std::optional option4; + if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + + option4.emplace((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 17)))))); + } + std::optional option6; + if ((int32_t) (*((uint8_t*) (ptr0 + (16+1*sizeof(void*)))))) { + auto _len5 = *((size_t*) (ptr0 + (16+3*sizeof(void*)))); + + + option6.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+2*sizeof(void*))))), _len5)); + } + + variant40_opt = ErrorCode{{ErrorCode::TlsAlertReceived{TlsAlertReceivedPayload{std::move(option4), std::move(option6), }}}}; + } break; + case 15: { + variant40_opt = ErrorCode{{ErrorCode::HttpRequestDenied{}}}; + } break; + case 16: { + variant40_opt = ErrorCode{{ErrorCode::HttpRequestLengthRequired{}}}; + } break; + case 17: { std::optional option7; + if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + + option7.emplace((uint64_t(*((int64_t*) (ptr0 + 24))))); + } + + variant40_opt = ErrorCode{{ErrorCode::HttpRequestBodySize{std::move(option7)}}}; +} break; +case 18: { + variant40_opt = ErrorCode{{ErrorCode::HttpRequestMethodInvalid{}}}; +} break; +case 19: { + variant40_opt = ErrorCode{{ErrorCode::HttpRequestUriInvalid{}}}; +} break; +case 20: { + variant40_opt = ErrorCode{{ErrorCode::HttpRequestUriTooLong{}}}; +} break; +case 21: { std::optional option9; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + int32_t l8 = *((int32_t const*)(ptr0 + 20)); + + option9.emplace((uint32_t(l8))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpRequestHeaderSectionSize{std::move(option9)}}}; +} break; +case 22: { std::optional option14; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + std::optional option11; + if ((int32_t) (*((uint8_t*) (ptr0 + (16+1*sizeof(void*)))))) { + auto _len10 = *((size_t*) (ptr0 + (16+3*sizeof(void*)))); + + + option11.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+2*sizeof(void*))))), _len10)); + } + std::optional option13; + if ((int32_t) (*((uint8_t*) (ptr0 + (16+4*sizeof(void*)))))) { + int32_t l12 = *((int32_t const*)(ptr0 + (20+4*sizeof(void*)))); + + option13.emplace((uint32_t(l12))); + } + + option14.emplace(FieldSizePayload{std::move(option11), std::move(option13), }); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpRequestHeaderSize{std::move(option14)}}}; +} break; +case 23: { std::optional option16; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + int32_t l15 = *((int32_t const*)(ptr0 + 20)); + + option16.emplace((uint32_t(l15))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpRequestTrailerSectionSize{std::move(option16)}}}; +} break; +case 24: { std::optional option18; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len17 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option18.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len17)); +} +std::optional option20; +if ((int32_t) (*((uint8_t*) (ptr0 + (16+3*sizeof(void*)))))) { + int32_t l19 = *((int32_t const*)(ptr0 + (20+3*sizeof(void*)))); + + option20.emplace((uint32_t(l19))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpRequestTrailerSize{FieldSizePayload{std::move(option18), std::move(option20), }}}}; +} break; +case 25: { + variant40_opt = ErrorCode{{ErrorCode::HttpResponseIncomplete{}}}; +} break; +case 26: { std::optional option22; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + int32_t l21 = *((int32_t const*)(ptr0 + 20)); + + option22.emplace((uint32_t(l21))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseHeaderSectionSize{std::move(option22)}}}; +} break; +case 27: { std::optional option24; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len23 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option24.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len23)); +} +std::optional option26; +if ((int32_t) (*((uint8_t*) (ptr0 + (16+3*sizeof(void*)))))) { + int32_t l25 = *((int32_t const*)(ptr0 + (20+3*sizeof(void*)))); + + option26.emplace((uint32_t(l25))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseHeaderSize{FieldSizePayload{std::move(option24), std::move(option26), }}}}; +} break; +case 28: { std::optional option27; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + + option27.emplace((uint64_t(*((int64_t*) (ptr0 + 24))))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseBodySize{std::move(option27)}}}; +} break; +case 29: { std::optional option29; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + int32_t l28 = *((int32_t const*)(ptr0 + 20)); + + option29.emplace((uint32_t(l28))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseTrailerSectionSize{std::move(option29)}}}; +} break; +case 30: { std::optional option31; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len30 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option31.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len30)); +} +std::optional option33; +if ((int32_t) (*((uint8_t*) (ptr0 + (16+3*sizeof(void*)))))) { + int32_t l32 = *((int32_t const*)(ptr0 + (20+3*sizeof(void*)))); + + option33.emplace((uint32_t(l32))); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseTrailerSize{FieldSizePayload{std::move(option31), std::move(option33), }}}}; +} break; +case 31: { std::optional option35; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len34 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option35.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len34)); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseTransferCoding{std::move(option35)}}}; +} break; +case 32: { std::optional option37; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len36 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option37.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len36)); +} + +variant40_opt = ErrorCode{{ErrorCode::HttpResponseContentCoding{std::move(option37)}}}; +} break; +case 33: { + variant40_opt = ErrorCode{{ErrorCode::HttpResponseTimeout{}}}; +} break; +case 34: { + variant40_opt = ErrorCode{{ErrorCode::HttpUpgradeFailed{}}}; +} break; +case 35: { + variant40_opt = ErrorCode{{ErrorCode::HttpProtocolError{}}}; +} break; +case 36: { + variant40_opt = ErrorCode{{ErrorCode::LoopDetected{}}}; +} break; +case 37: { + variant40_opt = ErrorCode{{ErrorCode::ConfigurationError{}}}; +} break; +case 38: { std::optional option39; +if ((int32_t) (*((uint8_t*) (ptr0 + 16)))) { + auto _len38 = *((size_t*) (ptr0 + (16+2*sizeof(void*)))); + + + option39.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + (16+1*sizeof(void*))))), _len38)); +} + +variant40_opt = ErrorCode{{ErrorCode::InternalError{std::move(option39)}}}; +} break; +} +ErrorCode variant40 = std::move(*variant40_opt); + +option41.emplace(std::move(variant40)); +} +auto result42 = std::move(option41); +return result42; +} +std::expected wasi::http0_2_0::outgoing_handler::Handle(types::OutgoingRequest&& request, std::optional options) +{ + uint64_t ret_area[((24+4*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + int32_t option2; + int32_t option3; + if ((options).has_value()) { + types::RequestOptions payload1 = (std::move(options)).value(); + option2 = (int32_t(1)); + option3 = payload1.into_handle(); + } else { + option2 = (int32_t(0)); + option3 = int32_t(0); + } + uint8_t* ptr4 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AhttpX2Foutgoing_handlerX400X2E2X2E0X00handle(request.into_handle(), std::move(option2), std::move(option3), std::move(ptr4)); + std::optional> result46_opt; + if ((int32_t) (*((uint8_t*) (ptr4 + 0)))==0) { + int32_t l5 = *((int32_t const*)(ptr4 + 8)); + + result46_opt.emplace(std::expected(wit::ResourceImportBase{l5})); + } else { + std::optional variant45_opt; + switch ((int32_t) (*((uint8_t*) (ptr4 + 8)))) { + case 0: { + variant45_opt = types::ErrorCode{{types::ErrorCode::DnsTimeout{}}}; + } break; + case 1: { std::optional option7; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len6 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option7.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len6)); + } + std::optional option8; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + + option8.emplace((uint16_t((int32_t) (*((uint16_t*) (ptr4 + (18+3*sizeof(void*)))))))); + } + + variant45_opt = types::ErrorCode{{types::ErrorCode::DnsError{types::DnsErrorPayload{std::move(option7), std::move(option8), }}}}; + } break; + case 2: { + variant45_opt = types::ErrorCode{{types::ErrorCode::DestinationNotFound{}}}; + } break; + case 3: { + variant45_opt = types::ErrorCode{{types::ErrorCode::DestinationUnavailable{}}}; + } break; + case 4: { + variant45_opt = types::ErrorCode{{types::ErrorCode::DestinationIpProhibited{}}}; + } break; + case 5: { + variant45_opt = types::ErrorCode{{types::ErrorCode::DestinationIpUnroutable{}}}; + } break; + case 6: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionRefused{}}}; + } break; + case 7: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionTerminated{}}}; + } break; + case 8: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionTimeout{}}}; + } break; + case 9: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionReadTimeout{}}}; + } break; + case 10: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionWriteTimeout{}}}; + } break; + case 11: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConnectionLimitReached{}}}; + } break; + case 12: { + variant45_opt = types::ErrorCode{{types::ErrorCode::TlsProtocolError{}}}; + } break; + case 13: { + variant45_opt = types::ErrorCode{{types::ErrorCode::TlsCertificateError{}}}; + } break; + case 14: { std::optional option9; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option9.emplace((uint8_t((int32_t) (*((uint8_t*) (ptr4 + 17)))))); + } + std::optional option11; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+1*sizeof(void*)))))) { + auto _len10 = *((size_t*) (ptr4 + (16+3*sizeof(void*)))); + + + option11.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+2*sizeof(void*))))), _len10)); + } + + variant45_opt = types::ErrorCode{{types::ErrorCode::TlsAlertReceived{types::TlsAlertReceivedPayload{std::move(option9), std::move(option11), }}}}; + } break; + case 15: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestDenied{}}}; + } break; + case 16: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestLengthRequired{}}}; + } break; + case 17: { std::optional option12; + if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option12.emplace((uint64_t(*((int64_t*) (ptr4 + 24))))); + } + + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestBodySize{std::move(option12)}}}; +} break; +case 18: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestMethodInvalid{}}}; +} break; +case 19: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriInvalid{}}}; +} break; +case 20: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestUriTooLong{}}}; +} break; +case 21: { std::optional option14; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l13 = *((int32_t const*)(ptr4 + 20)); + + option14.emplace((uint32_t(l13))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSectionSize{std::move(option14)}}}; +} break; +case 22: { std::optional option19; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + std::optional option16; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+1*sizeof(void*)))))) { + auto _len15 = *((size_t*) (ptr4 + (16+3*sizeof(void*)))); + + + option16.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+2*sizeof(void*))))), _len15)); + } + std::optional option18; + if ((int32_t) (*((uint8_t*) (ptr4 + (16+4*sizeof(void*)))))) { + int32_t l17 = *((int32_t const*)(ptr4 + (20+4*sizeof(void*)))); + + option18.emplace((uint32_t(l17))); + } + + option19.emplace(types::FieldSizePayload{std::move(option16), std::move(option18), }); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestHeaderSize{std::move(option19)}}}; +} break; +case 23: { std::optional option21; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l20 = *((int32_t const*)(ptr4 + 20)); + + option21.emplace((uint32_t(l20))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSectionSize{std::move(option21)}}}; +} break; +case 24: { std::optional option23; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len22 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option23.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len22)); +} +std::optional option25; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l24 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option25.emplace((uint32_t(l24))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpRequestTrailerSize{types::FieldSizePayload{std::move(option23), std::move(option25), }}}}; +} break; +case 25: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseIncomplete{}}}; +} break; +case 26: { std::optional option27; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l26 = *((int32_t const*)(ptr4 + 20)); + + option27.emplace((uint32_t(l26))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSectionSize{std::move(option27)}}}; +} break; +case 27: { std::optional option29; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len28 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option29.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len28)); +} +std::optional option31; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l30 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option31.emplace((uint32_t(l30))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseHeaderSize{types::FieldSizePayload{std::move(option29), std::move(option31), }}}}; +} break; +case 28: { std::optional option32; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + + option32.emplace((uint64_t(*((int64_t*) (ptr4 + 24))))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseBodySize{std::move(option32)}}}; +} break; +case 29: { std::optional option34; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + int32_t l33 = *((int32_t const*)(ptr4 + 20)); + + option34.emplace((uint32_t(l33))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSectionSize{std::move(option34)}}}; +} break; +case 30: { std::optional option36; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len35 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option36.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len35)); +} +std::optional option38; +if ((int32_t) (*((uint8_t*) (ptr4 + (16+3*sizeof(void*)))))) { + int32_t l37 = *((int32_t const*)(ptr4 + (20+3*sizeof(void*)))); + + option38.emplace((uint32_t(l37))); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTrailerSize{types::FieldSizePayload{std::move(option36), std::move(option38), }}}}; +} break; +case 31: { std::optional option40; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len39 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option40.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len39)); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTransferCoding{std::move(option40)}}}; +} break; +case 32: { std::optional option42; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len41 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option42.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len41)); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseContentCoding{std::move(option42)}}}; +} break; +case 33: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpResponseTimeout{}}}; +} break; +case 34: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpUpgradeFailed{}}}; +} break; +case 35: { + variant45_opt = types::ErrorCode{{types::ErrorCode::HttpProtocolError{}}}; +} break; +case 36: { + variant45_opt = types::ErrorCode{{types::ErrorCode::LoopDetected{}}}; +} break; +case 37: { + variant45_opt = types::ErrorCode{{types::ErrorCode::ConfigurationError{}}}; +} break; +case 38: { std::optional option44; +if ((int32_t) (*((uint8_t*) (ptr4 + 16)))) { + auto _len43 = *((size_t*) (ptr4 + (16+2*sizeof(void*)))); + + + option44.emplace(wit::string((char const*)(*((uint8_t**) (ptr4 + (16+1*sizeof(void*))))), _len43)); +} + +variant45_opt = types::ErrorCode{{types::ErrorCode::InternalError{std::move(option44)}}}; +} break; +} +types::ErrorCode variant45 = std::move(*variant45_opt); + +result46_opt.emplace(std::unexpected{std::move(variant45)}); +} +std::expected result46 = std::move(*result46_opt); +auto result47 = std::move(result46); +return result47; +} +std::expected fermyon::spin2_0_0::llm::Infer(std::string_view model, std::string_view prompt, std::optional params) +{ + uintptr_t ret_area[((8+3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = model; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = prompt; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + int32_t option4; + int32_t option5; + float option6; + int32_t option7; + float option8; + int32_t option9; + float option10; + if ((params).has_value()) { + InferencingParams payload3 = (std::move(params)).value(); + option4 = (int32_t(1)); + option5 = (int32_t((payload3).max_tokens)); + option6 = (float((payload3).repeat_penalty)); + option7 = (int32_t((payload3).repeat_penalty_last_n_token_count)); + option8 = (float((payload3).temperature)); + option9 = (int32_t((payload3).top_k)); + option10 = (float((payload3).top_p)); + } else { + option4 = (int32_t(0)); + option5 = int32_t(0); + option6 = 0.0f; + option7 = int32_t(0); + option8 = 0.0f; + option9 = int32_t(0); + option10 = 0.0f; + } + uint8_t* ptr11 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FllmX402X2E0X2E0X00infer(std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(option4), std::move(option5), std::move(option6), std::move(option7), std::move(option8), std::move(option9), std::move(option10), std::move(ptr11)); + std::optional> result18_opt; + if ((int32_t) (*((uint8_t*) (ptr11 + 0)))==0) { + auto _len12 = *((size_t*) (ptr11 + (2*sizeof(void*)))); + + int32_t l13 = *((int32_t const*)(ptr11 + (3*sizeof(void*)))); + int32_t l14 = *((int32_t const*)(ptr11 + (4+3*sizeof(void*)))); + + result18_opt.emplace(std::expected(InferencingResult{wit::string((char const*)(*((uint8_t**) (ptr11 + sizeof(void*)))), _len12), InferencingUsage{(uint32_t(l13)), (uint32_t(l14)), }, })); + } else { + std::optional variant17_opt; + switch ((int32_t) (*((uint8_t*) (ptr11 + sizeof(void*))))) { + case 0: { + variant17_opt = Error{{Error::ModelNotSupported{}}}; + } break; + case 1: { auto _len15 = *((size_t*) (ptr11 + (3*sizeof(void*)))); + + + variant17_opt = Error{{Error::RuntimeError{wit::string((char const*)(*((uint8_t**) (ptr11 + (2*sizeof(void*))))), _len15)}}}; + } break; + case 2: { auto _len16 = *((size_t*) (ptr11 + (3*sizeof(void*)))); + + + variant17_opt = Error{{Error::InvalidInput{wit::string((char const*)(*((uint8_t**) (ptr11 + (2*sizeof(void*))))), _len16)}}}; + } break; +} +Error variant17 = std::move(*variant17_opt); + +result18_opt.emplace(std::unexpected{std::move(variant17)}); +} +std::expected result18 = std::move(*result18_opt); +auto result19 = std::move(result18); +return result19; +} +std::expected fermyon::spin2_0_0::llm::GenerateEmbeddings(std::string_view model, std::span text) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = model; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec2 = text; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec1 = _iter_elem; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + sizeof(void*))) = _len1; + *((uint8_t**)(_base + 0)) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FllmX402X2E0X2E0X00generate_embeddings(std::move(_ptr0), std::move(_len0), std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result10_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + auto _base5 = *((uint8_t**) (ptr3 + sizeof(void*))); + auto _len5 = *((size_t*) (ptr3 + (2*sizeof(void*)))); + auto _result5 = wit::vector>::allocate(_len5); + for (unsigned i=0; i<_len5; ++i) { + auto _base = _base5 + i * (2*sizeof(void*)); + auto _len4 = *((size_t*) (_base + sizeof(void*))); + auto _e5 = wit::vector((float*)(*((uint8_t**) (_base + 0))), _len4); + _result5.initialize(i, std::move(_e5)); + } + int32_t l6 = *((int32_t const*)(ptr3 + (3*sizeof(void*)))); + + result10_opt.emplace(std::expected(EmbeddingsResult{std::move(_result5), EmbeddingsUsage{(uint32_t(l6)), }, })); + } else { + std::optional variant9_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + sizeof(void*))))) { + case 0: { + variant9_opt = Error{{Error::ModelNotSupported{}}}; + } break; + case 1: { auto _len7 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant9_opt = Error{{Error::RuntimeError{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len7)}}}; + } break; + case 2: { auto _len8 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant9_opt = Error{{Error::InvalidInput{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len8)}}}; + } break; +} +Error variant9 = std::move(*variant9_opt); + +result10_opt.emplace(std::unexpected{std::move(variant9)}); +} +std::expected result10 = std::move(*result10_opt); +auto result11 = std::move(result10); +return result11; +} +fermyon::spin2_0_0::redis::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected fermyon::spin2_0_0::redis::Connection::Open(std::string_view address) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant4_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant4_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + redis::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected fermyon::spin2_0_0::redis::Connection::Publish(std::string_view channel, std::span payload) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = channel; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = payload; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Epublish((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant4_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant4_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant4_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant4_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + redis::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected>, fermyon::spin2_0_0::redis::Error> fermyon::spin2_0_0::redis::Connection::Get(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eget((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional>, redis::Error>> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + std::optional> option3; + if ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + option3.emplace(wit::vector((uint8_t*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)); + } + + result6_opt.emplace(std::expected>, redis::Error>(std::move(option3))); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant5_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant5_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant5_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant5_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + redis::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected>, redis::Error> result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected fermyon::spin2_0_0::redis::Connection::Set(std::string_view key, std::span value) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = value; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eset((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant4_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant4_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant4_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant4_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + redis::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected fermyon::spin2_0_0::redis::Connection::Incr(std::string_view key) const +{ + uint64_t ret_area[((16+2*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eincr((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected((int64_t(*((int64_t*) (ptr1 + 8)))))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + 8)))) { + case 0: { + variant3_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant3_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant3_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len2 = *((size_t*) (ptr1 + (8+2*sizeof(void*)))); + + + variant3_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (8+1*sizeof(void*))))), _len2)}}}; + } break; + } + redis::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected fermyon::spin2_0_0::redis::Connection::Del(std::span keys) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec1 = keys; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + for (size_t i = 0; i < _len1; ++i) { + auto _base = _ptr1 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec1[i]; + auto&& _vec0 = _iter_elem; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + + } + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Edel((*this).get_handle(), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + int32_t l3 = *((int32_t const*)(ptr2 + sizeof(void*))); + + result6_opt.emplace(std::expected((uint32_t(l3)))); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant5_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant5_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant5_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len4 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant5_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + redis::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected fermyon::spin2_0_0::redis::Connection::Sadd(std::string_view key, std::span values) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec2 = values; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec1 = _iter_elem; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + sizeof(void*))) = _len1; + *((uint8_t**)(_base + 0)) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esadd((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result7_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + int32_t l4 = *((int32_t const*)(ptr3 + sizeof(void*))); + + result7_opt.emplace(std::expected((uint32_t(l4)))); + } else { + std::optional variant6_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + sizeof(void*))))) { + case 0: { + variant6_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant6_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant6_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len5 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant6_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len5)}}}; + } break; + } + redis::Error variant6 = std::move(*variant6_opt); + + result7_opt.emplace(std::unexpected{std::move(variant6)}); +} +std::expected result7 = std::move(*result7_opt); +auto result8 = std::move(result7); +return result8; +} +std::expected, fermyon::spin2_0_0::redis::Error> fermyon::spin2_0_0::redis::Connection::Smembers(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esmembers((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional, redis::Error>> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + auto _base3 = *((uint8_t**) (ptr1 + sizeof(void*))); + auto _len3 = *((size_t*) (ptr1 + (2*sizeof(void*)))); + auto _result3 = wit::vector::allocate(_len3); + for (unsigned i=0; i<_len3; ++i) { + auto _base = _base3 + i * (2*sizeof(void*)); + auto _len2 = *((size_t*) (_base + sizeof(void*))); + + auto _e3 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len2); + _result3.initialize(i, std::move(_e3)); + } + + result6_opt.emplace(std::expected, redis::Error>(std::move(_result3))); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant5_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant5_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant5_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant5_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + redis::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected, redis::Error> result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected fermyon::spin2_0_0::redis::Connection::Srem(std::string_view key, std::span values) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec2 = values; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec1 = _iter_elem; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + sizeof(void*))) = _len1; + *((uint8_t**)(_base + 0)) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Esrem((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result7_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + int32_t l4 = *((int32_t const*)(ptr3 + sizeof(void*))); + + result7_opt.emplace(std::expected((uint32_t(l4)))); + } else { + std::optional variant6_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + sizeof(void*))))) { + case 0: { + variant6_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant6_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant6_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len5 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant6_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len5)}}}; + } break; + } + redis::Error variant6 = std::move(*variant6_opt); + + result7_opt.emplace(std::unexpected{std::move(variant6)}); +} +std::expected result7 = std::move(*result7_opt); +auto result8 = std::move(result7); +return result8; +} +std::expected, fermyon::spin2_0_0::redis::Error> fermyon::spin2_0_0::redis::Connection::Execute(std::string_view command, std::span arguments) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = command; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec4 = arguments; + auto _ptr4 = (uint8_t*)(_vec4.data()); + auto _len4 = (size_t)(_vec4.size()); + for (size_t i = 0; i < _len4; ++i) { + auto _base = _ptr4 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec4[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int64_t*)(_base + 8)) = (int64_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + auto&& _vec3 = payload2; + auto _ptr3 = (uint8_t*)(_vec3.data()); + auto _len3 = (size_t)(_vec3.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len3; + *((uint8_t**)(_base + 8)) = _ptr3; + break; + } + } + + } + uint8_t* ptr5 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FredisX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr4), std::move(_len4), std::move(ptr5)); + std::optional, redis::Error>> result12_opt; + if ((int32_t) (*((uint8_t*) (ptr5 + 0)))==0) { + auto _base9 = *((uint8_t**) (ptr5 + sizeof(void*))); + auto _len9 = *((size_t*) (ptr5 + (2*sizeof(void*)))); + auto _result9 = wit::vector::allocate(_len9); + for (unsigned i=0; i<_len9; ++i) { + auto _base = _base9 + i * (8+2*sizeof(void*)); + std::optional variant8_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant8_opt = redis::RedisResult{{redis::RedisResult::Nil{}}}; + } break; + case 1: { auto _len6 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant8_opt = redis::RedisResult{{redis::RedisResult::Status{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len6)}}}; + } break; + case 2: { + variant8_opt = redis::RedisResult{{redis::RedisResult::Int64{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 3: { auto _len7 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant8_opt = redis::RedisResult{{redis::RedisResult::Binary{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len7)}}}; + } break; + } + redis::RedisResult variant8 = std::move(*variant8_opt); + auto _e9 = std::move(variant8); + _result9.initialize(i, std::move(_e9)); +} + +result12_opt.emplace(std::expected, redis::Error>(std::move(_result9))); +} else { +std::optional variant11_opt; +switch ((int32_t) (*((uint8_t*) (ptr5 + sizeof(void*))))) { + case 0: { + variant11_opt = redis::Error{{redis::Error::InvalidAddress{}}}; + } break; + case 1: { + variant11_opt = redis::Error{{redis::Error::TooManyConnections{}}}; + } break; + case 2: { + variant11_opt = redis::Error{{redis::Error::TypeError{}}}; + } break; + case 3: { auto _len10 = *((size_t*) (ptr5 + (3*sizeof(void*)))); + + + variant11_opt = redis::Error{{redis::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr5 + (2*sizeof(void*))))), _len10)}}}; +} break; +} +redis::Error variant11 = std::move(*variant11_opt); + +result12_opt.emplace(std::unexpected{std::move(variant11)}); +} +std::expected, redis::Error> result12 = std::move(*result12_opt); +auto result13 = std::move(result12); +return result13; +} +fermyon::spin2_0_0::redis::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +fermyon::spin2_0_0::mqtt::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected fermyon::spin2_0_0::mqtt::Connection::Open(std::string_view address, std::string_view username, std::string_view password, uint64_t keep_alive_interval_in_secs) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = username; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + auto&& _vec2 = password; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(_ptr2), std::move(_len2), (int64_t(keep_alive_interval_in_secs)), std::move(ptr3)); + std::optional> result8_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + int32_t l4 = *((int32_t const*)(ptr3 + sizeof(void*))); + + result8_opt.emplace(std::expected(wit::ResourceImportBase{l4})); + } else { + std::optional variant7_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + sizeof(void*))))) { + case 0: { + variant7_opt = mqtt::Error{{mqtt::Error::InvalidAddress{}}}; + } break; + case 1: { + variant7_opt = mqtt::Error{{mqtt::Error::TooManyConnections{}}}; + } break; + case 2: { auto _len5 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant7_opt = mqtt::Error{{mqtt::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len5)}}}; + } break; + case 3: { auto _len6 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant7_opt = mqtt::Error{{mqtt::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len6)}}}; + } break; +} +mqtt::Error variant7 = std::move(*variant7_opt); + +result8_opt.emplace(std::unexpected{std::move(variant7)}); +} +std::expected result8 = std::move(*result8_opt); +auto result9 = std::move(result8); +return result9; +} +std::expected fermyon::spin2_0_0::mqtt::Connection::Publish(std::string_view topic, std::span payload, mqtt::Qos qos) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = topic; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = payload; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FmqttX402X2E0X2E0X00X5BmethodX5DconnectionX2Epublish((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), int32_t(qos), std::move(ptr2)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result6_opt.emplace(std::expected()); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant5_opt = mqtt::Error{{mqtt::Error::InvalidAddress{}}}; + } break; + case 1: { + variant5_opt = mqtt::Error{{mqtt::Error::TooManyConnections{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant5_opt = mqtt::Error{{mqtt::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 3: { auto _len4 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant5_opt = mqtt::Error{{mqtt::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len4)}}}; + } break; +} +mqtt::Error variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +fermyon::spin2_0_0::mqtt::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +fermyon::spin2_0_0::postgres::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected fermyon::spin2_0_0::postgres::Connection::Open(std::string_view address) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result9_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result9_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant8_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 1: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 2: { auto _len5 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len5)}}}; +} break; +case 3: { auto _len6 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len6)}}}; +} break; +case 4: { auto _len7 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len7)}}}; +} break; +} +rdbms_types::Error variant8 = std::move(*variant8_opt); + +result9_opt.emplace(std::unexpected{std::move(variant8)}); +} +std::expected result9 = std::move(*result9_opt); +auto result10 = std::move(result9); +return result10; +} +std::expected fermyon::spin2_0_0::postgres::Connection::Query(std::string_view statement, std::span params) const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((int8_t*)(_base + 8)) = (int32_t(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((int16_t*)(_base + 8)) = (int32_t(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + *((int32_t*)(_base + 8)) = (int32_t(payload8)); + break; + } + case 8: { + auto& payload9 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + *((int64_t*)(_base + 8)) = (int64_t(payload9)); + break; + } + case 9: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((float*)(_base + 8)) = (float(payload10)); + break; + } + case 10: { + auto& payload11 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((double*)(_base + 8)) = (double(payload11)); + break; + } + case 11: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + auto&& _vec13 = payload12; + auto _ptr13 = (uint8_t*)(_vec13.data()); + auto _len13 = (size_t)(_vec13.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len13; + *((uint8_t**)(_base + 8)) = _ptr13; + break; + } + case 12: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + auto&& _vec15 = payload14; + auto _ptr15 = (uint8_t*)(_vec15.data()); + auto _len15 = (size_t)(_vec15.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len15; + *((uint8_t**)(_base + 8)) = _ptr15; + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BmethodX5DconnectionX2Equery((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result34_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + auto _base20 = *((uint8_t**) (ptr18 + sizeof(void*))); + auto _len20 = *((size_t*) (ptr18 + (2*sizeof(void*)))); + auto _result20 = wit::vector::allocate(_len20); + for (unsigned i=0; i<_len20; ++i) { + auto _base = _base20 + i * (3*sizeof(void*)); + auto _len19 = *((size_t*) (_base + sizeof(void*))); + + auto _e20 = rdbms_types::Column{wit::string((char const*)(*((uint8_t**) (_base + 0))), _len19), (rdbms_types::DbDataType)(int32_t) (*((uint8_t*) (_base + (2*sizeof(void*))))), }; + _result20.initialize(i, std::move(_e20)); + } + auto _base27 = *((uint8_t**) (ptr18 + (3*sizeof(void*)))); + auto _len27 = *((size_t*) (ptr18 + (4*sizeof(void*)))); + auto _result27 = wit::vector>::allocate(_len27); + for (unsigned i=0; i<_len27; ++i) { + auto _base = _base27 + i * (2*sizeof(void*)); + auto _base26 = *((uint8_t**) (_base + 0)); + auto _len26 = *((size_t*) (_base + sizeof(void*))); + auto _result26 = wit::vector::allocate(_len26); + for (unsigned i=0; i<_len26; ++i) { + auto _base = _base26 + i * (8+2*sizeof(void*)); + std::optional variant25_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Boolean{(bool((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 1: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int8{(int8_t((int32_t) (*((int8_t*) (_base + 8)))))}}}; + } break; + case 2: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int16{(int16_t((int32_t) (*((int16_t*) (_base + 8)))))}}}; + } break; + case 3: { int32_t l21 = *((int32_t const*)(_base + 8)); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int32{(int32_t(l21))}}}; + } break; + case 4: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int64{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 5: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint8{(uint8_t((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 6: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint16{(uint16_t((int32_t) (*((uint16_t*) (_base + 8)))))}}}; + } break; + case 7: { int32_t l22 = *((int32_t const*)(_base + 8)); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint32{(uint32_t(l22))}}}; + } break; + case 8: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint64{(uint64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 9: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Floating32{(float(*((float*) (_base + 8))))}}}; + } break; + case 10: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Floating64{(double(*((double*) (_base + 8))))}}}; + } break; + case 11: { auto _len23 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Str{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len23)}}}; + } break; + case 12: { auto _len24 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Binary{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len24)}}}; + } break; + case 13: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::DbNull{}}}; + } break; + case 14: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Unsupported{}}}; + } break; +} +rdbms_types::DbValue variant25 = std::move(*variant25_opt); +auto _e26 = std::move(variant25); +_result26.initialize(i, std::move(_e26)); +} +auto _e27 = std::move(_result26); +_result27.initialize(i, std::move(_e27)); +} + +result34_opt.emplace(std::expected(rdbms_types::RowSet{std::move(_result20), std::move(_result27), })); +} else { +std::optional variant33_opt; +switch ((int32_t) (*((uint8_t*) (ptr18 + sizeof(void*))))) { + case 0: { auto _len28 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant33_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len28)}}}; +} break; +case 1: { auto _len29 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len29)}}}; +} break; +case 2: { auto _len30 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len30)}}}; +} break; +case 3: { auto _len31 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len31)}}}; +} break; +case 4: { auto _len32 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len32)}}}; +} break; +} +rdbms_types::Error variant33 = std::move(*variant33_opt); + +result34_opt.emplace(std::unexpected{std::move(variant33)}); +} +std::expected result34 = std::move(*result34_opt); +auto result35 = std::move(result34); +return result35; +} +std::expected fermyon::spin2_0_0::postgres::Connection::Execute(std::string_view statement, std::span params) const +{ + uint64_t ret_area[((16+2*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((int8_t*)(_base + 8)) = (int32_t(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((int16_t*)(_base + 8)) = (int32_t(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + *((int32_t*)(_base + 8)) = (int32_t(payload8)); + break; + } + case 8: { + auto& payload9 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + *((int64_t*)(_base + 8)) = (int64_t(payload9)); + break; + } + case 9: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((float*)(_base + 8)) = (float(payload10)); + break; + } + case 10: { + auto& payload11 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((double*)(_base + 8)) = (double(payload11)); + break; + } + case 11: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + auto&& _vec13 = payload12; + auto _ptr13 = (uint8_t*)(_vec13.data()); + auto _len13 = (size_t)(_vec13.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len13; + *((uint8_t**)(_base + 8)) = _ptr13; + break; + } + case 12: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + auto&& _vec15 = payload14; + auto _ptr15 = (uint8_t*)(_vec15.data()); + auto _len15 = (size_t)(_vec15.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len15; + *((uint8_t**)(_base + 8)) = _ptr15; + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FpostgresX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result25_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + + result25_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr18 + 8)))))); + } else { + std::optional variant24_opt; + switch ((int32_t) (*((uint8_t*) (ptr18 + 8)))) { + case 0: { auto _len19 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len19)}}}; + } break; + case 1: { auto _len20 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len20)}}}; + } break; + case 2: { auto _len21 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len21)}}}; +} break; +case 3: { auto _len22 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + +variant24_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len22)}}}; +} break; +case 4: { auto _len23 = *((size_t*) (ptr18 + (8+2*sizeof(void*)))); + + +variant24_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (8+1*sizeof(void*))))), _len23)}}}; +} break; +} +rdbms_types::Error variant24 = std::move(*variant24_opt); + +result25_opt.emplace(std::unexpected{std::move(variant24)}); +} +std::expected result25 = std::move(*result25_opt); +auto result26 = std::move(result25); +return result26; +} +fermyon::spin2_0_0::postgres::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +fermyon::spin2_0_0::mysql::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected fermyon::spin2_0_0::mysql::Connection::Open(std::string_view address) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = address; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result9_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result9_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant8_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 1: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 2: { auto _len5 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant8_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len5)}}}; +} break; +case 3: { auto _len6 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len6)}}}; +} break; +case 4: { auto _len7 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant8_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len7)}}}; +} break; +} +rdbms_types::Error variant8 = std::move(*variant8_opt); + +result9_opt.emplace(std::unexpected{std::move(variant8)}); +} +std::expected result9 = std::move(*result9_opt); +auto result10 = std::move(result9); +return result10; +} +std::expected fermyon::spin2_0_0::mysql::Connection::Query(std::string_view statement, std::span params) const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((int8_t*)(_base + 8)) = (int32_t(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((int16_t*)(_base + 8)) = (int32_t(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + *((int32_t*)(_base + 8)) = (int32_t(payload8)); + break; + } + case 8: { + auto& payload9 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + *((int64_t*)(_base + 8)) = (int64_t(payload9)); + break; + } + case 9: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((float*)(_base + 8)) = (float(payload10)); + break; + } + case 10: { + auto& payload11 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((double*)(_base + 8)) = (double(payload11)); + break; + } + case 11: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + auto&& _vec13 = payload12; + auto _ptr13 = (uint8_t*)(_vec13.data()); + auto _len13 = (size_t)(_vec13.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len13; + *((uint8_t**)(_base + 8)) = _ptr13; + break; + } + case 12: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + auto&& _vec15 = payload14; + auto _ptr15 = (uint8_t*)(_vec15.data()); + auto _len15 = (size_t)(_vec15.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len15; + *((uint8_t**)(_base + 8)) = _ptr15; + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BmethodX5DconnectionX2Equery((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result34_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + auto _base20 = *((uint8_t**) (ptr18 + sizeof(void*))); + auto _len20 = *((size_t*) (ptr18 + (2*sizeof(void*)))); + auto _result20 = wit::vector::allocate(_len20); + for (unsigned i=0; i<_len20; ++i) { + auto _base = _base20 + i * (3*sizeof(void*)); + auto _len19 = *((size_t*) (_base + sizeof(void*))); + + auto _e20 = rdbms_types::Column{wit::string((char const*)(*((uint8_t**) (_base + 0))), _len19), (rdbms_types::DbDataType)(int32_t) (*((uint8_t*) (_base + (2*sizeof(void*))))), }; + _result20.initialize(i, std::move(_e20)); + } + auto _base27 = *((uint8_t**) (ptr18 + (3*sizeof(void*)))); + auto _len27 = *((size_t*) (ptr18 + (4*sizeof(void*)))); + auto _result27 = wit::vector>::allocate(_len27); + for (unsigned i=0; i<_len27; ++i) { + auto _base = _base27 + i * (2*sizeof(void*)); + auto _base26 = *((uint8_t**) (_base + 0)); + auto _len26 = *((size_t*) (_base + sizeof(void*))); + auto _result26 = wit::vector::allocate(_len26); + for (unsigned i=0; i<_len26; ++i) { + auto _base = _base26 + i * (8+2*sizeof(void*)); + std::optional variant25_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Boolean{(bool((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 1: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int8{(int8_t((int32_t) (*((int8_t*) (_base + 8)))))}}}; + } break; + case 2: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int16{(int16_t((int32_t) (*((int16_t*) (_base + 8)))))}}}; + } break; + case 3: { int32_t l21 = *((int32_t const*)(_base + 8)); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int32{(int32_t(l21))}}}; + } break; + case 4: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Int64{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 5: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint8{(uint8_t((int32_t) (*((uint8_t*) (_base + 8)))))}}}; + } break; + case 6: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint16{(uint16_t((int32_t) (*((uint16_t*) (_base + 8)))))}}}; + } break; + case 7: { int32_t l22 = *((int32_t const*)(_base + 8)); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint32{(uint32_t(l22))}}}; + } break; + case 8: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Uint64{(uint64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 9: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Floating32{(float(*((float*) (_base + 8))))}}}; + } break; + case 10: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Floating64{(double(*((double*) (_base + 8))))}}}; + } break; + case 11: { auto _len23 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Str{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len23)}}}; + } break; + case 12: { auto _len24 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Binary{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len24)}}}; + } break; + case 13: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::DbNull{}}}; + } break; + case 14: { + variant25_opt = rdbms_types::DbValue{{rdbms_types::DbValue::Unsupported{}}}; + } break; +} +rdbms_types::DbValue variant25 = std::move(*variant25_opt); +auto _e26 = std::move(variant25); +_result26.initialize(i, std::move(_e26)); +} +auto _e27 = std::move(_result26); +_result27.initialize(i, std::move(_e27)); +} + +result34_opt.emplace(std::expected(rdbms_types::RowSet{std::move(_result20), std::move(_result27), })); +} else { +std::optional variant33_opt; +switch ((int32_t) (*((uint8_t*) (ptr18 + sizeof(void*))))) { + case 0: { auto _len28 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant33_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len28)}}}; +} break; +case 1: { auto _len29 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len29)}}}; +} break; +case 2: { auto _len30 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len30)}}}; +} break; +case 3: { auto _len31 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len31)}}}; +} break; +case 4: { auto _len32 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant33_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len32)}}}; +} break; +} +rdbms_types::Error variant33 = std::move(*variant33_opt); + +result34_opt.emplace(std::unexpected{std::move(variant33)}); +} +std::expected result34 = std::move(*result34_opt); +auto result35 = std::move(result34); +return result35; +} +std::expected fermyon::spin2_0_0::mysql::Connection::Execute(std::string_view statement, std::span params) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec17 = params; + auto _ptr17 = (uint8_t*)(_vec17.data()); + auto _len17 = (size_t)(_vec17.size()); + for (size_t i = 0; i < _len17; ++i) { + auto _base = _ptr17 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec17[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int8_t*)(_base + 8)) = (int32_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((int8_t*)(_base + 8)) = (int32_t(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + *((int16_t*)(_base + 8)) = (int32_t(payload3)); + break; + } + case 3: { + auto& payload4 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + *((int32_t*)(_base + 8)) = (int32_t(payload4)); + break; + } + case 4: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(4)); + *((int64_t*)(_base + 8)) = (int64_t(payload5)); + break; + } + case 5: { + auto& payload6 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(5)); + *((int8_t*)(_base + 8)) = (int32_t(payload6)); + break; + } + case 6: { + auto& payload7 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(6)); + *((int16_t*)(_base + 8)) = (int32_t(payload7)); + break; + } + case 7: { + auto& payload8 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(7)); + *((int32_t*)(_base + 8)) = (int32_t(payload8)); + break; + } + case 8: { + auto& payload9 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(8)); + *((int64_t*)(_base + 8)) = (int64_t(payload9)); + break; + } + case 9: { + auto& payload10 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(9)); + *((float*)(_base + 8)) = (float(payload10)); + break; + } + case 10: { + auto& payload11 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(10)); + *((double*)(_base + 8)) = (double(payload11)); + break; + } + case 11: { + auto& payload12 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(11)); + auto&& _vec13 = payload12; + auto _ptr13 = (uint8_t*)(_vec13.data()); + auto _len13 = (size_t)(_vec13.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len13; + *((uint8_t**)(_base + 8)) = _ptr13; + break; + } + case 12: { + auto& payload14 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(12)); + auto&& _vec15 = payload14; + auto _ptr15 = (uint8_t*)(_vec15.data()); + auto _len15 = (size_t)(_vec15.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len15; + *((uint8_t**)(_base + 8)) = _ptr15; + break; + } + case 13: { + *((int8_t*)(_base + 0)) = (int32_t(13)); + break; + } + } + + } + uint8_t* ptr18 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FmysqlX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr17), std::move(_len17), std::move(ptr18)); + std::optional> result25_opt; + if ((int32_t) (*((uint8_t*) (ptr18 + 0)))==0) { + + result25_opt.emplace(std::expected()); + } else { + std::optional variant24_opt; + switch ((int32_t) (*((uint8_t*) (ptr18 + sizeof(void*))))) { + case 0: { auto _len19 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::ConnectionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len19)}}}; + } break; + case 1: { auto _len20 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::BadParameter{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len20)}}}; + } break; + case 2: { auto _len21 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + + variant24_opt = rdbms_types::Error{{rdbms_types::Error::QueryFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len21)}}}; +} break; +case 3: { auto _len22 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant24_opt = rdbms_types::Error{{rdbms_types::Error::ValueConversionFailed{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len22)}}}; +} break; +case 4: { auto _len23 = *((size_t*) (ptr18 + (3*sizeof(void*)))); + + +variant24_opt = rdbms_types::Error{{rdbms_types::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr18 + (2*sizeof(void*))))), _len23)}}}; +} break; +} +rdbms_types::Error variant24 = std::move(*variant24_opt); + +result25_opt.emplace(std::unexpected{std::move(variant24)}); +} +std::expected result25 = std::move(*result25_opt); +auto result26 = std::move(result25); +return result26; +} +fermyon::spin2_0_0::mysql::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +fermyon::spin2_0_0::sqlite::Connection::~Connection() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5Bresource_dropX5Dconnection(handle); + } +} +std::expected fermyon::spin2_0_0::sqlite::Connection::Open(std::string_view database) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = database; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5BstaticX5DconnectionX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = sqlite::Error{{sqlite::Error::NoSuchDatabase{}}}; + } break; + case 1: { + variant4_opt = sqlite::Error{{sqlite::Error::AccessDenied{}}}; + } break; + case 2: { + variant4_opt = sqlite::Error{{sqlite::Error::InvalidConnection{}}}; + } break; + case 3: { + variant4_opt = sqlite::Error{{sqlite::Error::DatabaseFull{}}}; + } break; + case 4: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = sqlite::Error{{sqlite::Error::Io{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + sqlite::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected fermyon::spin2_0_0::sqlite::Connection::Execute(std::string_view statement, std::span parameters) const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = statement; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec8 = parameters; + auto _ptr8 = (uint8_t*)(_vec8.data()); + auto _len8 = (size_t)(_vec8.size()); + for (size_t i = 0; i < _len8; ++i) { + auto _base = _ptr8 + i * (8+2*sizeof(void*)); + auto&& _iter_elem = _vec8[i]; + switch ((int32_t) (_iter_elem).variants.index()) { + case 0: { + auto& payload1 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(0)); + *((int64_t*)(_base + 8)) = (int64_t(payload1)); + break; + } + case 1: { + auto& payload2 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(1)); + *((double*)(_base + 8)) = (double(payload2)); + break; + } + case 2: { + auto& payload3 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(2)); + auto&& _vec4 = payload3; + auto _ptr4 = (uint8_t*)(_vec4.data()); + auto _len4 = (size_t)(_vec4.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len4; + *((uint8_t**)(_base + 8)) = _ptr4; + break; + } + case 3: { + auto& payload5 = std::get(_iter_elem.variants).value; + *((int8_t*)(_base + 0)) = (int32_t(3)); + auto&& _vec6 = payload5; + auto _ptr6 = (uint8_t*)(_vec6.data()); + auto _len6 = (size_t)(_vec6.size()); + *((size_t*)(_base + (8+1*sizeof(void*)))) = _len6; + *((uint8_t**)(_base + 8)) = _ptr6; + break; + } + case 4: { + *((int8_t*)(_base + 0)) = (int32_t(4)); + break; + } + } + + } + uint8_t* ptr9 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FsqliteX402X2E0X2E0X00X5BmethodX5DconnectionX2Eexecute((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr8), std::move(_len8), std::move(ptr9)); + std::optional> result19_opt; + if ((int32_t) (*((uint8_t*) (ptr9 + 0)))==0) { + auto _base11 = *((uint8_t**) (ptr9 + sizeof(void*))); + auto _len11 = *((size_t*) (ptr9 + (2*sizeof(void*)))); + auto _result11 = wit::vector::allocate(_len11); + for (unsigned i=0; i<_len11; ++i) { + auto _base = _base11 + i * (2*sizeof(void*)); + auto _len10 = *((size_t*) (_base + sizeof(void*))); + + auto _e11 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len10); + _result11.initialize(i, std::move(_e11)); + } + auto _base16 = *((uint8_t**) (ptr9 + (3*sizeof(void*)))); + auto _len16 = *((size_t*) (ptr9 + (4*sizeof(void*)))); + auto _result16 = wit::vector::allocate(_len16); + for (unsigned i=0; i<_len16; ++i) { + auto _base = _base16 + i * (2*sizeof(void*)); + auto _base15 = *((uint8_t**) (_base + 0)); + auto _len15 = *((size_t*) (_base + sizeof(void*))); + auto _result15 = wit::vector::allocate(_len15); + for (unsigned i=0; i<_len15; ++i) { + auto _base = _base15 + i * (8+2*sizeof(void*)); + std::optional variant14_opt; + switch ((int32_t) (*((uint8_t*) (_base + 0)))) { + case 0: { + variant14_opt = sqlite::Value{{sqlite::Value::Integer{(int64_t(*((int64_t*) (_base + 8))))}}}; + } break; + case 1: { + variant14_opt = sqlite::Value{{sqlite::Value::Real{(double(*((double*) (_base + 8))))}}}; + } break; + case 2: { auto _len12 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + + variant14_opt = sqlite::Value{{sqlite::Value::Text{wit::string((char const*)(*((uint8_t**) (_base + 8))), _len12)}}}; + } break; + case 3: { auto _len13 = *((size_t*) (_base + (8+1*sizeof(void*)))); + + variant14_opt = sqlite::Value{{sqlite::Value::Blob{wit::vector((uint8_t*)(*((uint8_t**) (_base + 8))), _len13)}}}; + } break; + case 4: { + variant14_opt = sqlite::Value{{sqlite::Value::Null{}}}; + } break; + } + sqlite::Value variant14 = std::move(*variant14_opt); + auto _e15 = std::move(variant14); + _result15.initialize(i, std::move(_e15)); + } + auto _e16 = sqlite::RowResult{std::move(_result15), }; + _result16.initialize(i, std::move(_e16)); +} + +result19_opt.emplace(std::expected(sqlite::QueryResult{std::move(_result11), std::move(_result16), })); +} else { +std::optional variant18_opt; +switch ((int32_t) (*((uint8_t*) (ptr9 + sizeof(void*))))) { + case 0: { + variant18_opt = sqlite::Error{{sqlite::Error::NoSuchDatabase{}}}; + } break; + case 1: { + variant18_opt = sqlite::Error{{sqlite::Error::AccessDenied{}}}; + } break; + case 2: { + variant18_opt = sqlite::Error{{sqlite::Error::InvalidConnection{}}}; + } break; + case 3: { + variant18_opt = sqlite::Error{{sqlite::Error::DatabaseFull{}}}; + } break; + case 4: { auto _len17 = *((size_t*) (ptr9 + (3*sizeof(void*)))); + + + variant18_opt = sqlite::Error{{sqlite::Error::Io{wit::string((char const*)(*((uint8_t**) (ptr9 + (2*sizeof(void*))))), _len17)}}}; +} break; +} +sqlite::Error variant18 = std::move(*variant18_opt); + +result19_opt.emplace(std::unexpected{std::move(variant18)}); +} +std::expected result19 = std::move(*result19_opt); +auto result20 = std::move(result19); +return result20; +} +fermyon::spin2_0_0::sqlite::Connection::Connection(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +fermyon::spin2_0_0::key_value::Store::~Store() +{ + if (handle>=0) { + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5Bresource_dropX5Dstore(handle); + } +} +std::expected fermyon::spin2_0_0::key_value::Store::Open(std::string_view label) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = label; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BstaticX5DstoreX2Eopen(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant4_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant4_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + key_value::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected>, fermyon::spin2_0_0::key_value::Error> fermyon::spin2_0_0::key_value::Store::Get(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eget((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional>, key_value::Error>> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + std::optional> option3; + if ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + option3.emplace(wit::vector((uint8_t*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)); + } + + result6_opt.emplace(std::expected>, key_value::Error>(std::move(option3))); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant5_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant5_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant5_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant5_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + key_value::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected>, key_value::Error> result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected fermyon::spin2_0_0::key_value::Store::Set(std::string_view key, std::span value) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = value; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eset((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant4_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant4_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant4_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant4_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + key_value::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected fermyon::spin2_0_0::key_value::Store::Delete(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Edelete((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected()); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant3_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant3_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant3_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant3_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)}}}; + } break; + } + key_value::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected fermyon::spin2_0_0::key_value::Store::Exists(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eexists((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected((bool((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*)))))))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant3_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant3_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant3_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant3_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)}}}; + } break; + } + key_value::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected, fermyon::spin2_0_0::key_value::Error> fermyon::spin2_0_0::key_value::Store::GetKeys() const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2Fkey_valueX402X2E0X2E0X00X5BmethodX5DstoreX2Eget_keys((*this).get_handle(), std::move(ptr0)); + std::optional, key_value::Error>> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _base2 = *((uint8_t**) (ptr0 + sizeof(void*))); + auto _len2 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + auto _result2 = wit::vector::allocate(_len2); + for (unsigned i=0; i<_len2; ++i) { + auto _base = _base2 + i * (2*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + + auto _e2 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len1); + _result2.initialize(i, std::move(_e2)); + } + + result5_opt.emplace(std::expected, key_value::Error>(std::move(_result2))); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { + variant4_opt = key_value::Error{{key_value::Error::StoreTableFull{}}}; + } break; + case 1: { + variant4_opt = key_value::Error{{key_value::Error::NoSuchStore{}}}; + } break; + case 2: { + variant4_opt = key_value::Error{{key_value::Error::AccessDenied{}}}; + } break; + case 3: { auto _len3 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant4_opt = key_value::Error{{key_value::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + key_value::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected, key_value::Error> result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +fermyon::spin2_0_0::key_value::Store::Store(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected fermyon::spin2_0_0::variables::Get(std::string_view name) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_fermyonX3AspinX2FvariablesX402X2E0X2E0X00get(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result8_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + auto _len2 = *((size_t*) (ptr1 + (2*sizeof(void*)))); + + + result8_opt.emplace(std::expected(wit::string((char const*)(*((uint8_t**) (ptr1 + sizeof(void*)))), _len2))); + } else { + std::optional variant7_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant7_opt = Error{{Error::InvalidName{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + case 1: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant7_opt = Error{{Error::Undefined{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + case 2: { auto _len5 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant7_opt = Error{{Error::Provider{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len5)}}}; +} break; +case 3: { auto _len6 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + +variant7_opt = Error{{Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len6)}}}; +} break; +} +Error variant7 = std::move(*variant7_opt); + +result8_opt.emplace(std::unexpected{std::move(variant7)}); +} +std::expected result8 = std::move(*result8_opt); +auto result9 = std::move(result8); +return result9; +} +wit::vector> wasi::cli0_2_0::environment::GetEnvironment() +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00get_environment(std::move(ptr0)); + auto _base4 = *((uint8_t**) (ptr0 + 0)); + auto _len4 = *((size_t*) (ptr0 + sizeof(void*))); + auto _result4 = wit::vector>::allocate(_len4); + for (unsigned i=0; i<_len4; ++i) { + auto _base = _base4 + i * (4*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + + auto _len2 = *((size_t*) (_base + (3*sizeof(void*)))); + + auto tuple3 = std::tuple(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len1), wit::string((char const*)(*((uint8_t**) (_base + (2*sizeof(void*))))), _len2)); + auto _e4 = std::move(tuple3); + _result4.initialize(i, std::move(_e4)); + } + auto result5 = std::move(_result4); + return result5; +} +wit::vector wasi::cli0_2_0::environment::GetArguments() +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00get_arguments(std::move(ptr0)); + auto _base2 = *((uint8_t**) (ptr0 + 0)); + auto _len2 = *((size_t*) (ptr0 + sizeof(void*))); + auto _result2 = wit::vector::allocate(_len2); + for (unsigned i=0; i<_len2; ++i) { + auto _base = _base2 + i * (2*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + + auto _e2 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len1); + _result2.initialize(i, std::move(_e2)); + } + auto result3 = std::move(_result2); + return result3; +} +std::optional wasi::cli0_2_0::environment::InitialCwd() +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2FenvironmentX400X2E2X2E0X00initial_cwd(std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + + + option2.emplace(wit::string((char const*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1)); + } + auto result3 = std::move(option2); + return result3; +} +void wasi::cli0_2_0::exit::Exit(std::expected status) +{ + int32_t result2; + if ((status).has_value()) { + + result2 = (int32_t(0)); + } else { + + result2 = (int32_t(1)); + } + __wasm_import_wasiX3AcliX2FexitX400X2E2X2E0X00exit(std::move(result2)); +} +wasi::io0_2_0::streams::InputStream wasi::cli0_2_0::stdin_::GetStdin() +{ + auto ret = __wasm_import_wasiX3AcliX2FstdinX400X2E2X2E0X00get_stdin(); + return wit::ResourceImportBase{ret}; +} +wasi::io0_2_0::streams::OutputStream wasi::cli0_2_0::stdout_::GetStdout() +{ + auto ret = __wasm_import_wasiX3AcliX2FstdoutX400X2E2X2E0X00get_stdout(); + return wit::ResourceImportBase{ret}; +} +wasi::io0_2_0::streams::OutputStream wasi::cli0_2_0::stderr_::GetStderr() +{ + auto ret = __wasm_import_wasiX3AcliX2FstderrX400X2E2X2E0X00get_stderr(); + return wit::ResourceImportBase{ret}; +} +wasi::cli0_2_0::terminal_input::TerminalInput::~TerminalInput() +{ + if (handle>=0) { + __wasm_import_wasiX3AcliX2Fterminal_inputX400X2E2X2E0X00X5Bresource_dropX5Dterminal_input(handle); + } +} +wasi::cli0_2_0::terminal_input::TerminalInput::TerminalInput(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::cli0_2_0::terminal_output::TerminalOutput::~TerminalOutput() +{ + if (handle>=0) { + __wasm_import_wasiX3AcliX2Fterminal_outputX400X2E2X2E0X00X5Bresource_dropX5Dterminal_output(handle); + } +} +wasi::cli0_2_0::terminal_output::TerminalOutput::TerminalOutput(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::optional wasi::cli0_2_0::terminal_stdin::GetTerminalStdin() +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2Fterminal_stdinX400X2E2X2E0X00get_terminal_stdin(std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + option2.emplace(wit::ResourceImportBase{l1}); + } + auto result3 = std::move(option2); + return result3; +} +std::optional wasi::cli0_2_0::terminal_stdout::GetTerminalStdout() +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2Fterminal_stdoutX400X2E2X2E0X00get_terminal_stdout(std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + option2.emplace(wit::ResourceImportBase{l1}); + } + auto result3 = std::move(option2); + return result3; +} +std::optional wasi::cli0_2_0::terminal_stderr::GetTerminalStderr() +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AcliX2Fterminal_stderrX400X2E2X2E0X00get_terminal_stderr(std::move(ptr0)); + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + option2.emplace(wit::ResourceImportBase{l1}); + } + auto result3 = std::move(option2); + return result3; +} +wasi::clocks0_2_0::wall_clock::Datetime wasi::clocks0_2_0::wall_clock::Now() +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AclocksX2Fwall_clockX400X2E2X2E0X00now(std::move(ptr0)); + int32_t l1 = *((int32_t const*)(ptr0 + 8)); + auto result2 = Datetime{(uint64_t(*((int64_t*) (ptr0 + 0)))), (uint32_t(l1)), }; + return result2; +} +wasi::clocks0_2_0::wall_clock::Datetime wasi::clocks0_2_0::wall_clock::Resolution() +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AclocksX2Fwall_clockX400X2E2X2E0X00resolution(std::move(ptr0)); + int32_t l1 = *((int32_t const*)(ptr0 + 8)); + auto result2 = Datetime{(uint64_t(*((int64_t*) (ptr0 + 0)))), (uint32_t(l1)), }; + return result2; +} +wasi::filesystem0_2_0::types::DirectoryEntryStream::~DirectoryEntryStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Ddirectory_entry_stream(handle); + } +} +std::expected, wasi::filesystem0_2_0::types::ErrorCode> wasi::filesystem0_2_0::types::DirectoryEntryStream::ReadDirectoryEntry() const +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5Ddirectory_entry_streamX2Eread_directory_entry((*this).get_handle(), std::move(ptr0)); + std::optional, types::ErrorCode>> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + auto _len1 = *((size_t*) (ptr0 + (4*sizeof(void*)))); + + + option2.emplace(types::DirectoryEntry{(types::DescriptorType)(int32_t) (*((uint8_t*) (ptr0 + (2*sizeof(void*))))), wit::string((char const*)(*((uint8_t**) (ptr0 + (3*sizeof(void*))))), _len1), }); + } + + result3_opt.emplace(std::expected, types::ErrorCode>(std::move(option2))); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))}); + } + std::expected, types::ErrorCode> result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +wasi::filesystem0_2_0::types::DirectoryEntryStream::DirectoryEntryStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::filesystem0_2_0::types::Descriptor::~Descriptor() +{ + if (handle>=0) { + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5Bresource_dropX5Ddescriptor(handle); + } +} +std::expected wasi::filesystem0_2_0::types::Descriptor::ReadViaStream(uint64_t offset) const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread_via_stream((*this).get_handle(), (int64_t(offset)), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::WriteViaStream(uint64_t offset) const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ewrite_via_stream((*this).get_handle(), (int64_t(offset)), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::AppendViaStream() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eappend_via_stream((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::Advise(uint64_t offset, uint64_t length, types::Advice advice) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eadvise((*this).get_handle(), (int64_t(offset)), (int64_t(length)), int32_t(advice), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::SyncData() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esync_data((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::GetFlags() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eget_flags((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected(((types::DescriptorFlags)(int32_t) (*((uint8_t*) (ptr0 + 1)))))); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::GetType() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eget_type((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((types::DescriptorType)(int32_t) (*((uint8_t*) (ptr0 + 1))))); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::SetSize(uint64_t size) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_size((*this).get_handle(), (int64_t(size)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::SetTimes(types::NewTimestamp data_access_timestamp, types::NewTimestamp data_modification_timestamp) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + int32_t variant3; + int64_t variant4; + int32_t variant5; + switch ((int32_t) (data_access_timestamp).variants.index()) { + case 0: { + variant3 = (int32_t(0)); + variant4 = int64_t(0); + variant5 = int32_t(0); + break; + } + case 1: { + variant3 = (int32_t(1)); + variant4 = int64_t(0); + variant5 = int32_t(0); + break; + } + case 2: { + auto& payload2 = std::get(data_access_timestamp.variants).value; + variant3 = (int32_t(2)); + variant4 = (int64_t((payload2).seconds)); + variant5 = (int32_t((payload2).nanoseconds)); + break; + } + } + int32_t variant9; + int64_t variant10; + int32_t variant11; + switch ((int32_t) (data_modification_timestamp).variants.index()) { + case 0: { + variant9 = (int32_t(0)); + variant10 = int64_t(0); + variant11 = int32_t(0); + break; + } + case 1: { + variant9 = (int32_t(1)); + variant10 = int64_t(0); + variant11 = int32_t(0); + break; + } + case 2: { + auto& payload8 = std::get(data_modification_timestamp.variants).value; + variant9 = (int32_t(2)); + variant10 = (int64_t((payload8).seconds)); + variant11 = (int32_t((payload8).nanoseconds)); + break; + } + } + uint8_t* ptr12 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_times((*this).get_handle(), std::move(variant3), std::move(variant4), std::move(variant5), std::move(variant9), std::move(variant10), std::move(variant11), std::move(ptr12)); + std::optional> result13_opt; + if ((int32_t) (*((uint8_t*) (ptr12 + 0)))==0) { + + result13_opt.emplace(std::expected()); + } else { + + result13_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr12 + 1)))}); + } + std::expected result13 = std::move(*result13_opt); + auto result14 = std::move(result13); + return result14; +} +std::expected, bool>, wasi::filesystem0_2_0::types::ErrorCode> wasi::filesystem0_2_0::types::Descriptor::Read(uint64_t length, uint64_t offset) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread((*this).get_handle(), (int64_t(length)), (int64_t(offset)), std::move(ptr0)); + std::optional, bool>, types::ErrorCode>> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _len1 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + auto tuple2 = std::tuple, bool>(wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + sizeof(void*)))), _len1), (bool((int32_t) (*((uint8_t*) (ptr0 + (3*sizeof(void*)))))))); + + result3_opt.emplace(std::expected, bool>, types::ErrorCode>(std::move(tuple2))); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))}); + } + std::expected, bool>, types::ErrorCode> result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::Write(std::span buffer, uint64_t offset) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = buffer; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ewrite((*this).get_handle(), std::move(_ptr0), std::move(_len0), (int64_t(offset)), std::move(ptr1)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result2_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr1 + 8)))))); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 8)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::ReadDirectory() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eread_directory((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::Sync() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esync((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::CreateDirectoryAt(std::string_view path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ecreate_directory_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result2_opt.emplace(std::expected()); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 1)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::Stat() const +{ + uint64_t ret_area[(104+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Estat((*this).get_handle(), std::move(ptr0)); + std::optional> result7_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional option2; + if ((int32_t) (*((uint8_t*) (ptr0 + 32)))) { + int32_t l1 = *((int32_t const*)(ptr0 + 48)); + + option2.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr0 + 40)))), (uint32_t(l1)), }); + } + std::optional option4; + if ((int32_t) (*((uint8_t*) (ptr0 + 56)))) { + int32_t l3 = *((int32_t const*)(ptr0 + 72)); + + option4.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr0 + 64)))), (uint32_t(l3)), }); + } + std::optional option6; + if ((int32_t) (*((uint8_t*) (ptr0 + 80)))) { + int32_t l5 = *((int32_t const*)(ptr0 + 96)); + + option6.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr0 + 88)))), (uint32_t(l5)), }); + } + + result7_opt.emplace(std::expected(types::DescriptorStat{(types::DescriptorType)(int32_t) (*((uint8_t*) (ptr0 + 8))), (uint64_t(*((int64_t*) (ptr0 + 16)))), (uint64_t(*((int64_t*) (ptr0 + 24)))), std::move(option2), std::move(option4), std::move(option6), })); + } else { + + result7_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result7 = std::move(*result7_opt); + auto result8 = std::move(result7); + return result8; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::StatAt(types::PathFlags path_flags, std::string_view path) const +{ + uint64_t ret_area[(104+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Estat_at((*this).get_handle(), ((int32_t)path_flags), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result8_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + std::optional option3; + if ((int32_t) (*((uint8_t*) (ptr1 + 32)))) { + int32_t l2 = *((int32_t const*)(ptr1 + 48)); + + option3.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr1 + 40)))), (uint32_t(l2)), }); + } + std::optional option5; + if ((int32_t) (*((uint8_t*) (ptr1 + 56)))) { + int32_t l4 = *((int32_t const*)(ptr1 + 72)); + + option5.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr1 + 64)))), (uint32_t(l4)), }); + } + std::optional option7; + if ((int32_t) (*((uint8_t*) (ptr1 + 80)))) { + int32_t l6 = *((int32_t const*)(ptr1 + 96)); + + option7.emplace(clocks0_2_0::wall_clock::Datetime{(uint64_t(*((int64_t*) (ptr1 + 88)))), (uint32_t(l6)), }); + } + + result8_opt.emplace(std::expected(types::DescriptorStat{(types::DescriptorType)(int32_t) (*((uint8_t*) (ptr1 + 8))), (uint64_t(*((int64_t*) (ptr1 + 16)))), (uint64_t(*((int64_t*) (ptr1 + 24)))), std::move(option3), std::move(option5), std::move(option7), })); + } else { + + result8_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 8)))}); + } + std::expected result8 = std::move(*result8_opt); + auto result9 = std::move(result8); + return result9; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::SetTimesAt(types::PathFlags path_flags, std::string_view path, types::NewTimestamp data_access_timestamp, types::NewTimestamp data_modification_timestamp) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + int32_t variant4; + int64_t variant5; + int32_t variant6; + switch ((int32_t) (data_access_timestamp).variants.index()) { + case 0: { + variant4 = (int32_t(0)); + variant5 = int64_t(0); + variant6 = int32_t(0); + break; + } + case 1: { + variant4 = (int32_t(1)); + variant5 = int64_t(0); + variant6 = int32_t(0); + break; + } + case 2: { + auto& payload3 = std::get(data_access_timestamp.variants).value; + variant4 = (int32_t(2)); + variant5 = (int64_t((payload3).seconds)); + variant6 = (int32_t((payload3).nanoseconds)); + break; + } + } + int32_t variant10; + int64_t variant11; + int32_t variant12; + switch ((int32_t) (data_modification_timestamp).variants.index()) { + case 0: { + variant10 = (int32_t(0)); + variant11 = int64_t(0); + variant12 = int32_t(0); + break; + } + case 1: { + variant10 = (int32_t(1)); + variant11 = int64_t(0); + variant12 = int32_t(0); + break; + } + case 2: { + auto& payload9 = std::get(data_modification_timestamp.variants).value; + variant10 = (int32_t(2)); + variant11 = (int64_t((payload9).seconds)); + variant12 = (int32_t((payload9).nanoseconds)); + break; + } + } + uint8_t* ptr13 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eset_times_at((*this).get_handle(), ((int32_t)path_flags), std::move(_ptr0), std::move(_len0), std::move(variant4), std::move(variant5), std::move(variant6), std::move(variant10), std::move(variant11), std::move(variant12), std::move(ptr13)); + std::optional> result14_opt; + if ((int32_t) (*((uint8_t*) (ptr13 + 0)))==0) { + + result14_opt.emplace(std::expected()); + } else { + + result14_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr13 + 1)))}); + } + std::expected result14 = std::move(*result14_opt); + auto result15 = std::move(result14); + return result15; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::LinkAt(types::PathFlags old_path_flags, std::string_view old_path, std::reference_wrapper new_descriptor, std::string_view new_path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = old_path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = new_path; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Elink_at((*this).get_handle(), ((int32_t)old_path_flags), std::move(_ptr0), std::move(_len0), new_descriptor.get().get_handle(), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr2 + 1)))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::OpenAt(types::PathFlags path_flags, std::string_view path, types::OpenFlags open_flags, types::DescriptorFlags flags) const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eopen_at((*this).get_handle(), ((int32_t)path_flags), std::move(_ptr0), std::move(_len0), ((int32_t)open_flags), ((int32_t)flags), std::move(ptr1)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + 4)); + + result3_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 4)))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::ReadlinkAt(std::string_view path) const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Ereadlink_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + auto _len2 = *((size_t*) (ptr1 + (2*sizeof(void*)))); + + + result3_opt.emplace(std::expected(wit::string((char const*)(*((uint8_t**) (ptr1 + sizeof(void*)))), _len2))); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::RemoveDirectoryAt(std::string_view path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eremove_directory_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result2_opt.emplace(std::expected()); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 1)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::RenameAt(std::string_view old_path, std::reference_wrapper new_descriptor, std::string_view new_path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = old_path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = new_path; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Erename_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), new_descriptor.get().get_handle(), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr2 + 1)))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::SymlinkAt(std::string_view old_path, std::string_view new_path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = old_path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = new_path; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Esymlink_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result3_opt.emplace(std::expected()); + } else { + + result3_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr2 + 1)))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::UnlinkFileAt(std::string_view path) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eunlink_file_at((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result2_opt.emplace(std::expected()); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 1)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +bool wasi::filesystem0_2_0::types::Descriptor::IsSameObject(std::reference_wrapper other) const +{ + auto ret = __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Eis_same_object((*this).get_handle(), other.get().get_handle()); + return (bool(ret)); +} +std::expected wasi::filesystem0_2_0::types::Descriptor::MetadataHash() const +{ + uint64_t ret_area[(24+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Emetadata_hash((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected(types::MetadataHashValue{(uint64_t(*((int64_t*) (ptr0 + 8)))), (uint64_t(*((int64_t*) (ptr0 + 16)))), })); + } else { + + result1_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::filesystem0_2_0::types::Descriptor::MetadataHashAt(types::PathFlags path_flags, std::string_view path) const +{ + uint64_t ret_area[(24+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = path; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00X5BmethodX5DdescriptorX2Emetadata_hash_at((*this).get_handle(), ((int32_t)path_flags), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result2_opt.emplace(std::expected(types::MetadataHashValue{(uint64_t(*((int64_t*) (ptr1 + 8)))), (uint64_t(*((int64_t*) (ptr1 + 16)))), })); + } else { + + result2_opt.emplace(std::unexpected{(types::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 8)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::filesystem0_2_0::types::Descriptor::Descriptor(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::optional wasi::filesystem0_2_0::types::FilesystemErrorCode(std::reference_wrapper err_) +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FtypesX400X2E2X2E0X00filesystem_error_code(err_.get().get_handle(), std::move(ptr0)); + std::optional option1; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))) { + + option1.emplace((ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))); + } + auto result2 = std::move(option1); + return result2; +} +wit::vector> wasi::filesystem0_2_0::preopens::GetDirectories() +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AfilesystemX2FpreopensX400X2E2X2E0X00get_directories(std::move(ptr0)); + auto _base4 = *((uint8_t**) (ptr0 + 0)); + auto _len4 = *((size_t*) (ptr0 + sizeof(void*))); + auto _result4 = wit::vector>::allocate(_len4); + for (unsigned i=0; i<_len4; ++i) { + auto _base = _base4 + i * (3*sizeof(void*)); + int32_t l1 = *((int32_t const*)(_base + 0)); + auto _len2 = *((size_t*) (_base + (2*sizeof(void*)))); + + auto tuple3 = std::tuple(wit::ResourceImportBase{l1}, wit::string((char const*)(*((uint8_t**) (_base + sizeof(void*)))), _len2)); + auto _e4 = std::move(tuple3); + _result4.initialize(i, std::move(_e4)); + } + auto result5 = std::move(_result4); + return result5; +} +wasi::sockets0_2_0::network::Network::~Network() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2FnetworkX400X2E2X2E0X00X5Bresource_dropX5Dnetwork(handle); + } +} +wasi::sockets0_2_0::network::Network::Network(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::sockets0_2_0::network::Network wasi::sockets0_2_0::instance_network::InstanceNetwork() +{ + auto ret = __wasm_import_wasiX3AsocketsX2Finstance_networkX400X2E2X2E0X00instance_network(); + return wit::ResourceImportBase{ret}; +} +wasi::sockets0_2_0::udp::IncomingDatagramStream::~IncomingDatagramStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Dincoming_datagram_stream(handle); + } +} +std::expected, wasi::sockets0_2_0::network::ErrorCode> wasi::sockets0_2_0::udp::IncomingDatagramStream::Receive(uint64_t max_results) const +{ + uintptr_t ret_area[((3*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dincoming_datagram_streamX2Ereceive((*this).get_handle(), (int64_t(max_results)), std::move(ptr0)); + std::optional, network::ErrorCode>> result8_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + auto _base7 = *((uint8_t**) (ptr0 + sizeof(void*))); + auto _len7 = *((size_t*) (ptr0 + (2*sizeof(void*)))); + auto _result7 = wit::vector::allocate(_len7); + for (unsigned i=0; i<_len7; ++i) { + auto _base = _base7 + i * (32+2*sizeof(void*)); + auto _len1 = *((size_t*) (_base + sizeof(void*))); + std::optional variant6_opt; + switch ((int32_t) (*((uint8_t*) (_base + (2*sizeof(void*)))))) { + case 0: { auto tuple2 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (_base + (6+2*sizeof(void*))))))), (uint8_t((int32_t) (*((uint8_t*) (_base + (7+2*sizeof(void*))))))), (uint8_t((int32_t) (*((uint8_t*) (_base + (8+2*sizeof(void*))))))), (uint8_t((int32_t) (*((uint8_t*) (_base + (9+2*sizeof(void*)))))))); + + variant6_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv4{network::Ipv4SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (_base + (4+2*sizeof(void*))))))), std::move(tuple2), }}}}; + } break; + case 1: { int32_t l3 = *((int32_t const*)(_base + (8+2*sizeof(void*)))); + auto tuple4 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (_base + (12+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (14+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (16+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (18+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (20+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (22+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (24+2*sizeof(void*))))))), (uint16_t((int32_t) (*((uint16_t*) (_base + (26+2*sizeof(void*)))))))); + int32_t l5 = *((int32_t const*)(_base + (28+2*sizeof(void*)))); + + variant6_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv6{network::Ipv6SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (_base + (4+2*sizeof(void*))))))), (uint32_t(l3)), std::move(tuple4), (uint32_t(l5)), }}}}; + } break; + } + network::IpSocketAddress variant6 = std::move(*variant6_opt); + auto _e7 = udp::IncomingDatagram{wit::vector((uint8_t*)(*((uint8_t**) (_base + 0))), _len1), std::move(variant6), }; + _result7.initialize(i, std::move(_e7)); +} + +result8_opt.emplace(std::expected, network::ErrorCode>(std::move(_result7))); +} else { + +result8_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))}); +} +std::expected, network::ErrorCode> result8 = std::move(*result8_opt); +auto result9 = std::move(result8); +return result9; +} +wasi::io0_2_0::poll::Pollable wasi::sockets0_2_0::udp::IncomingDatagramStream::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dincoming_datagram_streamX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::sockets0_2_0::udp::IncomingDatagramStream::IncomingDatagramStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::sockets0_2_0::udp::OutgoingDatagramStream::~OutgoingDatagramStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Doutgoing_datagram_stream(handle); + } +} +std::expected wasi::sockets0_2_0::udp::OutgoingDatagramStream::CheckSend() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Echeck_send((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::OutgoingDatagramStream::Send(std::span datagrams) const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec5 = datagrams; + auto _ptr5 = (uint8_t*)(_vec5.data()); + auto _len5 = (size_t)(_vec5.size()); + for (size_t i = 0; i < _len5; ++i) { + auto _base = _ptr5 + i * (32+3*sizeof(void*)); + auto&& _iter_elem = _vec5[i]; + auto&& _vec0 = (_iter_elem).data; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + if (((_iter_elem).remote_address).has_value()) { + network::IpSocketAddress payload2 = (std::move((_iter_elem).remote_address)).value(); + *((int8_t*)(_base + (2*sizeof(void*)))) = (int32_t(1)); + switch ((int32_t) (payload2).variants.index()) { + case 0: { + auto& payload3 = std::get(payload2.variants).value; + *((int8_t*)(_base + (4+2*sizeof(void*)))) = (int32_t(0)); + *((int16_t*)(_base + (8+2*sizeof(void*)))) = (int32_t((payload3).port)); + *((int8_t*)(_base + (10+2*sizeof(void*)))) = (int32_t(std::get<0>((payload3).address))); + *((int8_t*)(_base + (11+2*sizeof(void*)))) = (int32_t(std::get<1>((payload3).address))); + *((int8_t*)(_base + (12+2*sizeof(void*)))) = (int32_t(std::get<2>((payload3).address))); + *((int8_t*)(_base + (13+2*sizeof(void*)))) = (int32_t(std::get<3>((payload3).address))); + break; + } + case 1: { + auto& payload4 = std::get(payload2.variants).value; + *((int8_t*)(_base + (4+2*sizeof(void*)))) = (int32_t(1)); + *((int16_t*)(_base + (8+2*sizeof(void*)))) = (int32_t((payload4).port)); + *((int32_t*)(_base + (12+2*sizeof(void*)))) = (int32_t((payload4).flow_info)); + *((int16_t*)(_base + (16+2*sizeof(void*)))) = (int32_t(std::get<0>((payload4).address))); + *((int16_t*)(_base + (18+2*sizeof(void*)))) = (int32_t(std::get<1>((payload4).address))); + *((int16_t*)(_base + (20+2*sizeof(void*)))) = (int32_t(std::get<2>((payload4).address))); + *((int16_t*)(_base + (22+2*sizeof(void*)))) = (int32_t(std::get<3>((payload4).address))); + *((int16_t*)(_base + (24+2*sizeof(void*)))) = (int32_t(std::get<4>((payload4).address))); + *((int16_t*)(_base + (26+2*sizeof(void*)))) = (int32_t(std::get<5>((payload4).address))); + *((int16_t*)(_base + (28+2*sizeof(void*)))) = (int32_t(std::get<6>((payload4).address))); + *((int16_t*)(_base + (30+2*sizeof(void*)))) = (int32_t(std::get<7>((payload4).address))); + *((int32_t*)(_base + (32+2*sizeof(void*)))) = (int32_t((payload4).scope_id)); + break; + } + } + } else { + *((int8_t*)(_base + (2*sizeof(void*)))) = (int32_t(0)); + } + + } + uint8_t* ptr6 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Esend((*this).get_handle(), std::move(_ptr5), std::move(_len5), std::move(ptr6)); + std::optional> result7_opt; + if ((int32_t) (*((uint8_t*) (ptr6 + 0)))==0) { + + result7_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr6 + 8)))))); + } else { + + result7_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr6 + 8)))}); + } + std::expected result7 = std::move(*result7_opt); + auto result8 = std::move(result7); + return result8; +} +wasi::io0_2_0::poll::Pollable wasi::sockets0_2_0::udp::OutgoingDatagramStream::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Doutgoing_datagram_streamX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::sockets0_2_0::udp::OutgoingDatagramStream::OutgoingDatagramStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +wasi::sockets0_2_0::udp::UdpSocket::~UdpSocket() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5Bresource_dropX5Dudp_socket(handle); + } +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::StartBind(std::reference_wrapper network, network::IpSocketAddress local_address) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + int32_t variant12; + int32_t variant13; + switch ((int32_t) (local_address).variants.index()) { + case 0: { + auto& payload0 = std::get(local_address.variants).value; + variant2 = (int32_t(0)); + variant3 = (int32_t((payload0).port)); + variant4 = (int32_t(std::get<0>((payload0).address))); + variant5 = (int32_t(std::get<1>((payload0).address))); + variant6 = (int32_t(std::get<2>((payload0).address))); + variant7 = (int32_t(std::get<3>((payload0).address))); + variant8 = int32_t(0); + variant9 = int32_t(0); + variant10 = int32_t(0); + variant11 = int32_t(0); + variant12 = int32_t(0); + variant13 = int32_t(0); + break; + } + case 1: { + auto& payload1 = std::get(local_address.variants).value; + variant2 = (int32_t(1)); + variant3 = (int32_t((payload1).port)); + variant4 = (int32_t((payload1).flow_info)); + variant5 = (int32_t(std::get<0>((payload1).address))); + variant6 = (int32_t(std::get<1>((payload1).address))); + variant7 = (int32_t(std::get<2>((payload1).address))); + variant8 = (int32_t(std::get<3>((payload1).address))); + variant9 = (int32_t(std::get<4>((payload1).address))); + variant10 = (int32_t(std::get<5>((payload1).address))); + variant11 = (int32_t(std::get<6>((payload1).address))); + variant12 = (int32_t(std::get<7>((payload1).address))); + variant13 = (int32_t((payload1).scope_id)); + break; + } + } + uint8_t* ptr14 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Estart_bind((*this).get_handle(), network.get().get_handle(), std::move(variant2), std::move(variant3), std::move(variant4), std::move(variant5), std::move(variant6), std::move(variant7), std::move(variant8), std::move(variant9), std::move(variant10), std::move(variant11), std::move(variant12), std::move(variant13), std::move(ptr14)); + std::optional> result15_opt; + if ((int32_t) (*((uint8_t*) (ptr14 + 0)))==0) { + + result15_opt.emplace(std::expected()); + } else { + + result15_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr14 + 1)))}); + } + std::expected result15 = std::move(*result15_opt); + auto result16 = std::move(result15); + return result16; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::FinishBind() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Efinish_bind((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected, wasi::sockets0_2_0::network::ErrorCode> wasi::sockets0_2_0::udp::UdpSocket::Stream(std::optional remote_address) const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + int32_t option16; + int32_t option17; + int32_t option18; + int32_t option19; + int32_t option20; + int32_t option21; + int32_t option22; + int32_t option23; + int32_t option24; + int32_t option25; + int32_t option26; + int32_t option27; + int32_t option28; + if ((remote_address).has_value()) { + network::IpSocketAddress payload1 = (std::move(remote_address)).value(); + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + int32_t variant12; + int32_t variant13; + int32_t variant14; + int32_t variant15; + switch ((int32_t) (payload1).variants.index()) { + case 0: { + auto& payload2 = std::get(payload1.variants).value; + variant4 = (int32_t(0)); + variant5 = (int32_t((payload2).port)); + variant6 = (int32_t(std::get<0>((payload2).address))); + variant7 = (int32_t(std::get<1>((payload2).address))); + variant8 = (int32_t(std::get<2>((payload2).address))); + variant9 = (int32_t(std::get<3>((payload2).address))); + variant10 = int32_t(0); + variant11 = int32_t(0); + variant12 = int32_t(0); + variant13 = int32_t(0); + variant14 = int32_t(0); + variant15 = int32_t(0); + break; + } + case 1: { + auto& payload3 = std::get(payload1.variants).value; + variant4 = (int32_t(1)); + variant5 = (int32_t((payload3).port)); + variant6 = (int32_t((payload3).flow_info)); + variant7 = (int32_t(std::get<0>((payload3).address))); + variant8 = (int32_t(std::get<1>((payload3).address))); + variant9 = (int32_t(std::get<2>((payload3).address))); + variant10 = (int32_t(std::get<3>((payload3).address))); + variant11 = (int32_t(std::get<4>((payload3).address))); + variant12 = (int32_t(std::get<5>((payload3).address))); + variant13 = (int32_t(std::get<6>((payload3).address))); + variant14 = (int32_t(std::get<7>((payload3).address))); + variant15 = (int32_t((payload3).scope_id)); + break; + } + } + option16 = (int32_t(1)); + option17 = variant4; + option18 = variant5; + option19 = variant6; + option20 = variant7; + option21 = variant8; + option22 = variant9; + option23 = variant10; + option24 = variant11; + option25 = variant12; + option26 = variant13; + option27 = variant14; + option28 = variant15; + } else { + option16 = (int32_t(0)); + option17 = int32_t(0); + option18 = int32_t(0); + option19 = int32_t(0); + option20 = int32_t(0); + option21 = int32_t(0); + option22 = int32_t(0); + option23 = int32_t(0); + option24 = int32_t(0); + option25 = int32_t(0); + option26 = int32_t(0); + option27 = int32_t(0); + option28 = int32_t(0); + } + uint8_t* ptr29 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Estream((*this).get_handle(), std::move(option16), std::move(option17), std::move(option18), std::move(option19), std::move(option20), std::move(option21), std::move(option22), std::move(option23), std::move(option24), std::move(option25), std::move(option26), std::move(option27), std::move(option28), std::move(ptr29)); + std::optional, network::ErrorCode>> result33_opt; + if ((int32_t) (*((uint8_t*) (ptr29 + 0)))==0) { + int32_t l30 = *((int32_t const*)(ptr29 + 4)); + int32_t l31 = *((int32_t const*)(ptr29 + 8)); + auto tuple32 = std::tuple(wit::ResourceImportBase{l30}, wit::ResourceImportBase{l31}); + + result33_opt.emplace(std::expected, network::ErrorCode>(std::move(tuple32))); + } else { + + result33_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr29 + 4)))}); + } + std::expected, network::ErrorCode> result33 = std::move(*result33_opt); + auto result34 = std::move(result33); + return result34; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::LocalAddress() const +{ + uint32_t ret_area[(36+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Elocal_address((*this).get_handle(), std::move(ptr0)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { auto tuple1 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 10))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 11))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 12))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 13)))))); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv4{network::Ipv4SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), std::move(tuple1), }}}}; + } break; + case 1: { int32_t l2 = *((int32_t const*)(ptr0 + 12)); + auto tuple3 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (ptr0 + 16))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 18))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 20))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 22))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 24))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 26))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 28))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 30)))))); + int32_t l4 = *((int32_t const*)(ptr0 + 32)); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv6{network::Ipv6SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), (uint32_t(l2)), std::move(tuple3), (uint32_t(l4)), }}}}; + } break; +} +network::IpSocketAddress variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::expected(std::move(variant5))); +} else { + +result6_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::RemoteAddress() const +{ + uint32_t ret_area[(36+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eremote_address((*this).get_handle(), std::move(ptr0)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { auto tuple1 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 10))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 11))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 12))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 13)))))); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv4{network::Ipv4SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), std::move(tuple1), }}}}; + } break; + case 1: { int32_t l2 = *((int32_t const*)(ptr0 + 12)); + auto tuple3 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (ptr0 + 16))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 18))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 20))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 22))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 24))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 26))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 28))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 30)))))); + int32_t l4 = *((int32_t const*)(ptr0 + 32)); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv6{network::Ipv6SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), (uint32_t(l2)), std::move(tuple3), (uint32_t(l4)), }}}}; + } break; +} +network::IpSocketAddress variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::expected(std::move(variant5))); +} else { + +result6_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +wasi::sockets0_2_0::network::IpAddressFamily wasi::sockets0_2_0::udp::UdpSocket::AddressFamily() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eaddress_family((*this).get_handle()); + return (network::IpAddressFamily)ret; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::UnicastHopLimit() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eunicast_hop_limit((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 1))))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::SetUnicastHopLimit(uint8_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_unicast_hop_limit((*this).get_handle(), (int32_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::ReceiveBufferSize() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Ereceive_buffer_size((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::SetReceiveBufferSize(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_receive_buffer_size((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::SendBufferSize() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Esend_buffer_size((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::udp::UdpSocket::SetSendBufferSize(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Eset_send_buffer_size((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +wasi::io0_2_0::poll::Pollable wasi::sockets0_2_0::udp::UdpSocket::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FudpX400X2E2X2E0X00X5BmethodX5Dudp_socketX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::sockets0_2_0::udp::UdpSocket::UdpSocket(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected wasi::sockets0_2_0::udp_create_socket::CreateUdpSocket(network::IpAddressFamily address_family) +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2Fudp_create_socketX400X2E2X2E0X00create_udp_socket(int32_t(address_family), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::sockets0_2_0::tcp::TcpSocket::~TcpSocket() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5Bresource_dropX5Dtcp_socket(handle); + } +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::StartBind(std::reference_wrapper network, network::IpSocketAddress local_address) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + int32_t variant12; + int32_t variant13; + switch ((int32_t) (local_address).variants.index()) { + case 0: { + auto& payload0 = std::get(local_address.variants).value; + variant2 = (int32_t(0)); + variant3 = (int32_t((payload0).port)); + variant4 = (int32_t(std::get<0>((payload0).address))); + variant5 = (int32_t(std::get<1>((payload0).address))); + variant6 = (int32_t(std::get<2>((payload0).address))); + variant7 = (int32_t(std::get<3>((payload0).address))); + variant8 = int32_t(0); + variant9 = int32_t(0); + variant10 = int32_t(0); + variant11 = int32_t(0); + variant12 = int32_t(0); + variant13 = int32_t(0); + break; + } + case 1: { + auto& payload1 = std::get(local_address.variants).value; + variant2 = (int32_t(1)); + variant3 = (int32_t((payload1).port)); + variant4 = (int32_t((payload1).flow_info)); + variant5 = (int32_t(std::get<0>((payload1).address))); + variant6 = (int32_t(std::get<1>((payload1).address))); + variant7 = (int32_t(std::get<2>((payload1).address))); + variant8 = (int32_t(std::get<3>((payload1).address))); + variant9 = (int32_t(std::get<4>((payload1).address))); + variant10 = (int32_t(std::get<5>((payload1).address))); + variant11 = (int32_t(std::get<6>((payload1).address))); + variant12 = (int32_t(std::get<7>((payload1).address))); + variant13 = (int32_t((payload1).scope_id)); + break; + } + } + uint8_t* ptr14 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_bind((*this).get_handle(), network.get().get_handle(), std::move(variant2), std::move(variant3), std::move(variant4), std::move(variant5), std::move(variant6), std::move(variant7), std::move(variant8), std::move(variant9), std::move(variant10), std::move(variant11), std::move(variant12), std::move(variant13), std::move(ptr14)); + std::optional> result15_opt; + if ((int32_t) (*((uint8_t*) (ptr14 + 0)))==0) { + + result15_opt.emplace(std::expected()); + } else { + + result15_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr14 + 1)))}); + } + std::expected result15 = std::move(*result15_opt); + auto result16 = std::move(result15); + return result16; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::FinishBind() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_bind((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::StartConnect(std::reference_wrapper network, network::IpSocketAddress remote_address) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + int32_t variant2; + int32_t variant3; + int32_t variant4; + int32_t variant5; + int32_t variant6; + int32_t variant7; + int32_t variant8; + int32_t variant9; + int32_t variant10; + int32_t variant11; + int32_t variant12; + int32_t variant13; + switch ((int32_t) (remote_address).variants.index()) { + case 0: { + auto& payload0 = std::get(remote_address.variants).value; + variant2 = (int32_t(0)); + variant3 = (int32_t((payload0).port)); + variant4 = (int32_t(std::get<0>((payload0).address))); + variant5 = (int32_t(std::get<1>((payload0).address))); + variant6 = (int32_t(std::get<2>((payload0).address))); + variant7 = (int32_t(std::get<3>((payload0).address))); + variant8 = int32_t(0); + variant9 = int32_t(0); + variant10 = int32_t(0); + variant11 = int32_t(0); + variant12 = int32_t(0); + variant13 = int32_t(0); + break; + } + case 1: { + auto& payload1 = std::get(remote_address.variants).value; + variant2 = (int32_t(1)); + variant3 = (int32_t((payload1).port)); + variant4 = (int32_t((payload1).flow_info)); + variant5 = (int32_t(std::get<0>((payload1).address))); + variant6 = (int32_t(std::get<1>((payload1).address))); + variant7 = (int32_t(std::get<2>((payload1).address))); + variant8 = (int32_t(std::get<3>((payload1).address))); + variant9 = (int32_t(std::get<4>((payload1).address))); + variant10 = (int32_t(std::get<5>((payload1).address))); + variant11 = (int32_t(std::get<6>((payload1).address))); + variant12 = (int32_t(std::get<7>((payload1).address))); + variant13 = (int32_t((payload1).scope_id)); + break; + } + } + uint8_t* ptr14 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_connect((*this).get_handle(), network.get().get_handle(), std::move(variant2), std::move(variant3), std::move(variant4), std::move(variant5), std::move(variant6), std::move(variant7), std::move(variant8), std::move(variant9), std::move(variant10), std::move(variant11), std::move(variant12), std::move(variant13), std::move(ptr14)); + std::optional> result15_opt; + if ((int32_t) (*((uint8_t*) (ptr14 + 0)))==0) { + + result15_opt.emplace(std::expected()); + } else { + + result15_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr14 + 1)))}); + } + std::expected result15 = std::move(*result15_opt); + auto result16 = std::move(result15); + return result16; +} +std::expected, wasi::sockets0_2_0::network::ErrorCode> wasi::sockets0_2_0::tcp::TcpSocket::FinishConnect() const +{ + uint32_t ret_area[(12+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_connect((*this).get_handle(), std::move(ptr0)); + std::optional, network::ErrorCode>> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + int32_t l2 = *((int32_t const*)(ptr0 + 8)); + auto tuple3 = std::tuple(wit::ResourceImportBase{l1}, wit::ResourceImportBase{l2}); + + result4_opt.emplace(std::expected, network::ErrorCode>(std::move(tuple3))); + } else { + + result4_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected, network::ErrorCode> result4 = std::move(*result4_opt); + auto result5 = std::move(result4); + return result5; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::StartListen() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Estart_listen((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::FinishListen() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Efinish_listen((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected, wasi::sockets0_2_0::network::ErrorCode> wasi::sockets0_2_0::tcp::TcpSocket::Accept() const +{ + uint32_t ret_area[(16+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eaccept((*this).get_handle(), std::move(ptr0)); + std::optional, network::ErrorCode>> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + int32_t l2 = *((int32_t const*)(ptr0 + 8)); + int32_t l3 = *((int32_t const*)(ptr0 + 12)); + auto tuple4 = std::tuple(wit::ResourceImportBase{l1}, wit::ResourceImportBase{l2}, wit::ResourceImportBase{l3}); + + result5_opt.emplace(std::expected, network::ErrorCode>(std::move(tuple4))); + } else { + + result5_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected, network::ErrorCode> result5 = std::move(*result5_opt); + auto result6 = std::move(result5); + return result6; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::LocalAddress() const +{ + uint32_t ret_area[(36+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Elocal_address((*this).get_handle(), std::move(ptr0)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { auto tuple1 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 10))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 11))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 12))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 13)))))); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv4{network::Ipv4SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), std::move(tuple1), }}}}; + } break; + case 1: { int32_t l2 = *((int32_t const*)(ptr0 + 12)); + auto tuple3 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (ptr0 + 16))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 18))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 20))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 22))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 24))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 26))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 28))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 30)))))); + int32_t l4 = *((int32_t const*)(ptr0 + 32)); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv6{network::Ipv6SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), (uint32_t(l2)), std::move(tuple3), (uint32_t(l4)), }}}}; + } break; +} +network::IpSocketAddress variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::expected(std::move(variant5))); +} else { + +result6_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::RemoteAddress() const +{ + uint32_t ret_area[(36+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eremote_address((*this).get_handle(), std::move(ptr0)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { auto tuple1 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 10))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 11))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 12))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 13)))))); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv4{network::Ipv4SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), std::move(tuple1), }}}}; + } break; + case 1: { int32_t l2 = *((int32_t const*)(ptr0 + 12)); + auto tuple3 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (ptr0 + 16))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 18))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 20))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 22))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 24))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 26))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 28))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 30)))))); + int32_t l4 = *((int32_t const*)(ptr0 + 32)); + + variant5_opt = network::IpSocketAddress{{network::IpSocketAddress::Ipv6{network::Ipv6SocketAddress{(uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), (uint32_t(l2)), std::move(tuple3), (uint32_t(l4)), }}}}; + } break; +} +network::IpSocketAddress variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::expected(std::move(variant5))); +} else { + +result6_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +bool wasi::sockets0_2_0::tcp::TcpSocket::IsListening() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eis_listening((*this).get_handle()); + return (bool(ret)); +} +wasi::sockets0_2_0::network::IpAddressFamily wasi::sockets0_2_0::tcp::TcpSocket::AddressFamily() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eaddress_family((*this).get_handle()); + return (network::IpAddressFamily)ret; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetListenBacklogSize(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_listen_backlog_size((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::KeepAliveEnabled() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_enabled((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((bool((int32_t) (*((uint8_t*) (ptr0 + 1))))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetKeepAliveEnabled(bool value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_enabled((*this).get_handle(), (int32_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::KeepAliveIdleTime() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_idle_time((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetKeepAliveIdleTime(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_idle_time((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::KeepAliveInterval() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_interval((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetKeepAliveInterval(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_interval((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::KeepAliveCount() const +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ekeep_alive_count((*this).get_handle(), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected((uint32_t(l1)))); + } else { + + result2_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetKeepAliveCount(uint32_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_keep_alive_count((*this).get_handle(), (int32_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::HopLimit() const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ehop_limit((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 1))))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetHopLimit(uint8_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_hop_limit((*this).get_handle(), (int32_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::ReceiveBufferSize() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Ereceive_buffer_size((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetReceiveBufferSize(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_receive_buffer_size((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SendBufferSize() const +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Esend_buffer_size((*this).get_handle(), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected((uint64_t(*((int64_t*) (ptr0 + 8)))))); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 8)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::SetSendBufferSize(uint64_t value) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eset_send_buffer_size((*this).get_handle(), (int64_t(value)), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +wasi::io0_2_0::poll::Pollable wasi::sockets0_2_0::tcp::TcpSocket::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +std::expected wasi::sockets0_2_0::tcp::TcpSocket::Shutdown(tcp::ShutdownType shutdown_type) const +{ + uint8_t ret_area[(2+sizeof(uint8_t)-1)/sizeof(uint8_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2FtcpX400X2E2X2E0X00X5BmethodX5Dtcp_socketX2Eshutdown((*this).get_handle(), int32_t(shutdown_type), std::move(ptr0)); + std::optional> result1_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + + result1_opt.emplace(std::expected()); + } else { + + result1_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 1)))}); + } + std::expected result1 = std::move(*result1_opt); + auto result2 = std::move(result1); + return result2; +} +wasi::sockets0_2_0::tcp::TcpSocket::TcpSocket(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected wasi::sockets0_2_0::tcp_create_socket::CreateTcpSocket(network::IpAddressFamily address_family) +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2Ftcp_create_socketX400X2E2X2E0X00create_tcp_socket(int32_t(address_family), std::move(ptr0)); + std::optional> result2_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + int32_t l1 = *((int32_t const*)(ptr0 + 4)); + + result2_opt.emplace(std::expected(wit::ResourceImportBase{l1})); + } else { + + result2_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 4)))}); + } + std::expected result2 = std::move(*result2_opt); + auto result3 = std::move(result2); + return result3; +} +wasi::sockets0_2_0::ip_name_lookup::ResolveAddressStream::~ResolveAddressStream() +{ + if (handle>=0) { + __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5Bresource_dropX5Dresolve_address_stream(handle); + } +} +std::expected, wasi::sockets0_2_0::network::ErrorCode> wasi::sockets0_2_0::ip_name_lookup::ResolveAddressStream::ResolveNextAddress() const +{ + uint16_t ret_area[(22+sizeof(uint16_t)-1)/sizeof(uint16_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5BmethodX5Dresolve_address_streamX2Eresolve_next_address((*this).get_handle(), std::move(ptr0)); + std::optional, network::ErrorCode>> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional option4; + if ((int32_t) (*((uint8_t*) (ptr0 + 2)))) { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + 4)))) { + case 0: { auto tuple1 = std::tuple((uint8_t((int32_t) (*((uint8_t*) (ptr0 + 6))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 7))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 8))))), (uint8_t((int32_t) (*((uint8_t*) (ptr0 + 9)))))); + + variant3_opt = network::IpAddress{{network::IpAddress::Ipv4{std::move(tuple1)}}}; + } break; + case 1: { auto tuple2 = std::tuple((uint16_t((int32_t) (*((uint16_t*) (ptr0 + 6))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 8))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 10))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 12))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 14))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 16))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 18))))), (uint16_t((int32_t) (*((uint16_t*) (ptr0 + 20)))))); + + variant3_opt = network::IpAddress{{network::IpAddress::Ipv6{std::move(tuple2)}}}; + } break; + } + network::IpAddress variant3 = std::move(*variant3_opt); + + option4.emplace(std::move(variant3)); +} + +result5_opt.emplace(std::expected, network::ErrorCode>(std::move(option4))); +} else { + +result5_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr0 + 2)))}); +} +std::expected, network::ErrorCode> result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +wasi::io0_2_0::poll::Pollable wasi::sockets0_2_0::ip_name_lookup::ResolveAddressStream::Subscribe() const +{ + auto ret = __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00X5BmethodX5Dresolve_address_streamX2Esubscribe((*this).get_handle()); + return wit::ResourceImportBase{ret}; +} +wasi::sockets0_2_0::ip_name_lookup::ResolveAddressStream::ResolveAddressStream(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected wasi::sockets0_2_0::ip_name_lookup::ResolveAddresses(std::reference_wrapper network, std::string_view name) +{ + uint32_t ret_area[(8+sizeof(uint32_t)-1)/sizeof(uint32_t)]; + auto&& _vec0 = name; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AsocketsX2Fip_name_lookupX400X2E2X2E0X00resolve_addresses(network.get().get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result3_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + 4)); + + result3_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + + result3_opt.emplace(std::unexpected{(network::ErrorCode)(int32_t) (*((uint8_t*) (ptr1 + 4)))}); + } + std::expected result3 = std::move(*result3_opt); + auto result4 = std::move(result3); + return result4; +} +wit::vector wasi::random0_2_0::random::GetRandomBytes(uint64_t len) +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3ArandomX2FrandomX400X2E2X2E0X00get_random_bytes((int64_t(len)), std::move(ptr0)); + auto _len1 = *((size_t*) (ptr0 + sizeof(void*))); + auto result2 = wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + 0))), _len1); + return result2; +} +uint64_t wasi::random0_2_0::random::GetRandomU64() +{ + auto ret = __wasm_import_wasiX3ArandomX2FrandomX400X2E2X2E0X00get_random_u64(); + return (uint64_t(ret)); +} +wit::vector wasi::random0_2_0::insecure::GetInsecureRandomBytes(uint64_t len) +{ + uintptr_t ret_area[((2*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3ArandomX2FinsecureX400X2E2X2E0X00get_insecure_random_bytes((int64_t(len)), std::move(ptr0)); + auto _len1 = *((size_t*) (ptr0 + sizeof(void*))); + auto result2 = wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + 0))), _len1); + return result2; +} +uint64_t wasi::random0_2_0::insecure::GetInsecureRandomU64() +{ + auto ret = __wasm_import_wasiX3ArandomX2FinsecureX400X2E2X2E0X00get_insecure_random_u64(); + return (uint64_t(ret)); +} +std::tuple wasi::random0_2_0::insecure_seed::InsecureSeed() +{ + uint64_t ret_area[(16+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3ArandomX2Finsecure_seedX400X2E2X2E0X00insecure_seed(std::move(ptr0)); + auto tuple1 = std::tuple((uint64_t(*((int64_t*) (ptr0 + 0)))), (uint64_t(*((int64_t*) (ptr0 + 8))))); + auto result2 = std::move(tuple1); + return result2; +} +wasi::keyvalue::store::Bucket::~Bucket() +{ + if (handle>=0) { + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5Bresource_dropX5Dbucket(handle); + } +} +std::expected>, wasi::keyvalue::store::Error> wasi::keyvalue::store::Bucket::Get(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eget((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional>, store::Error>> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + std::optional> option3; + if ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + option3.emplace(wit::vector((uint8_t*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)); + } + + result6_opt.emplace(std::expected>, store::Error>(std::move(option3))); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant5_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant5_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len4 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant5_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + store::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected>, store::Error> result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected wasi::keyvalue::store::Bucket::Set(std::string_view key, std::span value) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + auto&& _vec1 = value; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eset((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant4_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant4_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant4_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + store::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected wasi::keyvalue::store::Bucket::Delete(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Edelete((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected()); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant3_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant3_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant3_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)}}}; + } break; + } + store::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::keyvalue::store::Bucket::Exists(std::string_view key) const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Eexists((*this).get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected((bool((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*)))))))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant3_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant3_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len2 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant3_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len2)}}}; + } break; + } + store::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::keyvalue::store::Bucket::ListKeys(std::optional cursor) const +{ + uintptr_t ret_area[((6*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + int32_t option3; + uint8_t * option4; + size_t option5; + if ((cursor).has_value()) { + std::string_view payload1 = (std::move(cursor)).value(); + auto&& _vec2 = payload1; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + option3 = (int32_t(1)); + option4 = _ptr2; + option5 = _len2; + } else { + option3 = (int32_t(0)); + option4 = nullptr; + option5 = size_t(0); + } + uint8_t* ptr6 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00X5BmethodX5DbucketX2Elist_keys((*this).get_handle(), std::move(option3), std::move(option4), std::move(option5), std::move(ptr6)); + std::optional> result13_opt; + if ((int32_t) (*((uint8_t*) (ptr6 + 0)))==0) { + auto _base8 = *((uint8_t**) (ptr6 + sizeof(void*))); + auto _len8 = *((size_t*) (ptr6 + (2*sizeof(void*)))); + auto _result8 = wit::vector::allocate(_len8); + for (unsigned i=0; i<_len8; ++i) { + auto _base = _base8 + i * (2*sizeof(void*)); + auto _len7 = *((size_t*) (_base + sizeof(void*))); + + auto _e8 = wit::string((char const*)(*((uint8_t**) (_base + 0))), _len7); + _result8.initialize(i, std::move(_e8)); + } + std::optional option10; + if ((int32_t) (*((uint8_t*) (ptr6 + (3*sizeof(void*)))))) { + auto _len9 = *((size_t*) (ptr6 + (5*sizeof(void*)))); + + + option10.emplace(wit::string((char const*)(*((uint8_t**) (ptr6 + (4*sizeof(void*))))), _len9)); + } + + result13_opt.emplace(std::expected(store::KeyResponse{std::move(_result8), std::move(option10), })); + } else { + std::optional variant12_opt; + switch ((int32_t) (*((uint8_t*) (ptr6 + sizeof(void*))))) { + case 0: { + variant12_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant12_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len11 = *((size_t*) (ptr6 + (3*sizeof(void*)))); + + + variant12_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr6 + (2*sizeof(void*))))), _len11)}}}; + } break; + } + store::Error variant12 = std::move(*variant12_opt); + + result13_opt.emplace(std::unexpected{std::move(variant12)}); +} +std::expected result13 = std::move(*result13_opt); +auto result14 = std::move(result13); +return result14; +} +wasi::keyvalue::store::Bucket::Bucket(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected wasi::keyvalue::store::Open(std::string_view identifier) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = identifier; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FstoreX400X2E2X2E0_draft2X00open(std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = Error{{Error::NoSuchStore{}}}; + } break; + case 1: { + variant4_opt = Error{{Error::AccessDenied{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = Error{{Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +wasi::keyvalue::atomics::Cas::~Cas() +{ + if (handle>=0) { + __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5Bresource_dropX5Dcas(handle); + } +} +std::expected wasi::keyvalue::atomics::Cas::New(std::reference_wrapper bucket, std::string_view key) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5BstaticX5DcasX2Enew(bucket.get().get_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + int32_t l2 = *((int32_t const*)(ptr1 + sizeof(void*))); + + result5_opt.emplace(std::expected(wit::ResourceImportBase{l2})); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { + variant4_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant4_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr1 + (3*sizeof(void*)))); + + + variant4_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + store::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +std::expected>, wasi::keyvalue::store::Error> wasi::keyvalue::atomics::Cas::Current() const +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + uint8_t* ptr0 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00X5BmethodX5DcasX2Ecurrent((*this).get_handle(), std::move(ptr0)); + std::optional>, store::Error>> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr0 + 0)))==0) { + std::optional> option2; + if ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + auto _len1 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + option2.emplace(wit::vector((uint8_t*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len1)); + } + + result5_opt.emplace(std::expected>, store::Error>(std::move(option2))); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr0 + sizeof(void*))))) { + case 0: { + variant4_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant4_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr0 + (3*sizeof(void*)))); + + + variant4_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr0 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + store::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected>, store::Error> result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +wasi::keyvalue::atomics::Cas::Cas(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {} +std::expected wasi::keyvalue::atomics::Increment(std::reference_wrapper bucket, std::string_view key, int64_t delta) +{ + uint64_t ret_area[((16+2*sizeof(void*))+sizeof(uint64_t)-1)/sizeof(uint64_t)]; + auto&& _vec0 = key; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00increment(bucket.get().get_handle(), std::move(_ptr0), std::move(_len0), (int64_t(delta)), std::move(ptr1)); + std::optional> result4_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result4_opt.emplace(std::expected((int64_t(*((int64_t*) (ptr1 + 8)))))); + } else { + std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + 8)))) { + case 0: { + variant3_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant3_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len2 = *((size_t*) (ptr1 + (8+2*sizeof(void*)))); + + + variant3_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (8+1*sizeof(void*))))), _len2)}}}; + } break; + } + store::Error variant3 = std::move(*variant3_opt); + + result4_opt.emplace(std::unexpected{std::move(variant3)}); +} +std::expected result4 = std::move(*result4_opt); +auto result5 = std::move(result4); +return result5; +} +std::expected wasi::keyvalue::atomics::Swap(Cas&& cas, std::span value) +{ + uintptr_t ret_area[((5*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec0 = value; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + uint8_t* ptr1 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FatomicsX400X2E2X2E0_draft2X00swap(cas.into_handle(), std::move(_ptr0), std::move(_len0), std::move(ptr1)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr1 + 0)))==0) { + + result6_opt.emplace(std::expected()); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + sizeof(void*))))) { + case 0: { std::optional variant3_opt; + switch ((int32_t) (*((uint8_t*) (ptr1 + (2*sizeof(void*)))))) { + case 0: { + variant3_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant3_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len2 = *((size_t*) (ptr1 + (4*sizeof(void*)))); + + + variant3_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr1 + (3*sizeof(void*))))), _len2)}}}; + } break; + } + store::Error variant3 = std::move(*variant3_opt); + + variant5_opt = CasError{{CasError::StoreError{std::move(variant3)}}}; + } break; + case 1: { int32_t l4 = *((int32_t const*)(ptr1 + (2*sizeof(void*)))); + + variant5_opt = CasError{{CasError::CasFailed{wit::ResourceImportBase{l4}}}}; +} break; +} +CasError variant5 = std::move(*variant5_opt); + +result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected>>>, wasi::keyvalue::store::Error> wasi::keyvalue::batch::GetMany(std::reference_wrapper bucket, std::span keys) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec1 = keys; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + for (size_t i = 0; i < _len1; ++i) { + auto _base = _ptr1 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec1[i]; + auto&& _vec0 = _iter_elem; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + + } + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00get_many(bucket.get().get_handle(), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional>>>, store::Error>> result10_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + auto _base7 = *((uint8_t**) (ptr2 + sizeof(void*))); + auto _len7 = *((size_t*) (ptr2 + (2*sizeof(void*)))); + auto _result7 = wit::vector>>>::allocate(_len7); + for (unsigned i=0; i<_len7; ++i) { + auto _base = _base7 + i * (5*sizeof(void*)); + auto _len3 = *((size_t*) (_base + sizeof(void*))); + + std::optional> option5; + if ((int32_t) (*((uint8_t*) (_base + (2*sizeof(void*)))))) { + auto _len4 = *((size_t*) (_base + (4*sizeof(void*)))); + + option5.emplace(wit::vector((uint8_t*)(*((uint8_t**) (_base + (3*sizeof(void*))))), _len4)); + } + auto tuple6 = std::tuple>>(wit::string((char const*)(*((uint8_t**) (_base + 0))), _len3), std::move(option5)); + auto _e7 = std::move(tuple6); + _result7.initialize(i, std::move(_e7)); + } + + result10_opt.emplace(std::expected>>>, store::Error>(std::move(_result7))); + } else { + std::optional variant9_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant9_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant9_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len8 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant9_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len8)}}}; + } break; + } + store::Error variant9 = std::move(*variant9_opt); + + result10_opt.emplace(std::unexpected{std::move(variant9)}); +} +std::expected>>>, store::Error> result10 = std::move(*result10_opt); +auto result11 = std::move(result10); +return result11; +} +std::expected wasi::keyvalue::batch::SetMany(std::reference_wrapper bucket, std::span> const> key_values) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec2 = key_values; + auto _ptr2 = (uint8_t*)(_vec2.data()); + auto _len2 = (size_t)(_vec2.size()); + for (size_t i = 0; i < _len2; ++i) { + auto _base = _ptr2 + i * (4*sizeof(void*)); + auto&& _iter_elem = _vec2[i]; + auto&& _vec0 = std::get<0>(_iter_elem); + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + auto&& _vec1 = std::get<1>(_iter_elem); + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + *((size_t*)(_base + (3*sizeof(void*)))) = _len1; + *((uint8_t**)(_base + (2*sizeof(void*)))) = _ptr1; + + } + uint8_t* ptr3 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00set_many(bucket.get().get_handle(), std::move(_ptr2), std::move(_len2), std::move(ptr3)); + std::optional> result6_opt; + if ((int32_t) (*((uint8_t*) (ptr3 + 0)))==0) { + + result6_opt.emplace(std::expected()); + } else { + std::optional variant5_opt; + switch ((int32_t) (*((uint8_t*) (ptr3 + sizeof(void*))))) { + case 0: { + variant5_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant5_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len4 = *((size_t*) (ptr3 + (3*sizeof(void*)))); + + + variant5_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr3 + (2*sizeof(void*))))), _len4)}}}; + } break; + } + store::Error variant5 = std::move(*variant5_opt); + + result6_opt.emplace(std::unexpected{std::move(variant5)}); +} +std::expected result6 = std::move(*result6_opt); +auto result7 = std::move(result6); +return result7; +} +std::expected wasi::keyvalue::batch::DeleteMany(std::reference_wrapper bucket, std::span keys) +{ + uintptr_t ret_area[((4*sizeof(void*))+sizeof(uintptr_t)-1)/sizeof(uintptr_t)]; + auto&& _vec1 = keys; + auto _ptr1 = (uint8_t*)(_vec1.data()); + auto _len1 = (size_t)(_vec1.size()); + for (size_t i = 0; i < _len1; ++i) { + auto _base = _ptr1 + i * (2*sizeof(void*)); + auto&& _iter_elem = _vec1[i]; + auto&& _vec0 = _iter_elem; + auto _ptr0 = (uint8_t*)(_vec0.data()); + auto _len0 = (size_t)(_vec0.size()); + *((size_t*)(_base + sizeof(void*))) = _len0; + *((uint8_t**)(_base + 0)) = _ptr0; + + } + uint8_t* ptr2 = (uint8_t*)(&ret_area); + __wasm_import_wasiX3AkeyvalueX2FbatchX400X2E2X2E0_draft2X00delete_many(bucket.get().get_handle(), std::move(_ptr1), std::move(_len1), std::move(ptr2)); + std::optional> result5_opt; + if ((int32_t) (*((uint8_t*) (ptr2 + 0)))==0) { + + result5_opt.emplace(std::expected()); + } else { + std::optional variant4_opt; + switch ((int32_t) (*((uint8_t*) (ptr2 + sizeof(void*))))) { + case 0: { + variant4_opt = store::Error{{store::Error::NoSuchStore{}}}; + } break; + case 1: { + variant4_opt = store::Error{{store::Error::AccessDenied{}}}; + } break; + case 2: { auto _len3 = *((size_t*) (ptr2 + (3*sizeof(void*)))); + + + variant4_opt = store::Error{{store::Error::Other{wit::string((char const*)(*((uint8_t**) (ptr2 + (2*sizeof(void*))))), _len3)}}}; + } break; + } + store::Error variant4 = std::move(*variant4_opt); + + result5_opt.emplace(std::unexpected{std::move(variant4)}); +} +std::expected result5 = std::move(*result5_opt); +auto result6 = std::move(result5); +return result6; +} +extern "C" __attribute__((__export_name__("wasi:http/incoming-handler@0.2.0#handle"))) +void __wasm_export_wasiX3AhttpX2Fincoming_handlerX400X2E2X2E0X23handle(int32_t arg0, int32_t arg1) +{ + auto obj0 = wasi::http0_2_0::types::IncomingRequest(wit::ResourceImportBase{arg0}); + auto obj1 = wasi::http0_2_0::types::ResponseOutparam(wit::ResourceImportBase{arg1}); + exports::wasi::http0_2_0::incoming_handler::Handle(std::move(obj0), std::move(obj1)); +} + +// Component Adapters diff --git a/templates/http-cpp/content/bindings/http_trigger_component_type.o b/templates/http-cpp/content/bindings/http_trigger_component_type.o new file mode 100644 index 0000000000..e72a80b6bd Binary files /dev/null and b/templates/http-cpp/content/bindings/http_trigger_component_type.o differ diff --git a/templates/http-cpp/content/bindings/http_trigger_cpp.h b/templates/http-cpp/content/bindings/http_trigger_cpp.h new file mode 100644 index 0000000000..e80c154460 --- /dev/null +++ b/templates/http-cpp/content/bindings/http_trigger_cpp.h @@ -0,0 +1,3456 @@ +// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT! +#ifndef __CPP_GUEST_BINDINGS_HTTP_TRIGGER_H +#define __CPP_GUEST_BINDINGS_HTTP_TRIGGER_H +#include +#include +#include +#include +#include +#include +#include +#include +#include "wit.h" +namespace spin { + namespace postgres3_0_0 { + namespace postgres { + /// Errors related to interacting with a database. + struct Error { + struct ConnectionFailed { wit::string value; }; + struct BadParameter { wit::string value; }; + struct QueryFailed { wit::string value; }; + struct ValueConversionFailed { wit::string value; }; + struct Other { wit::string value; }; + std::variant variants; + }; + /// Data types for a database column + enum class DbDataType : uint8_t { + kBoolean = 0, + kInt8 = 1, + kInt16 = 2, + kInt32 = 3, + kInt64 = 4, + kFloating32 = 5, + kFloating64 = 6, + kStr = 7, + kBinary = 8, + kDate = 9, + kTime = 10, + kDatetime = 11, + kTimestamp = 12, + kOther = 13, + }; + + /// Database values + struct DbValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct Date { std::tuple value; }; + /// (year, month, day) + struct Time { std::tuple value; }; + /// (hour, minute, second, nanosecond) + /// Date-time types are always treated as UTC (without timezone info). + /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. + struct Datetime { std::tuple value; }; + /// Unix timestamp (seconds since epoch) + struct Timestamp { int64_t value; }; + struct DbNull {}; + struct Unsupported {}; + std::variant variants; + }; + /// Values used in parameterized queries + struct ParameterValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct Date { std::tuple value; }; + /// (year, month, day) + struct Time { std::tuple value; }; + /// (hour, minute, second, nanosecond) + /// Date-time types are always treated as UTC (without timezone info). + /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. + struct Datetime { std::tuple value; }; + /// Unix timestamp (seconds since epoch) + struct Timestamp { int64_t value; }; + struct DbNull {}; + std::variant variants; + }; + /// A database column + struct Column { + wit::string name; + DbDataType data_type; + }; + /// A set of database rows + struct RowSet { + wit::vector columns; + wit::vector> rows; + }; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the Postgres instance at `address`. + static std::expected Open(std::string_view address); + /// Query the database. + std::expected Query(std::string_view statement, std::span params) const; + /// Execute command to the database. + std::expected Execute(std::string_view statement, std::span params) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + } + namespace postgres4_0_0 { + namespace postgres { + struct DbError { + /// Stringised version of the error. This is primarily to facilitate migration of older code. + wit::string as_text; + wit::string severity; + wit::string code; + wit::string message; + std::optional detail; + /// Any error information provided by Postgres and not captured above. + wit::vector> extras; + }; + struct QueryError { + /// An error occurred but we do not have structured info for it + struct Text { wit::string value; }; + /// Postgres returned a structured database error + struct DbError { postgres::DbError value; }; + std::variant variants; + }; + /// Errors related to interacting with a database. + struct Error { + struct ConnectionFailed { wit::string value; }; + struct BadParameter { wit::string value; }; + struct QueryFailed { postgres::QueryError value; }; + struct ValueConversionFailed { wit::string value; }; + struct Other { wit::string value; }; + std::variant variants; + }; + /// Data types for a database column + struct DbDataType { + struct Boolean {}; + struct Int8 {}; + struct Int16 {}; + struct Int32 {}; + struct Int64 {}; + struct Floating32 {}; + struct Floating64 {}; + struct Str {}; + struct Binary {}; + struct Date {}; + struct Time {}; + struct Datetime {}; + struct Timestamp {}; + struct Uuid {}; + struct Jsonb {}; + struct Decimal {}; + struct RangeInt32 {}; + struct RangeInt64 {}; + struct RangeDecimal {}; + struct ArrayInt32 {}; + struct ArrayInt64 {}; + struct ArrayDecimal {}; + struct ArrayStr {}; + struct Interval {}; + struct Other { wit::string value; }; + std::variant variants; + }; + struct Interval { + int64_t micros; + int32_t days; + int32_t months; + }; + /// A database column + struct Column { + wit::string name; + DbDataType data_type; + }; + /// For range types, indicates if each bound is inclusive or exclusive + enum class RangeBoundKind : uint8_t { + kInclusive = 0, + kExclusive = 1, + }; + + /// Database values + struct DbValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct Date { std::tuple value; }; + /// (year, month, day) + struct Time { std::tuple value; }; + /// (hour, minute, second, nanosecond) + /// Date-time types are always treated as UTC (without timezone info). + /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. + struct Datetime { std::tuple value; }; + /// Unix timestamp (seconds since epoch) + struct Timestamp { int64_t value; }; + struct Uuid { wit::string value; }; + struct Jsonb { wit::vector value; }; + struct Decimal { wit::string value; }; + /// I admit defeat. Base 10 + struct RangeInt32 { std::tuple>, std::optional>> value; }; + struct RangeInt64 { std::tuple>, std::optional>> value; }; + struct RangeDecimal { std::tuple>, std::optional>> value; }; + struct ArrayInt32 { wit::vector> value; }; + struct ArrayInt64 { wit::vector> value; }; + struct ArrayDecimal { wit::vector> value; }; + struct ArrayStr { wit::vector> value; }; + struct Interval { postgres::Interval value; }; + struct DbNull {}; + struct Unsupported { wit::vector value; }; + std::variant variants; + }; + /// Values used in parameterized queries + struct ParameterValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct Date { std::tuple value; }; + /// (year, month, day) + struct Time { std::tuple value; }; + /// (hour, minute, second, nanosecond) + /// Date-time types are always treated as UTC (without timezone info). + /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. + struct Datetime { std::tuple value; }; + /// Unix timestamp (seconds since epoch) + struct Timestamp { int64_t value; }; + struct Uuid { wit::string value; }; + struct Jsonb { wit::vector value; }; + struct Decimal { wit::string value; }; + /// base 10 + struct RangeInt32 { std::tuple>, std::optional>> value; }; + struct RangeInt64 { std::tuple>, std::optional>> value; }; + struct RangeDecimal { std::tuple>, std::optional>> value; }; + struct ArrayInt32 { wit::vector> value; }; + struct ArrayInt64 { wit::vector> value; }; + struct ArrayDecimal { wit::vector> value; }; + struct ArrayStr { wit::vector> value; }; + struct Interval { postgres::Interval value; }; + struct DbNull {}; + std::variant variants; + }; + /// A set of database rows + struct RowSet { + wit::vector columns; + wit::vector> rows; + }; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the Postgres instance at `address`. + static std::expected Open(std::string_view address); + /// Query the database. + std::expected Query(std::string_view statement, std::span params) const; + /// Execute command to the database. + std::expected Execute(std::string_view statement, std::span params) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + } + namespace sqlite { + namespace sqlite { + /// The set of errors which may be raised by functions in this interface + struct Error { + /// The host does not recognize the database name requested. + struct NoSuchDatabase {}; + /// The requesting component does not have access to the specified database (which may or may not exist). + struct AccessDenied {}; + /// The provided connection is not valid + struct InvalidConnection {}; + /// The database has reached its capacity + struct DatabaseFull {}; + /// Some implementation-specific error has occurred (e.g. I/O) + struct Io { wit::string value; }; + std::variant variants; + }; + /// A single column's result from a database query + struct Value { + struct Integer { int64_t value; }; + struct Real { double value; }; + struct Text { wit::string value; }; + struct Blob { wit::vector value; }; + struct Null {}; + std::variant variants; + }; + /// A set of values for each of the columns in a query-result + struct RowResult { + wit::vector values; + }; + /// A result of a query + struct QueryResult { + /// The names of the columns retrieved in the query + wit::vector columns; + /// the row results each containing the values for all the columns for a given row + wit::vector rows; + }; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to a named database instance. + /// + /// If `database` is "default", the default instance is opened. + /// + /// `error::no-such-database` will be raised if the `name` is not recognized. + static std::expected Open(std::string_view database); + /// Execute a statement returning back data if there is any + std::expected Execute(std::string_view statement, std::span parameters) const; + /// The SQLite rowid of the most recent successful INSERT on the connection, or 0 if + /// there has not yet been an INSERT on the connection. + int64_t LastInsertRowid() const; + /// The number of rows modified, inserted or deleted by the most recently completed + /// INSERT, UPDATE or DELETE statement on the connection. + uint64_t Changes() const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + } +} +namespace wasi { + namespace config { + namespace store { + /// An error type that encapsulates the different errors that can occur fetching configuration values. + struct Error { + /// 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. + struct Upstream { wit::string value; }; + /// 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. + struct Io { wit::string value; }; + std::variant variants; + }; + /// Gets a configuration value of type `string` associated with the `key`. + /// + /// The value is returned as an `option`. If the key is not found, + /// `Ok(none)` is returned. If an error occurs, an `Err(error)` is returned. + std::expected, Error> Get(std::string_view key); + /// Gets a list of configuration key-value pairs of type `string`. + /// + /// If an error occurs, an `Err(error)` is returned. + std::expected>, Error> GetAll(); + } + } + /// A poll API intended to let users wait for I/O events on multiple handles + /// at once. + namespace io0_2_0 { + namespace poll { + class Pollable : public wit::ResourceImportBase{ + + public: + + ~Pollable(); + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + bool Ready() const; + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + void Block() const; + Pollable(wit::ResourceImportBase &&); + Pollable(Pollable&&) = default; + Pollable& operator=(Pollable&&) = default; + }; + + /// Poll for completion on a set of pollables. + /// + /// This function takes a list of pollables, which identify I/O sources of + /// interest, and waits until one or more of the events is ready for I/O. + /// + /// The result `list` contains one or more indices of handles in the + /// argument list that is ready for I/O. + /// + /// If the list contains more elements than can be indexed with a `u32` + /// value, this function traps. + /// + /// A timeout can be implemented by adding a pollable from the + /// wasi-clocks API to the list. + /// + /// This function does not return a `result`; polling in itself does not + /// do any I/O so it doesn't fail. If any of the I/O sources identified by + /// the pollables has an error, it is indicated by marking the source as + /// being reaedy for I/O. + wit::vector Poll(std::span const> in); + } + } + /// WASI Monotonic Clock is a clock API intended to let users measure elapsed + /// time. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + /// + /// A monotonic clock is a clock which has an unspecified initial value, and + /// successive reads of the clock will produce non-decreasing values. + /// + /// It is intended for measuring elapsed time. + namespace clocks0_2_0 { + namespace monotonic_clock { + using Pollable = io0_2_0::poll::Pollable; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + using Instant = uint64_t; + /// A duration of time, in nanoseconds. + using Duration = uint64_t; + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + uint64_t Now(); + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + uint64_t Resolution(); + /// Create a `pollable` which will resolve once the specified instant + /// occured. + io0_2_0::poll::Pollable SubscribeInstant(uint64_t when); + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + io0_2_0::poll::Pollable SubscribeDuration(uint64_t when); + } + } + namespace io0_2_0 { + namespace error { + class Error : public wit::ResourceImportBase{ + + public: + + ~Error(); + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + wit::string ToDebugString() const; + Error(wit::ResourceImportBase &&); + Error(Error&&) = default; + Error& operator=(Error&&) = default; + }; + + } + /// WASI I/O is an I/O abstraction API which is currently focused on providing + /// stream types. + /// + /// In the future, the component model is expected to add built-in stream types; + /// when it does, they are expected to subsume this API. + namespace streams { + using Error = error::Error; + using Pollable = poll::Pollable; + /// An error for input-stream and output-stream operations. + struct StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + struct LastOperationFailed { error::Error value; }; + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + struct Closed {}; + std::variant variants; + }; + class InputStream : public wit::ResourceImportBase{ + + public: + + ~InputStream(); + /// Perform a non-blocking read from the stream. + /// + /// When the source of a `read` is binary data, the bytes from the source + /// are returned verbatim. When the source of a `read` is known to the + /// implementation to be text, bytes containing the UTF-8 encoding of the + /// text are returned. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + std::expected, StreamError> Read(uint64_t len) const; + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + std::expected, StreamError> BlockingRead(uint64_t len) const; + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + std::expected Skip(uint64_t len) const; + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + std::expected BlockingSkip(uint64_t len) const; + /// Create a `pollable` which will resolve once either the specified stream + /// has bytes available to read or the other end of the stream has been + /// closed. + /// The created `pollable` is a child resource of the `input-stream`. + /// Implementations may trap if the `input-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + poll::Pollable Subscribe() const; + InputStream(wit::ResourceImportBase &&); + InputStream(InputStream&&) = default; + InputStream& operator=(InputStream&&) = default; + }; + + class OutputStream : public wit::ResourceImportBase{ + + public: + + ~OutputStream(); + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + std::expected CheckWrite() const; + /// Perform a write. This function never blocks. + /// + /// When the destination of a `write` is binary data, the bytes from + /// `contents` are written verbatim. When the destination of a `write` is + /// known to the implementation to be text, the bytes of `contents` are + /// transcoded from UTF-8 into the encoding of the destination and then + /// written. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + std::expected Write(std::span contents) const; + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// pollable.block(); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// pollable.block(); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + std::expected BlockingWriteAndFlush(std::span contents) const; + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + std::expected Flush() const; + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + std::expected BlockingFlush() const; + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + poll::Pollable Subscribe() const; + /// Write zeroes to a stream. + /// + /// This should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + std::expected WriteZeroes(uint64_t len) const; + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// pollable.block(); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// pollable.block(); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + std::expected BlockingWriteZeroesAndFlush(uint64_t len) const; + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + std::expected Splice(std::reference_wrapper src, uint64_t len) const; + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + std::expected BlockingSplice(std::reference_wrapper src, uint64_t len) const; + OutputStream(wit::ResourceImportBase &&); + OutputStream(OutputStream&&) = default; + OutputStream& operator=(OutputStream&&) = default; + }; + + } + } + /// This interface defines all of the types and methods for implementing + /// HTTP Requests and Responses, both incoming and outgoing, as well as + /// their headers, trailers, and bodies. + namespace http0_2_0 { + namespace types { + using Duration = uint64_t; + using InputStream = io0_2_0::streams::InputStream; + using OutputStream = io0_2_0::streams::OutputStream; + using IoError = io0_2_0::error::Error; + using Pollable = io0_2_0::poll::Pollable; + /// This type corresponds to HTTP standard Methods. + struct Method { + struct Get {}; + struct Head {}; + struct Post {}; + struct Put {}; + struct Delete {}; + struct Connect {}; + struct Options {}; + struct Trace {}; + struct Patch {}; + struct Other { wit::string value; }; + std::variant variants; + }; + /// This type corresponds to HTTP standard Related Schemes. + struct Scheme { + struct Http {}; + struct Https {}; + struct Other { wit::string value; }; + std::variant variants; + }; + /// Defines the case payload type for `DNS-error` above: + struct DnsErrorPayload { + std::optional rcode; + std::optional info_code; + }; + /// Defines the case payload type for `TLS-alert-received` above: + struct TlsAlertReceivedPayload { + std::optional alert_id; + std::optional alert_message; + }; + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + struct FieldSizePayload { + std::optional field_name; + std::optional field_size; + }; + /// These cases are inspired by the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + struct ErrorCode { + struct DnsTimeout {}; + struct DnsError { types::DnsErrorPayload value; }; + struct DestinationNotFound {}; + struct DestinationUnavailable {}; + struct DestinationIpProhibited {}; + struct DestinationIpUnroutable {}; + struct ConnectionRefused {}; + struct ConnectionTerminated {}; + struct ConnectionTimeout {}; + struct ConnectionReadTimeout {}; + struct ConnectionWriteTimeout {}; + struct ConnectionLimitReached {}; + struct TlsProtocolError {}; + struct TlsCertificateError {}; + struct TlsAlertReceived { types::TlsAlertReceivedPayload value; }; + struct HttpRequestDenied {}; + struct HttpRequestLengthRequired {}; + struct HttpRequestBodySize { std::optional value; }; + struct HttpRequestMethodInvalid {}; + struct HttpRequestUriInvalid {}; + struct HttpRequestUriTooLong {}; + struct HttpRequestHeaderSectionSize { std::optional value; }; + struct HttpRequestHeaderSize { std::optional value; }; + struct HttpRequestTrailerSectionSize { std::optional value; }; + struct HttpRequestTrailerSize { types::FieldSizePayload value; }; + struct HttpResponseIncomplete {}; + struct HttpResponseHeaderSectionSize { std::optional value; }; + struct HttpResponseHeaderSize { types::FieldSizePayload value; }; + struct HttpResponseBodySize { std::optional value; }; + struct HttpResponseTrailerSectionSize { std::optional value; }; + struct HttpResponseTrailerSize { types::FieldSizePayload value; }; + struct HttpResponseTransferCoding { std::optional value; }; + struct HttpResponseContentCoding { std::optional value; }; + struct HttpResponseTimeout {}; + struct HttpUpgradeFailed {}; + struct HttpProtocolError {}; + struct LoopDetected {}; + struct ConfigurationError {}; + /// This is a catch-all error for anything that doesn't fit cleanly into a + /// more specific case. It also includes an optional string for an + /// unstructured description of the error. Users should not depend on the + /// string for diagnosing errors, as it's not required to be consistent + /// between implementations. + struct InternalError { std::optional value; }; + std::variant variants; + }; + /// This type enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + struct HeaderError { + /// This error indicates that a `field-key` or `field-value` was + /// syntactically invalid when used with an operation that sets headers in a + /// `fields`. + struct InvalidSyntax {}; + /// This error indicates that a forbidden `field-key` was used when trying + /// to set a header in a `fields`. + struct Forbidden {}; + /// This error indicates that the operation on the `fields` was not + /// permitted because the fields are immutable. + struct Immutable {}; + std::variant variants; + }; + /// Field keys are always strings. + using FieldKey = wit::string; + class Fields : public wit::ResourceImportBase{ + + public: + + ~Fields(); + /// Construct an empty HTTP Fields. + /// + /// The resulting `fields` is mutable. + Fields(); + /// Construct an HTTP Fields. + /// + /// The resulting `fields` is mutable. + /// + /// The list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + /// + /// The tuple is a pair of the field key, represented as a string, and + /// Value, represented as a list of bytes. In a valid Fields, all keys + /// and values are valid UTF-8 strings. However, values are not always + /// well-formed, so they are represented as a raw list of bytes. + /// + /// An error result will be returned if any header or value was + /// syntactically invalid, or if a header was forbidden. + static std::expected FromList(std::span> const> entries); + /// Get all of the values corresponding to a key. If the key is not present + /// in this `fields`, an empty list is returned. However, if the key is + /// present but empty, this is represented by a list with one or more + /// empty field-values present. + wit::vector> Get(std::string_view name) const; + /// Returns `true` when the key is present in this `fields`. If the key is + /// syntactically invalid, `false` is returned. + bool Has(std::string_view name) const; + /// Set all of the values for a key. Clears any existing values for that + /// key, if they have been set. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + std::expected Set(std::string_view name, std::span const> value) const; + /// Delete all values for a key. Does nothing if no values for the key + /// exist. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + std::expected Delete(std::string_view name) const; + /// Append a value for a key. Does not change or delete any existing + /// values for that key. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + std::expected Append(std::string_view name, std::span value) const; + /// Retrieve the full set of keys and values in the Fields. Like the + /// constructor, the list represents each key-value pair. + /// + /// The outer list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + wit::vector>> Entries() const; + /// Make a deep copy of the Fields. Equivelant in behavior to calling the + /// `fields` constructor on the return value of `entries`. The resulting + /// `fields` is mutable. + Fields Clone() const; + Fields(wit::ResourceImportBase &&); + Fields(Fields&&) = default; + Fields& operator=(Fields&&) = default; + }; + + /// Headers is an alias for Fields. + using Headers = Fields; + /// Trailers is an alias for Fields. + using Trailers = Fields; + class FutureTrailers : public wit::ResourceImportBase{ + + public: + + ~FutureTrailers(); + /// Returns a pollable which becomes ready when either the trailers have + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + io0_2_0::poll::Pollable Subscribe() const; + /// Returns the contents of the trailers, or an error which occured, + /// once the future is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the trailers or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the HTTP Request or Response + /// body, as well as any trailers, were received successfully, or that an + /// error occured receiving them. The optional `trailers` indicates whether + /// or not trailers were present in the body. + /// + /// When some `trailers` are returned by this method, the `trailers` + /// resource is immutable, and a child. Use of the `set`, `append`, or + /// `delete` methods will return an error, and the resource must be + /// dropped before the parent `future-trailers` is dropped. + std::optional, ErrorCode>, wit::Void>> Get() const; + FutureTrailers(wit::ResourceImportBase &&); + FutureTrailers(FutureTrailers&&) = default; + FutureTrailers& operator=(FutureTrailers&&) = default; + }; + + class IncomingBody : public wit::ResourceImportBase{ + + public: + + ~IncomingBody(); + /// Returns the contents of the body, as a stream of bytes. + /// + /// Returns success on first call: the stream representing the contents + /// can be retrieved at most once. Subsequent calls will return error. + /// + /// The returned `input-stream` resource is a child: it must be dropped + /// before the parent `incoming-body` is dropped, or consumed by + /// `incoming-body.finish`. + /// + /// This invariant ensures that the implementation can determine whether + /// the user is consuming the contents of the body, waiting on the + /// `future-trailers` to be ready, or neither. This allows for network + /// backpressure is to be applied when the user is consuming the body, + /// and for that backpressure to not inhibit delivery of the trailers if + /// the user does not read the entire body. + std::expected Stream() const; + /// Takes ownership of `incoming-body`, and returns a `future-trailers`. + /// This function will trap if the `input-stream` child is still alive. + static FutureTrailers Finish(types::IncomingBody&& this_); + IncomingBody(wit::ResourceImportBase &&); + IncomingBody(IncomingBody&&) = default; + IncomingBody& operator=(IncomingBody&&) = default; + }; + + class IncomingRequest : public wit::ResourceImportBase{ + + public: + + ~IncomingRequest(); + /// Returns the method of the incoming request. + Method Method() const; + /// Returns the path with query parameters from the request, as a string. + std::optional PathWithQuery() const; + /// Returns the protocol scheme from the request. + std::optional Scheme() const; + /// Returns the authority from the request, if it was present. + std::optional Authority() const; + /// Get the `headers` associated with the request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// The `headers` returned are a child resource: it must be dropped before + /// the parent `incoming-request` is dropped. Dropping this + /// `incoming-request` before all children are dropped will trap. + Fields Headers() const; + /// Gives the `incoming-body` associated with this request. Will only + /// return success at most once, and subsequent calls will return error. + std::expected Consume() const; + IncomingRequest(wit::ResourceImportBase &&); + IncomingRequest(IncomingRequest&&) = default; + IncomingRequest& operator=(IncomingRequest&&) = default; + }; + + class OutgoingBody : public wit::ResourceImportBase{ + + public: + + ~OutgoingBody(); + /// Returns a stream for writing the body contents. + /// + /// The returned `output-stream` is a child resource: it must be dropped + /// before the parent `outgoing-body` resource is dropped (or finished), + /// otherwise the `outgoing-body` drop or `finish` will trap. + /// + /// Returns success on the first call: the `output-stream` resource for + /// this `outgoing-body` may be retrieved at most once. Subsequent calls + /// will return error. + std::expected Write() const; + /// Finalize an outgoing body, optionally providing trailers. This must be + /// called to signal that the response is complete. If the `outgoing-body` + /// is dropped without calling `outgoing-body.finalize`, the implementation + /// should treat the body as corrupted. + /// + /// Fails if the body's `outgoing-request` or `outgoing-response` was + /// constructed with a Content-Length header, and the contents written + /// to the body (via `write`) does not match the value given in the + /// Content-Length. + static std::expected Finish(types::OutgoingBody&& this_, std::optional trailers); + OutgoingBody(wit::ResourceImportBase &&); + OutgoingBody(OutgoingBody&&) = default; + OutgoingBody& operator=(OutgoingBody&&) = default; + }; + + class OutgoingRequest : public wit::ResourceImportBase{ + + public: + + ~OutgoingRequest(); + /// Construct a new `outgoing-request` with a default `method` of `GET`, and + /// `none` values for `path-with-query`, `scheme`, and `authority`. + /// + /// * `headers` is the HTTP Headers for the Request. + /// + /// It is possible to construct, or manipulate with the accessor functions + /// below, an `outgoing-request` with an invalid combination of `scheme` + /// and `authority`, or `headers` which are not permitted to be sent. + /// It is the obligation of the `outgoing-handler.handle` implementation + /// to reject invalid constructions of `outgoing-request`. + OutgoingRequest(types::Fields&& headers); + /// Returns the resource corresponding to the outgoing Body for this + /// Request. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-request` can be retrieved at most once. Subsequent + /// calls will return error. + std::expected Body() const; + /// Get the Method for the Request. + Method Method() const; + /// Set the Method for the Request. Fails if the string present in a + /// `method.other` argument is not a syntactically valid method. + std::expected SetMethod(types::Method method) const; + /// Get the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. + std::optional PathWithQuery() const; + /// Set the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. Fails is the + /// string given is not a syntactically valid path and query uri component. + std::expected SetPathWithQuery(std::optional path_with_query) const; + /// Get the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. + std::optional Scheme() const; + /// Set the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. Fails if the + /// string given is not a syntactically valid uri scheme. + std::expected SetScheme(std::optional scheme) const; + /// Get the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. + std::optional Authority() const; + /// Set the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. Fails if the string given is + /// not a syntactically valid uri authority. + std::expected SetAuthority(std::optional authority) const; + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + Fields Headers() const; + OutgoingRequest(wit::ResourceImportBase &&); + OutgoingRequest(OutgoingRequest&&) = default; + OutgoingRequest& operator=(OutgoingRequest&&) = default; + }; + + class RequestOptions : public wit::ResourceImportBase{ + + public: + + ~RequestOptions(); + /// Construct a default `request-options` value. + RequestOptions(); + /// The timeout for the initial connect to the HTTP Server. + std::optional ConnectTimeout() const; + /// Set the timeout for the initial connect to the HTTP Server. An error + /// return value indicates that this timeout is not supported. + std::expected SetConnectTimeout(std::optional duration) const; + /// The timeout for receiving the first byte of the Response body. + std::optional FirstByteTimeout() const; + /// Set the timeout for receiving the first byte of the Response body. An + /// error return value indicates that this timeout is not supported. + std::expected SetFirstByteTimeout(std::optional duration) const; + /// The timeout for receiving subsequent chunks of bytes in the Response + /// body stream. + std::optional BetweenBytesTimeout() const; + /// Set the timeout for receiving subsequent chunks of bytes in the Response + /// body stream. An error return value indicates that this timeout is not + /// supported. + std::expected SetBetweenBytesTimeout(std::optional duration) const; + RequestOptions(wit::ResourceImportBase &&); + RequestOptions(RequestOptions&&) = default; + RequestOptions& operator=(RequestOptions&&) = default; + }; + + /// This type corresponds to the HTTP standard Status Code. + using StatusCode = uint16_t; + class OutgoingResponse : public wit::ResourceImportBase{ + + public: + + ~OutgoingResponse(); + /// Construct an `outgoing-response`, with a default `status-code` of `200`. + /// If a different `status-code` is needed, it must be set via the + /// `set-status-code` method. + /// + /// * `headers` is the HTTP Headers for the Response. + OutgoingResponse(types::Fields&& headers); + /// Get the HTTP Status Code for the Response. + uint16_t StatusCode() const; + /// Set the HTTP Status Code for the Response. Fails if the status-code + /// given is not a valid http status code. + std::expected SetStatusCode(uint16_t status_code) const; + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + Fields Headers() const; + /// Returns the resource corresponding to the outgoing Body for this Response. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-response` can be retrieved at most once. Subsequent + /// calls will return error. + std::expected Body() const; + OutgoingResponse(wit::ResourceImportBase &&); + OutgoingResponse(OutgoingResponse&&) = default; + OutgoingResponse& operator=(OutgoingResponse&&) = default; + }; + + class ResponseOutparam : public wit::ResourceImportBase{ + + public: + + ~ResponseOutparam(); + /// Set the value of the `response-outparam` to either send a response, + /// or indicate an error. + /// + /// This method consumes the `response-outparam` to ensure that it is + /// called at most once. If it is never called, the implementation + /// will respond with an error. + /// + /// The user may provide an `error` to `response` to allow the + /// implementation determine how to respond with an HTTP error response. + static void Set(types::ResponseOutparam&& param, std::expected response); + ResponseOutparam(wit::ResourceImportBase &&); + ResponseOutparam(ResponseOutparam&&) = default; + ResponseOutparam& operator=(ResponseOutparam&&) = default; + }; + + class IncomingResponse : public wit::ResourceImportBase{ + + public: + + ~IncomingResponse(); + /// Returns the status code from the incoming response. + uint16_t Status() const; + /// Returns the headers from the incoming response. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `incoming-response` is dropped. + Fields Headers() const; + /// Returns the incoming body. May be called at most once. Returns error + /// if called additional times. + std::expected Consume() const; + IncomingResponse(wit::ResourceImportBase &&); + IncomingResponse(IncomingResponse&&) = default; + IncomingResponse& operator=(IncomingResponse&&) = default; + }; + + class FutureIncomingResponse : public wit::ResourceImportBase{ + + public: + + ~FutureIncomingResponse(); + /// Returns a pollable which becomes ready when either the Response has + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + io0_2_0::poll::Pollable Subscribe() const; + /// Returns the incoming HTTP Response, or an error, once one is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the response or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the incoming HTTP Response + /// status and headers have recieved successfully, or that an error + /// occured. Errors may also occur while consuming the response body, + /// but those will be reported by the `incoming-body` and its + /// `output-stream` child. + std::optional, wit::Void>> Get() const; + FutureIncomingResponse(wit::ResourceImportBase &&); + FutureIncomingResponse(FutureIncomingResponse&&) = default; + FutureIncomingResponse& operator=(FutureIncomingResponse&&) = default; + }; + + /// Attempts to extract a http-related `error` from the wasi:io `error` + /// provided. + /// + /// Stream operations which return + /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of + /// type `wasi:io/error/error` with more information about the operation + /// that failed. This payload can be passed through to this function to see + /// if there's http-related information about the error to return. + /// + /// Note that this function is fallible because not all io-errors are + /// http-related errors. + std::optional HttpErrorCode(std::reference_wrapper err_); + } + /// This interface defines a handler of outgoing HTTP Requests. It should be + /// imported by components which wish to make HTTP Requests. + namespace outgoing_handler { + using OutgoingRequest = types::OutgoingRequest; + using RequestOptions = types::RequestOptions; + using FutureIncomingResponse = types::FutureIncomingResponse; + using ErrorCode = types::ErrorCode; + /// This function is invoked with an outgoing HTTP Request, and it returns + /// a resource `future-incoming-response` which represents an HTTP Response + /// which may arrive in the future. + /// + /// The `options` argument accepts optional parameters for the HTTP + /// protocol's transport layer. + /// + /// This function may return an error if the `outgoing-request` is invalid + /// or not allowed to be made. Otherwise, protocol errors are reported + /// through the `future-incoming-response`. + std::expected Handle(types::OutgoingRequest&& request, std::optional options); + } + } +} +/// A WASI interface dedicated to performing inferencing for Large Language Models. +namespace fermyon { + namespace spin2_0_0 { + namespace llm { + /// A Large Language Model. + using InferencingModel = wit::string; + /// Inference request parameters + struct InferencingParams { + /// The maximum tokens that should be inferred. + /// + /// Note: the backing implementation may return less tokens. + uint32_t max_tokens; + /// The amount the model should avoid repeating tokens. + float repeat_penalty; + /// The number of tokens the model should apply the repeat penalty to. + uint32_t repeat_penalty_last_n_token_count; + /// The randomness with which the next token is selected. + float temperature; + /// The number of possible next tokens the model will choose from. + uint32_t top_k; + /// The probability total of next tokens the model will choose from. + float top_p; + }; + /// The set of errors which may be raised by functions in this interface + struct Error { + struct ModelNotSupported {}; + struct RuntimeError { wit::string value; }; + struct InvalidInput { wit::string value; }; + std::variant variants; + }; + /// Usage information related to the inferencing result + struct InferencingUsage { + /// Number of tokens in the prompt + uint32_t prompt_token_count; + /// Number of tokens generated by the inferencing operation + uint32_t generated_token_count; + }; + /// An inferencing result + struct InferencingResult { + /// The text generated by the model + /// TODO: this should be a stream + wit::string text; + /// Usage information about the inferencing request + InferencingUsage usage; + }; + /// The model used for generating embeddings + using EmbeddingModel = wit::string; + /// Usage related to an embeddings generation request + struct EmbeddingsUsage { + /// Number of tokens in the prompt + uint32_t prompt_token_count; + }; + /// Result of generating embeddings + struct EmbeddingsResult { + /// The embeddings generated by the request + wit::vector> embeddings; + /// Usage related to the embeddings generation request + EmbeddingsUsage usage; + }; + /// Perform inferencing using the provided model and prompt with the given optional params + std::expected Infer(std::string_view model, std::string_view prompt, std::optional params); + /// Generate embeddings for the supplied list of text + std::expected GenerateEmbeddings(std::string_view model, std::span text); + } + namespace redis { + /// Errors related to interacting with Redis + struct Error { + /// An invalid address string + struct InvalidAddress {}; + /// There are too many open connections + struct TooManyConnections {}; + /// A retrieved value was not of the correct type + struct TypeError {}; + /// Some other error occurred + struct Other { wit::string value; }; + std::variant variants; + }; + /// A parameter type for the general-purpose `execute` function. + struct RedisParameter { + struct Int64 { int64_t value; }; + struct Binary { wit::vector value; }; + std::variant variants; + }; + /// A return type for the general-purpose `execute` function. + struct RedisResult { + struct Nil {}; + struct Status { wit::string value; }; + struct Int64 { int64_t value; }; + struct Binary { wit::vector value; }; + std::variant variants; + }; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the Redis instance at `address`. + static std::expected Open(std::string_view address); + /// Publish a Redis message to the specified channel. + std::expected Publish(std::string_view channel, std::span payload) const; + /// Get the value of a key. + std::expected>, Error> Get(std::string_view key) const; + /// Set key to value. + /// + /// If key already holds a value, it is overwritten. + std::expected Set(std::string_view key, std::span value) const; + /// Increments the number stored at key by one. + /// + /// If the key does not exist, it is set to 0 before performing the operation. + /// An `error::type-error` is returned if the key contains a value of the wrong type + /// or contains a string that can not be represented as integer. + std::expected Incr(std::string_view key) const; + /// Removes the specified keys. + /// + /// A key is ignored if it does not exist. Returns the number of keys deleted. + std::expected Del(std::span keys) const; + /// Add the specified `values` to the set named `key`, returning the number of newly-added values. + std::expected Sadd(std::string_view key, std::span values) const; + /// Retrieve the contents of the set named `key`. + std::expected, Error> Smembers(std::string_view key) const; + /// Remove the specified `values` from the set named `key`, returning the number of newly-removed values. + std::expected Srem(std::string_view key, std::span values) const; + /// Execute an arbitrary Redis command and receive the result. + std::expected, Error> Execute(std::string_view command, std::span arguments) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + namespace mqtt { + /// Errors related to interacting with Mqtt + struct Error { + /// An invalid address string + struct InvalidAddress {}; + /// There are too many open connections + struct TooManyConnections {}; + /// Connection failure e.g. address not allowed. + struct ConnectionFailed { wit::string value; }; + /// Some other error occurred + struct Other { wit::string value; }; + std::variant variants; + }; + /// QoS for publishing Mqtt messages + enum class Qos : uint8_t { + kAtMostOnce = 0, + kAtLeastOnce = 1, + kExactlyOnce = 2, + }; + + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the Mqtt instance at `address`. + static std::expected Open(std::string_view address, std::string_view username, std::string_view password, uint64_t keep_alive_interval_in_secs); + /// Publish an Mqtt message to the specified `topic`. + std::expected Publish(std::string_view topic, std::span payload, mqtt::Qos qos) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + namespace rdbms_types { + /// Errors related to interacting with a database. + struct Error { + struct ConnectionFailed { wit::string value; }; + struct BadParameter { wit::string value; }; + struct QueryFailed { wit::string value; }; + struct ValueConversionFailed { wit::string value; }; + struct Other { wit::string value; }; + std::variant variants; + }; + /// Data types for a database column + enum class DbDataType : uint8_t { + kBoolean = 0, + kInt8 = 1, + kInt16 = 2, + kInt32 = 3, + kInt64 = 4, + kUint8 = 5, + kUint16 = 6, + kUint32 = 7, + kUint64 = 8, + kFloating32 = 9, + kFloating64 = 10, + kStr = 11, + kBinary = 12, + kOther = 13, + }; + + /// Database values + struct DbValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Uint8 { uint8_t value; }; + struct Uint16 { uint16_t value; }; + struct Uint32 { uint32_t value; }; + struct Uint64 { uint64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct DbNull {}; + struct Unsupported {}; + std::variant variants; + }; + /// Values used in parameterized queries + struct ParameterValue { + struct Boolean { bool value; }; + struct Int8 { int8_t value; }; + struct Int16 { int16_t value; }; + struct Int32 { int32_t value; }; + struct Int64 { int64_t value; }; + struct Uint8 { uint8_t value; }; + struct Uint16 { uint16_t value; }; + struct Uint32 { uint32_t value; }; + struct Uint64 { uint64_t value; }; + struct Floating32 { float value; }; + struct Floating64 { double value; }; + struct Str { wit::string value; }; + struct Binary { wit::vector value; }; + struct DbNull {}; + std::variant variants; + }; + /// A database column + struct Column { + wit::string name; + DbDataType data_type; + }; + /// A set of database rows + struct RowSet { + wit::vector columns; + wit::vector> rows; + }; + } + namespace postgres { + using ParameterValue = rdbms_types::ParameterValue; + using RowSet = rdbms_types::RowSet; + using Error = rdbms_types::Error; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the Postgres instance at `address`. + static std::expected Open(std::string_view address); + /// Query the database. + std::expected Query(std::string_view statement, std::span params) const; + /// Execute command to the database. + std::expected Execute(std::string_view statement, std::span params) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + namespace mysql { + using ParameterValue = rdbms_types::ParameterValue; + using RowSet = rdbms_types::RowSet; + using Error = rdbms_types::Error; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to the MySQL instance at `address`. + static std::expected Open(std::string_view address); + /// query the database: select + std::expected Query(std::string_view statement, std::span params) const; + /// execute command to the database: insert, update, delete + std::expected Execute(std::string_view statement, std::span params) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + namespace sqlite { + /// The set of errors which may be raised by functions in this interface + struct Error { + /// The host does not recognize the database name requested. + struct NoSuchDatabase {}; + /// The requesting component does not have access to the specified database (which may or may not exist). + struct AccessDenied {}; + /// The provided connection is not valid + struct InvalidConnection {}; + /// The database has reached its capacity + struct DatabaseFull {}; + /// Some implementation-specific error has occurred (e.g. I/O) + struct Io { wit::string value; }; + std::variant variants; + }; + /// A single column's result from a database query + struct Value { + struct Integer { int64_t value; }; + struct Real { double value; }; + struct Text { wit::string value; }; + struct Blob { wit::vector value; }; + struct Null {}; + std::variant variants; + }; + /// A set of values for each of the columns in a query-result + struct RowResult { + wit::vector values; + }; + /// A result of a query + struct QueryResult { + /// The names of the columns retrieved in the query + wit::vector columns; + /// the row results each containing the values for all the columns for a given row + wit::vector rows; + }; + class Connection : public wit::ResourceImportBase{ + + public: + + ~Connection(); + /// Open a connection to a named database instance. + /// + /// If `database` is "default", the default instance is opened. + /// + /// `error::no-such-database` will be raised if the `name` is not recognized. + static std::expected Open(std::string_view database); + /// Execute a statement returning back data if there is any + std::expected Execute(std::string_view statement, std::span parameters) const; + Connection(wit::ResourceImportBase &&); + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + }; + + } + namespace key_value { + /// The set of errors which may be raised by functions in this interface + struct Error { + /// Too many stores have been opened simultaneously. Closing one or more + /// stores prior to retrying may address this. + struct StoreTableFull {}; + /// The host does not recognize the store label requested. + struct NoSuchStore {}; + /// The requesting component does not have access to the specified store + /// (which may or may not exist). + struct AccessDenied {}; + /// Some implementation-specific error has occurred (e.g. I/O) + struct Other { wit::string value; }; + std::variant variants; + }; + class Store : public wit::ResourceImportBase{ + + public: + + ~Store(); + /// Open the store with the specified label. + /// + /// `label` must refer to a store allowed in the spin.toml manifest. + /// + /// `error::no-such-store` will be raised if the `label` is not recognized. + static std::expected Open(std::string_view label); + /// Get the value associated with the specified `key` + /// + /// Returns `ok(none)` if the key does not exist. + std::expected>, Error> Get(std::string_view key) const; + /// Set the `value` associated with the specified `key` overwriting any existing value. + std::expected Set(std::string_view key, std::span value) const; + /// Delete the tuple with the specified `key` + /// + /// No error is raised if a tuple did not previously exist for `key`. + std::expected Delete(std::string_view key) const; + /// Return whether a tuple exists for the specified `key` + std::expected Exists(std::string_view key) const; + /// Return a list of all the keys + std::expected, Error> GetKeys() const; + Store(wit::ResourceImportBase &&); + Store(Store&&) = default; + Store& operator=(Store&&) = default; + }; + + } + namespace variables { + /// The set of errors which may be raised by functions in this interface. + struct Error { + /// The provided variable name is invalid. + struct InvalidName { wit::string value; }; + /// The provided variable is undefined. + struct Undefined { wit::string value; }; + /// A variables provider specific error has occurred. + struct Provider { wit::string value; }; + /// Some implementation-specific error has occurred. + struct Other { wit::string value; }; + std::variant variants; + }; + /// Get an application variable value for the current component. + /// + /// The name must match one defined in in the component manifest. + std::expected Get(std::string_view name); + } + } +} +namespace wasi { + namespace cli0_2_0 { + namespace environment { + /// Get the POSIX-style environment variables. + /// + /// Each environment variable is provided as a pair of string variable names + /// and string value. + /// + /// Morally, these are a value import, but until value imports are available + /// in the component model, this import function should return the same + /// values each time it is called. + wit::vector> GetEnvironment(); + /// Get the POSIX-style arguments to the program. + wit::vector GetArguments(); + /// Return a path that programs should use as their initial current working + /// directory, interpreting `.` as shorthand for this. + std::optional InitialCwd(); + } + namespace exit { + /// Exit the current instance and any linked instances. + void Exit(std::expected status); + } + namespace stdin_ { + using InputStream = io0_2_0::streams::InputStream; + io0_2_0::streams::InputStream GetStdin(); + } + namespace stdout_ { + using OutputStream = io0_2_0::streams::OutputStream; + io0_2_0::streams::OutputStream GetStdout(); + } + namespace stderr_ { + using OutputStream = io0_2_0::streams::OutputStream; + io0_2_0::streams::OutputStream GetStderr(); + } + /// Terminal input. + /// + /// In the future, this may include functions for disabling echoing, + /// disabling input buffering so that keyboard events are sent through + /// immediately, querying supported features, and so on. + namespace terminal_input { + class TerminalInput : public wit::ResourceImportBase{ + + public: + + ~TerminalInput(); + TerminalInput(wit::ResourceImportBase &&); + TerminalInput(TerminalInput&&) = default; + TerminalInput& operator=(TerminalInput&&) = default; + }; + + } + /// Terminal output. + /// + /// In the future, this may include functions for querying the terminal + /// size, being notified of terminal size changes, querying supported + /// features, and so on. + namespace terminal_output { + class TerminalOutput : public wit::ResourceImportBase{ + + public: + + ~TerminalOutput(); + TerminalOutput(wit::ResourceImportBase &&); + TerminalOutput(TerminalOutput&&) = default; + TerminalOutput& operator=(TerminalOutput&&) = default; + }; + + } + /// An interface providing an optional `terminal-input` for stdin as a + /// link-time authority. + namespace terminal_stdin { + using TerminalInput = terminal_input::TerminalInput; + /// If stdin is connected to a terminal, return a `terminal-input` handle + /// allowing further interaction with it. + std::optional GetTerminalStdin(); + } + /// An interface providing an optional `terminal-output` for stdout as a + /// link-time authority. + namespace terminal_stdout { + using TerminalOutput = terminal_output::TerminalOutput; + /// If stdout is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + std::optional GetTerminalStdout(); + } + /// An interface providing an optional `terminal-output` for stderr as a + /// link-time authority. + namespace terminal_stderr { + using TerminalOutput = terminal_output::TerminalOutput; + /// If stderr is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + std::optional GetTerminalStderr(); + } + } + /// WASI Wall Clock is a clock API intended to let users query the current + /// time. The name "wall" makes an analogy to a "clock on the wall", which + /// is not necessarily monotonic as it may be reset. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + /// + /// A wall clock is a clock which measures the date and time according to + /// some external reference. + /// + /// External references may be reset, so this clock is not necessarily + /// monotonic, making it unsuitable for measuring elapsed time. + /// + /// It is intended for reporting the current date and time for humans. + namespace clocks0_2_0 { + namespace wall_clock { + /// A time and date in seconds plus nanoseconds. + struct Datetime { + uint64_t seconds; + uint32_t nanoseconds; + }; + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The returned timestamps represent the number of seconds since + /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], + /// also known as [Unix Time]. + /// + /// The nanoseconds field of the output is always less than 1000000000. + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + Datetime Now(); + /// Query the resolution of the clock. + /// + /// The nanoseconds field of the output is always less than 1000000000. + Datetime Resolution(); + } + } + /// WASI filesystem is a filesystem API primarily intended to let users run WASI + /// programs that access their files on their existing filesystems, without + /// significant overhead. + /// + /// It is intended to be roughly portable between Unix-family platforms and + /// Windows, though it does not hide many of the major differences. + /// + /// Paths are passed as interface-type `string`s, meaning they must consist of + /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain + /// paths which are not accessible by this API. + /// + /// The directory separator in WASI is always the forward-slash (`/`). + /// + /// All paths in WASI are relative paths, and are interpreted relative to a + /// `descriptor` referring to a base directory. If a `path` argument to any WASI + /// function starts with `/`, or if any step of resolving a `path`, including + /// `..` and symbolic link steps, reaches a directory outside of the base + /// directory, or reaches a symlink to an absolute or rooted path in the + /// underlying filesystem, the function fails with `error-code::not-permitted`. + /// + /// For more information about WASI path resolution and sandboxing, see + /// [WASI filesystem path resolution]. + /// + /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md + namespace filesystem0_2_0 { + namespace types { + using InputStream = io0_2_0::streams::InputStream; + using OutputStream = io0_2_0::streams::OutputStream; + using Error = io0_2_0::error::Error; + using Datetime = clocks0_2_0::wall_clock::Datetime; + /// File size or length of a region within a file. + using Filesize = uint64_t; + /// The type of a filesystem object referenced by a descriptor. + /// + /// Note: This was called `filetype` in earlier versions of WASI. + enum class DescriptorType : uint8_t { + /// The type of the descriptor or file is unknown or is different from + /// any of the other types specified. + kUnknown = 0, + /// The descriptor refers to a block device inode. + kBlockDevice = 1, + /// The descriptor refers to a character device inode. + kCharacterDevice = 2, + /// The descriptor refers to a directory inode. + kDirectory = 3, + /// The descriptor refers to a named pipe. + kFifo = 4, + /// The file refers to a symbolic link inode. + kSymbolicLink = 5, + /// The descriptor refers to a regular file inode. + kRegularFile = 6, + /// The descriptor refers to a socket. + kSocket = 7, + }; + + /// Descriptor flags. + /// + /// Note: This was called `fdflags` in earlier versions of WASI. + enum class DescriptorFlags : uint8_t { + k_None = 0, + /// Read mode: Data can be read. + kRead = (1ULL<<0), + /// Write mode: Data can be written to. + kWrite = (1ULL<<1), + /// Request that writes be performed according to synchronized I/O file + /// integrity completion. The data stored in the file and the file's + /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + kFileIntegritySync = (1ULL<<2), + /// Request that writes be performed according to synchronized I/O data + /// integrity completion. Only the data stored in the file is + /// synchronized. This is similar to `O_DSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + kDataIntegritySync = (1ULL<<3), + /// Requests that reads be performed at the same level of integrety + /// requested for writes. This is similar to `O_RSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + kRequestedWriteSync = (1ULL<<4), + /// Mutating directories mode: Directory contents may be mutated. + /// + /// When this flag is unset on a descriptor, operations using the + /// descriptor which would create, rename, delete, modify the data or + /// metadata of filesystem objects, or obtain another handle which + /// would permit any of those, shall fail with `error-code::read-only` if + /// they would otherwise succeed. + /// + /// This may only be set on directories. + kMutateDirectory = (1ULL<<5), + }; + static inline DescriptorFlags operator|(DescriptorFlags a, DescriptorFlags b) { return DescriptorFlags(uint8_t(a)|uint8_t(b)); } + static inline DescriptorFlags operator&(DescriptorFlags a, DescriptorFlags b) { return DescriptorFlags(uint8_t(a)&uint8_t(b)); } + /// Flags determining the method of how paths are resolved. + enum class PathFlags : uint8_t { + k_None = 0, + /// As long as the resolved path corresponds to a symbolic link, it is + /// expanded. + kSymlinkFollow = (1ULL<<0), + }; + static inline PathFlags operator|(PathFlags a, PathFlags b) { return PathFlags(uint8_t(a)|uint8_t(b)); } + static inline PathFlags operator&(PathFlags a, PathFlags b) { return PathFlags(uint8_t(a)&uint8_t(b)); } + /// Open flags used by `open-at`. + enum class OpenFlags : uint8_t { + k_None = 0, + /// Create file if it does not exist, similar to `O_CREAT` in POSIX. + kCreate = (1ULL<<0), + /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. + kDirectory = (1ULL<<1), + /// Fail if file already exists, similar to `O_EXCL` in POSIX. + kExclusive = (1ULL<<2), + /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. + kTruncate = (1ULL<<3), + }; + static inline OpenFlags operator|(OpenFlags a, OpenFlags b) { return OpenFlags(uint8_t(a)|uint8_t(b)); } + static inline OpenFlags operator&(OpenFlags a, OpenFlags b) { return OpenFlags(uint8_t(a)&uint8_t(b)); } + /// Number of hard links to an inode. + using LinkCount = uint64_t; + /// File attributes. + /// + /// Note: This was called `filestat` in earlier versions of WASI. + struct DescriptorStat { + /// File type. + DescriptorType type; + /// Number of hard links to the file. + uint64_t link_count; + /// For regular files, the file size in bytes. For symbolic links, the + /// length in bytes of the pathname contained in the symbolic link. + uint64_t size; + /// Last data access timestamp. + /// + /// If the `option` is none, the platform doesn't maintain an access + /// timestamp for this file. + std::optional data_access_timestamp; + /// Last data modification timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// modification timestamp for this file. + std::optional data_modification_timestamp; + /// Last file status-change timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// status-change timestamp for this file. + std::optional status_change_timestamp; + }; + /// When setting a timestamp, this gives the value to set it to. + struct NewTimestamp { + /// Leave the timestamp set to its previous value. + struct NoChange {}; + /// Set the timestamp to the current time of the system clock associated + /// with the filesystem. + struct Now {}; + /// Set the timestamp to the given value. + struct Timestamp { clocks0_2_0::wall_clock::Datetime value; }; + std::variant variants; + }; + /// A directory entry. + struct DirectoryEntry { + /// The type of the file referred to by this directory entry. + DescriptorType type; + /// The name of the object. + wit::string name; + }; + /// Error codes returned by functions, similar to `errno` in POSIX. + /// Not all of these error codes are returned by the functions provided by this + /// API; some are used in higher-level library layers, and others are provided + /// merely for alignment with POSIX. + enum class ErrorCode : uint8_t { + /// Permission denied, similar to `EACCES` in POSIX. + kAccess = 0, + /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. + kWouldBlock = 1, + /// Connection already in progress, similar to `EALREADY` in POSIX. + kAlready = 2, + /// Bad descriptor, similar to `EBADF` in POSIX. + kBadDescriptor = 3, + /// Device or resource busy, similar to `EBUSY` in POSIX. + kBusy = 4, + /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. + kDeadlock = 5, + /// Storage quota exceeded, similar to `EDQUOT` in POSIX. + kQuota = 6, + /// File exists, similar to `EEXIST` in POSIX. + kExist = 7, + /// File too large, similar to `EFBIG` in POSIX. + kFileTooLarge = 8, + /// Illegal byte sequence, similar to `EILSEQ` in POSIX. + kIllegalByteSequence = 9, + /// Operation in progress, similar to `EINPROGRESS` in POSIX. + kInProgress = 10, + /// Interrupted function, similar to `EINTR` in POSIX. + kInterrupted = 11, + /// Invalid argument, similar to `EINVAL` in POSIX. + kInvalid = 12, + /// I/O error, similar to `EIO` in POSIX. + kIo = 13, + /// Is a directory, similar to `EISDIR` in POSIX. + kIsDirectory = 14, + /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. + kLoop = 15, + /// Too many links, similar to `EMLINK` in POSIX. + kTooManyLinks = 16, + /// Message too large, similar to `EMSGSIZE` in POSIX. + kMessageSize = 17, + /// Filename too long, similar to `ENAMETOOLONG` in POSIX. + kNameTooLong = 18, + /// No such device, similar to `ENODEV` in POSIX. + kNoDevice = 19, + /// No such file or directory, similar to `ENOENT` in POSIX. + kNoEntry = 20, + /// No locks available, similar to `ENOLCK` in POSIX. + kNoLock = 21, + /// Not enough space, similar to `ENOMEM` in POSIX. + kInsufficientMemory = 22, + /// No space left on device, similar to `ENOSPC` in POSIX. + kInsufficientSpace = 23, + /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. + kNotDirectory = 24, + /// Directory not empty, similar to `ENOTEMPTY` in POSIX. + kNotEmpty = 25, + /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. + kNotRecoverable = 26, + /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. + kUnsupported = 27, + /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. + kNoTty = 28, + /// No such device or address, similar to `ENXIO` in POSIX. + kNoSuchDevice = 29, + /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. + kOverflow = 30, + /// Operation not permitted, similar to `EPERM` in POSIX. + kNotPermitted = 31, + /// Broken pipe, similar to `EPIPE` in POSIX. + kPipe = 32, + /// Read-only file system, similar to `EROFS` in POSIX. + kReadOnly = 33, + /// Invalid seek, similar to `ESPIPE` in POSIX. + kInvalidSeek = 34, + /// Text file busy, similar to `ETXTBSY` in POSIX. + kTextFileBusy = 35, + /// Cross-device link, similar to `EXDEV` in POSIX. + kCrossDevice = 36, + }; + + /// File or memory access pattern advisory information. + enum class Advice : uint8_t { + /// The application has no advice to give on its behavior with respect + /// to the specified data. + kNormal = 0, + /// The application expects to access the specified data sequentially + /// from lower offsets to higher offsets. + kSequential = 1, + /// The application expects to access the specified data in a random + /// order. + kRandom = 2, + /// The application expects to access the specified data in the near + /// future. + kWillNeed = 3, + /// The application expects that it will not access the specified data + /// in the near future. + kDontNeed = 4, + /// The application expects to access the specified data once and then + /// not reuse it thereafter. + kNoReuse = 5, + }; + + /// A 128-bit hash value, split into parts because wasm doesn't have a + /// 128-bit integer type. + struct MetadataHashValue { + /// 64 bits of a 128-bit hash value. + uint64_t lower; + /// Another 64 bits of a 128-bit hash value. + uint64_t upper; + }; + class DirectoryEntryStream : public wit::ResourceImportBase{ + + public: + + ~DirectoryEntryStream(); + /// Read a single directory entry from a `directory-entry-stream`. + std::expected, ErrorCode> ReadDirectoryEntry() const; + DirectoryEntryStream(wit::ResourceImportBase &&); + DirectoryEntryStream(DirectoryEntryStream&&) = default; + DirectoryEntryStream& operator=(DirectoryEntryStream&&) = default; + }; + + class Descriptor : public wit::ResourceImportBase{ + + public: + + ~Descriptor(); + /// Return a stream for reading from a file, if available. + /// + /// May fail with an error-code describing why the file cannot be read. + /// + /// Multiple read, write, and append streams may be active on the same open + /// file and they do not interfere with each other. + /// + /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. + std::expected ReadViaStream(uint64_t offset) const; + /// Return a stream for writing to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be written. + /// + /// Note: This allows using `write-stream`, which is similar to `write` in + /// POSIX. + std::expected WriteViaStream(uint64_t offset) const; + /// Return a stream for appending to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be appended. + /// + /// Note: This allows using `write-stream`, which is similar to `write` with + /// `O_APPEND` in in POSIX. + std::expected AppendViaStream() const; + /// Provide file advisory information on a descriptor. + /// + /// This is similar to `posix_fadvise` in POSIX. + std::expected Advise(uint64_t offset, uint64_t length, types::Advice advice) const; + /// Synchronize the data of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fdatasync` in POSIX. + std::expected SyncData() const; + /// Get flags associated with a descriptor. + /// + /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + /// + /// Note: This returns the value that was the `fs_flags` value returned + /// from `fdstat_get` in earlier versions of WASI. + std::expected GetFlags() const; + /// Get the dynamic type of a descriptor. + /// + /// Note: This returns the same value as the `type` field of the `fd-stat` + /// returned by `stat`, `stat-at` and similar. + /// + /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided + /// by `fstat` in POSIX. + /// + /// Note: This returns the value that was the `fs_filetype` value returned + /// from `fdstat_get` in earlier versions of WASI. + std::expected GetType() const; + /// Adjust the size of an open file. If this increases the file's size, the + /// extra bytes are filled with zeros. + /// + /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. + std::expected SetSize(uint64_t size) const; + /// Adjust the timestamps of an open file or directory. + /// + /// Note: This is similar to `futimens` in POSIX. + /// + /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. + std::expected SetTimes(types::NewTimestamp data_access_timestamp, types::NewTimestamp data_modification_timestamp) const; + /// Read from a descriptor, without using and updating the descriptor's offset. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool which, when true, indicates that the end of the + /// file was reached. The returned list will contain up to `length` bytes; it + /// may return fewer than requested, if the end of the file is reached or + /// if the I/O operation is interrupted. + /// + /// In the future, this may change to return a `stream`. + /// + /// Note: This is similar to `pread` in POSIX. + std::expected, bool>, ErrorCode> Read(uint64_t length, uint64_t offset) const; + /// Write to a descriptor, without using and updating the descriptor's offset. + /// + /// It is valid to write past the end of a file; the file is extended to the + /// extent of the write, with bytes between the previous end and the start of + /// the write set to zero. + /// + /// In the future, this may change to take a `stream`. + /// + /// Note: This is similar to `pwrite` in POSIX. + std::expected Write(std::span buffer, uint64_t offset) const; + /// Read directory entries from a directory. + /// + /// On filesystems where directories contain entries referring to themselves + /// and their parents, often named `.` and `..` respectively, these entries + /// are omitted. + /// + /// This always returns a new stream which starts at the beginning of the + /// directory. Multiple streams may be active on the same directory, and they + /// do not interfere with each other. + std::expected ReadDirectory() const; + /// Synchronize the data and metadata of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fsync` in POSIX. + std::expected Sync() const; + /// Create a directory. + /// + /// Note: This is similar to `mkdirat` in POSIX. + std::expected CreateDirectoryAt(std::string_view path) const; + /// Return the attributes of an open file or directory. + /// + /// Note: This is similar to `fstat` in POSIX, except that it does not return + /// device and inode information. For testing whether two descriptors refer to + /// the same underlying filesystem object, use `is-same-object`. To obtain + /// additional data that can be used do determine whether a file has been + /// modified, use `metadata-hash`. + /// + /// Note: This was called `fd_filestat_get` in earlier versions of WASI. + std::expected Stat() const; + /// Return the attributes of a file or directory. + /// + /// Note: This is similar to `fstatat` in POSIX, except that it does not + /// return device and inode information. See the `stat` description for a + /// discussion of alternatives. + /// + /// Note: This was called `path_filestat_get` in earlier versions of WASI. + std::expected StatAt(types::PathFlags path_flags, std::string_view path) const; + /// Adjust the timestamps of a file or directory. + /// + /// Note: This is similar to `utimensat` in POSIX. + /// + /// Note: This was called `path_filestat_set_times` in earlier versions of + /// WASI. + std::expected SetTimesAt(types::PathFlags path_flags, std::string_view path, types::NewTimestamp data_access_timestamp, types::NewTimestamp data_modification_timestamp) const; + /// Create a hard link. + /// + /// Note: This is similar to `linkat` in POSIX. + std::expected LinkAt(types::PathFlags old_path_flags, std::string_view old_path, std::reference_wrapper new_descriptor, std::string_view new_path) const; + /// Open a file or directory. + /// + /// The returned descriptor is not guaranteed to be the lowest-numbered + /// descriptor not currently open/ it is randomized to prevent applications + /// from depending on making assumptions about indexes, since this is + /// error-prone in multi-threaded contexts. The returned descriptor is + /// guaranteed to be less than 2**31. + /// + /// If `flags` contains `descriptor-flags::mutate-directory`, and the base + /// descriptor doesn't have `descriptor-flags::mutate-directory` set, + /// `open-at` fails with `error-code::read-only`. + /// + /// If `flags` contains `write` or `mutate-directory`, or `open-flags` + /// contains `truncate` or `create`, and the base descriptor doesn't have + /// `descriptor-flags::mutate-directory` set, `open-at` fails with + /// `error-code::read-only`. + /// + /// Note: This is similar to `openat` in POSIX. + std::expected OpenAt(types::PathFlags path_flags, std::string_view path, types::OpenFlags open_flags, types::DescriptorFlags flags) const; + /// Read the contents of a symbolic link. + /// + /// If the contents contain an absolute or rooted path in the underlying + /// filesystem, this function fails with `error-code::not-permitted`. + /// + /// Note: This is similar to `readlinkat` in POSIX. + std::expected ReadlinkAt(std::string_view path) const; + /// Remove a directory. + /// + /// Return `error-code::not-empty` if the directory is not empty. + /// + /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. + std::expected RemoveDirectoryAt(std::string_view path) const; + /// Rename a filesystem object. + /// + /// Note: This is similar to `renameat` in POSIX. + std::expected RenameAt(std::string_view old_path, std::reference_wrapper new_descriptor, std::string_view new_path) const; + /// Create a symbolic link (also known as a "symlink"). + /// + /// If `old-path` starts with `/`, the function fails with + /// `error-code::not-permitted`. + /// + /// Note: This is similar to `symlinkat` in POSIX. + std::expected SymlinkAt(std::string_view old_path, std::string_view new_path) const; + /// Unlink a filesystem object that is not a directory. + /// + /// Return `error-code::is-directory` if the path refers to a directory. + /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. + std::expected UnlinkFileAt(std::string_view path) const; + /// Test whether two descriptors refer to the same filesystem object. + /// + /// In POSIX, this corresponds to testing whether the two descriptors have the + /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. + /// wasi-filesystem does not expose device and inode numbers, so this function + /// may be used instead. + bool IsSameObject(std::reference_wrapper other) const; + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a descriptor. + /// + /// This returns a hash of the last-modification timestamp and file size, and + /// may also include the inode number, device number, birth timestamp, and + /// other metadata fields that may change when the file is modified or + /// replaced. It may also include a secret value chosen by the + /// implementation and not otherwise exposed. + /// + /// Implementations are encourated to provide the following properties: + /// + /// - If the file is not modified or replaced, the computed hash value should + /// usually not change. + /// - If the object is modified or replaced, the computed hash value should + /// usually change. + /// - The inputs to the hash should not be easily computable from the + /// computed hash. + /// + /// However, none of these is required. + std::expected MetadataHash() const; + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a directory descriptor and a relative path. + /// + /// This performs the same hash computation as `metadata-hash`. + std::expected MetadataHashAt(types::PathFlags path_flags, std::string_view path) const; + Descriptor(wit::ResourceImportBase &&); + Descriptor(Descriptor&&) = default; + Descriptor& operator=(Descriptor&&) = default; + }; + + /// Attempts to extract a filesystem-related `error-code` from the stream + /// `error` provided. + /// + /// Stream operations which return `stream-error::last-operation-failed` + /// have a payload with more information about the operation that failed. + /// This payload can be passed through to this function to see if there's + /// filesystem-related information about the error to return. + /// + /// Note that this function is fallible because not all stream-related + /// errors are filesystem-related errors. + std::optional FilesystemErrorCode(std::reference_wrapper err_); + } + namespace preopens { + using Descriptor = types::Descriptor; + /// Return the set of preopened directories, and their path. + wit::vector> GetDirectories(); + } + } + namespace sockets0_2_0 { + namespace network { + class Network : public wit::ResourceImportBase{ + + public: + + ~Network(); + Network(wit::ResourceImportBase &&); + Network(Network&&) = default; + Network& operator=(Network&&) = default; + }; + + /// Error codes. + /// + /// In theory, every API can return any error code. + /// In practice, API's typically only return the errors documented per API + /// combined with a couple of errors that are always possible: + /// - `unknown` + /// - `access-denied` + /// - `not-supported` + /// - `out-of-memory` + /// - `concurrency-conflict` + /// + /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + enum class ErrorCode : uint8_t { + /// Unknown error + kUnknown = 0, + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM + kAccessDenied = 1, + /// The operation is not supported. + /// + /// POSIX equivalent: EOPNOTSUPP + kNotSupported = 2, + /// One of the arguments is invalid. + /// + /// POSIX equivalent: EINVAL + kInvalidArgument = 3, + /// Not enough memory to complete the operation. + /// + /// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY + kOutOfMemory = 4, + /// The operation timed out before it could finish completely. + kTimeout = 5, + /// This operation is incompatible with another asynchronous operation that is already in progress. + /// + /// POSIX equivalent: EALREADY + kConcurrencyConflict = 6, + /// Trying to finish an asynchronous operation that: + /// - has not been started yet, or: + /// - was already finished by a previous `finish-*` call. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. + kNotInProgress = 7, + /// The operation has been aborted because it could not be completed immediately. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. + kWouldBlock = 8, + /// The operation is not valid in the socket's current state. + kInvalidState = 9, + /// A new socket resource could not be created because of a system limit. + kNewSocketLimit = 10, + /// A bind operation failed because the provided address is not an address that the `network` can bind to. + kAddressNotBindable = 11, + /// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available. + kAddressInUse = 12, + /// The remote address is not reachable + kRemoteUnreachable = 13, + /// The TCP connection was forcefully rejected + kConnectionRefused = 14, + /// The TCP connection was reset. + kConnectionReset = 15, + /// A TCP connection was aborted. + kConnectionAborted = 16, + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. + kDatagramTooLarge = 17, + /// Name does not exist or has no suitable associated IP addresses. + kNameUnresolvable = 18, + /// A temporary failure in name resolution occurred. + kTemporaryResolverFailure = 19, + /// A permanent failure in name resolution occurred. + kPermanentResolverFailure = 20, + }; + + enum class IpAddressFamily : uint8_t { + /// Similar to `AF_INET` in POSIX. + kIpv4 = 0, + /// Similar to `AF_INET6` in POSIX. + kIpv6 = 1, + }; + + struct IpAddress { + struct Ipv4 { std::tuple value; }; + struct Ipv6 { std::tuple value; }; + std::variant variants; + }; + struct Ipv4SocketAddress { + /// sin_port + uint16_t port; + /// sin_addr + std::tuple address; + }; + struct Ipv6SocketAddress { + /// sin6_port + uint16_t port; + /// sin6_flowinfo + uint32_t flow_info; + /// sin6_addr + std::tuple address; + /// sin6_scope_id + uint32_t scope_id; + }; + struct IpSocketAddress { + struct Ipv4 { network::Ipv4SocketAddress value; }; + struct Ipv6 { network::Ipv6SocketAddress value; }; + std::variant variants; + }; + } + /// This interface provides a value-export of the default network handle.. + namespace instance_network { + using Network = network::Network; + /// Get a handle to the default network. + network::Network InstanceNetwork(); + } + namespace udp { + using Pollable = io0_2_0::poll::Pollable; + using Network = network::Network; + using ErrorCode = network::ErrorCode; + using IpSocketAddress = network::IpSocketAddress; + using IpAddressFamily = network::IpAddressFamily; + /// A received datagram. + struct IncomingDatagram { + /// The payload. + /// + /// Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes. + wit::vector data; + /// The source address. + /// + /// This field is guaranteed to match the remote address the stream was initialized with, if any. + /// + /// Equivalent to the `src_addr` out parameter of `recvfrom`. + network::IpSocketAddress remote_address; + }; + /// A datagram to be sent out. + struct OutgoingDatagram { + /// The payload. + wit::vector data; + /// The destination address. + /// + /// The requirements on this field depend on how the stream was initialized: + /// - with a remote address: this field must be None or match the stream's remote address exactly. + /// - without a remote address: this field is required. + /// + /// If this value is None, the send operation is equivalent to `send` in POSIX. Otherwise it is equivalent to `sendto`. + std::optional remote_address; + }; + class IncomingDatagramStream : public wit::ResourceImportBase{ + + public: + + ~IncomingDatagramStream(); + /// Receive messages on the socket. + /// + /// This function attempts to receive up to `max-results` datagrams on the socket without blocking. + /// The returned list may contain fewer elements than requested, but never more. + /// + /// This function returns successfully with an empty list when either: + /// - `max-results` is 0, or: + /// - `max-results` is greater than 0, but no results are immediately available. + /// This function never returns `error(would-block)`. + /// + /// # Typical errors + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - + std::expected, network::ErrorCode> Receive(uint64_t max_results) const; + /// Create a `pollable` which will resolve once the stream is ready to receive again. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + io0_2_0::poll::Pollable Subscribe() const; + IncomingDatagramStream(wit::ResourceImportBase &&); + IncomingDatagramStream(IncomingDatagramStream&&) = default; + IncomingDatagramStream& operator=(IncomingDatagramStream&&) = default; + }; + + class OutgoingDatagramStream : public wit::ResourceImportBase{ + + public: + + ~OutgoingDatagramStream(); + /// Check readiness for sending. This function never blocks. + /// + /// Returns the number of datagrams permitted for the next call to `send`, + /// or an error. Calling `send` with more datagrams than this function has + /// permitted will trap. + /// + /// When this function returns ok(0), the `subscribe` pollable will + /// become ready when this function will report at least ok(1), or an + /// error. + /// + /// Never returns `would-block`. + std::expected CheckSend() const; + /// Send messages on the socket. + /// + /// This function attempts to send all provided `datagrams` on the socket without blocking and + /// returns how many messages were actually sent (or queued for sending). This function never + /// returns `error(would-block)`. If none of the datagrams were able to be sent, `ok(0)` is returned. + /// + /// This function semantically behaves the same as iterating the `datagrams` list and sequentially + /// sending each individual datagram until either the end of the list has been reached or the first error occurred. + /// If at least one datagram has been sent successfully, this function never returns an error. + /// + /// If the input list is empty, the function returns `ok(0)`. + /// + /// Each call to `send` must be permitted by a preceding `check-send`. Implementations must trap if + /// either `check-send` was not called or `datagrams` contains more items than `check-send` permitted. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` value that does not match the address passed to `stream`. (EISCONN) + /// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - + std::expected Send(std::span datagrams) const; + /// Create a `pollable` which will resolve once the stream is ready to send again. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + io0_2_0::poll::Pollable Subscribe() const; + OutgoingDatagramStream(wit::ResourceImportBase &&); + OutgoingDatagramStream(OutgoingDatagramStream&&) = default; + OutgoingDatagramStream& operator=(OutgoingDatagramStream&&) = default; + }; + + class UdpSocket : public wit::ResourceImportBase{ + + public: + + ~UdpSocket(); + /// Bind the socket to a specific network on the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which + /// network interface(s) to bind to. + /// If the port is zero, the socket will be bound to a random free port. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) + /// - `address-in-use`: Address is already in use. (EADDRINUSE) + /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) + /// - `not-in-progress`: A `bind` operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected StartBind(std::reference_wrapper network, network::IpSocketAddress local_address) const; + std::expected FinishBind() const; + /// Set up inbound & outbound communication channels, optionally to a specific peer. + /// + /// This function only changes the local socket configuration and does not generate any network traffic. + /// On success, the `remote-address` of the socket is updated. The `local-address` may be updated as well, + /// based on the best network path to `remote-address`. + /// + /// When a `remote-address` is provided, the returned streams are limited to communicating with that specific peer: + /// - `send` can only be used to send to this destination. + /// - `receive` will only return datagrams sent from the provided `remote-address`. + /// + /// This method may be called multiple times on the same socket to change its association, but + /// only the most recently returned pair of streams will be operational. Implementations may trap if + /// the streams returned by a previous invocation haven't been dropped yet before calling `stream` again. + /// + /// The POSIX equivalent in pseudo-code is: + /// ```text + /// if (was previously connected) { + /// connect(s, AF_UNSPEC) + /// } + /// if (remote_address is Some) { + /// connect(s, remote_address) + /// } + /// ``` + /// + /// Unlike in POSIX, the socket must already be explicitly bound. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-state`: The socket is not bound. + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected, network::ErrorCode> Stream(std::optional remote_address) const; + /// Get the current bound address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected LocalAddress() const; + /// Get the address the socket is currently streaming to. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not streaming to a specific remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected RemoteAddress() const; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// Equivalent to the SO_DOMAIN socket option. + network::IpAddressFamily AddressFamily() const; + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + std::expected UnicastHopLimit() const; + std::expected SetUnicastHopLimit(uint8_t value) const; + /// The kernel buffer space reserved for sends/receives on this socket. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + std::expected ReceiveBufferSize() const; + std::expected SetReceiveBufferSize(uint64_t value) const; + std::expected SendBufferSize() const; + std::expected SetSendBufferSize(uint64_t value) const; + /// Create a `pollable` which will resolve once the socket is ready for I/O. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + io0_2_0::poll::Pollable Subscribe() const; + UdpSocket(wit::ResourceImportBase &&); + UdpSocket(UdpSocket&&) = default; + UdpSocket& operator=(UdpSocket&&) = default; + }; + + } + namespace udp_create_socket { + using Network = network::Network; + using ErrorCode = network::ErrorCode; + using IpAddressFamily = network::IpAddressFamily; + using UdpSocket = udp::UdpSocket; + /// Create a new UDP socket. + /// + /// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. + /// + /// This function does not require a network capability handle. This is considered to be safe because + /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is called, + /// the socket is effectively an in-memory configuration object, unable to communicate with the outside world. + /// + /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. + /// + /// # Typical errors + /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References: + /// - + /// - + /// - + /// - + std::expected CreateUdpSocket(network::IpAddressFamily address_family); + } + namespace tcp { + using InputStream = io0_2_0::streams::InputStream; + using OutputStream = io0_2_0::streams::OutputStream; + using Pollable = io0_2_0::poll::Pollable; + using Duration = uint64_t; + using Network = network::Network; + using ErrorCode = network::ErrorCode; + using IpSocketAddress = network::IpSocketAddress; + using IpAddressFamily = network::IpAddressFamily; + enum class ShutdownType : uint8_t { + /// Similar to `SHUT_RD` in POSIX. + kReceive = 0, + /// Similar to `SHUT_WR` in POSIX. + kSend = 1, + /// Similar to `SHUT_RDWR` in POSIX. + kBoth = 2, + }; + + class TcpSocket : public wit::ResourceImportBase{ + + public: + + ~TcpSocket(); + /// Bind the socket to a specific network on the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which + /// network interface(s) to bind to. + /// If the TCP/UDP port is zero, the socket will be bound to a random free port. + /// + /// Bind can be attempted multiple times on the same socket, even with + /// different arguments on each iteration. But never concurrently and + /// only as long as the previous bind failed. Once a bind succeeds, the + /// binding can't be changed anymore. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-argument`: `local-address` is not a unicast address. (EINVAL) + /// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) + /// - `address-in-use`: Address is already in use. (EADDRINUSE) + /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) + /// - `not-in-progress`: A `bind` operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT + /// state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR + /// socket option should be set implicitly on all platforms, except on Windows where this is the default behavior + /// and SO_REUSEADDR performs something different entirely. + /// + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected StartBind(std::reference_wrapper network, network::IpSocketAddress local_address) const; + std::expected FinishBind() const; + /// Connect to a remote endpoint. + /// + /// On success: + /// - the socket is transitioned into the `connection` state. + /// - a pair of streams is returned that can be used to read & write to the connection + /// + /// After a failed connection attempt, the socket will be in the `closed` + /// state and the only valid action left is to `drop` the socket. A single + /// socket can not be used to connect more than once. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS) + /// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows) + /// - `invalid-argument`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`. + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN) + /// - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows) + /// - `timeout`: Connection timed out. (ETIMEDOUT) + /// - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED) + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `connection-aborted`: The connection was aborted. (ECONNABORTED) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// - `not-in-progress`: A connect operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// The POSIX equivalent of `start-connect` is the regular `connect` syscall. + /// Because all WASI sockets are non-blocking this is expected to return + /// EINPROGRESS, which should be translated to `ok()` in WASI. + /// + /// The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT` + /// with a timeout of 0 on the socket descriptor. Followed by a check for + /// the `SO_ERROR` socket option, in case the poll signaled readiness. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected StartConnect(std::reference_wrapper network, network::IpSocketAddress remote_address) const; + std::expected, network::ErrorCode> FinishConnect() const; + /// Start listening for new connections. + /// + /// Transitions the socket into the `listening` state. + /// + /// Unlike POSIX, the socket must already be explicitly bound. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ) + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD) + /// - `invalid-state`: The socket is already in the `listening` state. + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) + /// - `not-in-progress`: A listen operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// Unlike in POSIX, in WASI the listen operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `listen` as part of either `start-listen` or `finish-listen`. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected StartListen() const; + std::expected FinishListen() const; + /// Accept a new client socket. + /// + /// The returned socket is bound and in the `connected` state. The following properties are inherited from the listener socket: + /// - `address-family` + /// - `keep-alive-enabled` + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// - `hop-limit` + /// - `receive-buffer-size` + /// - `send-buffer-size` + /// + /// On success, this function returns the newly accepted client socket along with + /// a pair of streams that can be used to read & write to the connection. + /// + /// # Typical errors + /// - `invalid-state`: Socket is not in the `listening` state. (EINVAL) + /// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN) + /// - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected, network::ErrorCode> Accept() const; + /// Get the bound local address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - + std::expected LocalAddress() const; + /// Get the remote address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected RemoteAddress() const; + /// Whether the socket is in the `listening` state. + /// + /// Equivalent to the SO_ACCEPTCONN socket option. + bool IsListening() const; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// Equivalent to the SO_DOMAIN socket option. + network::IpAddressFamily AddressFamily() const; + /// Hints the desired listen queue size. Implementations are free to ignore this. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// + /// # Typical errors + /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. + /// - `invalid-argument`: (set) The provided value was 0. + /// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. + std::expected SetListenBacklogSize(uint64_t value) const; + /// Enables or disables keepalive. + /// + /// The keepalive behavior can be adjusted using: + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. + /// + /// Equivalent to the SO_KEEPALIVE socket option. + std::expected KeepAliveEnabled() const; + std::expected SetKeepAliveEnabled(bool value) const; + /// Amount of time the connection has to be idle before TCP starts sending keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + std::expected KeepAliveIdleTime() const; + std::expected SetKeepAliveIdleTime(uint64_t value) const; + /// The time between keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPINTVL socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + std::expected KeepAliveInterval() const; + std::expected SetKeepAliveInterval(uint64_t value) const; + /// The maximum amount of keepalive packets TCP should send before aborting the connection. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPCNT socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + std::expected KeepAliveCount() const; + std::expected SetKeepAliveCount(uint32_t value) const; + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + std::expected HopLimit() const; + std::expected SetHopLimit(uint8_t value) const; + /// The kernel buffer space reserved for sends/receives on this socket. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. + std::expected ReceiveBufferSize() const; + std::expected SetReceiveBufferSize(uint64_t value) const; + std::expected SendBufferSize() const; + std::expected SetSendBufferSize(uint64_t value) const; + /// Create a `pollable` which can be used to poll for, or block on, + /// completion of any of the asynchronous operations of this socket. + /// + /// When `finish-bind`, `finish-listen`, `finish-connect` or `accept` + /// return `error(would-block)`, this pollable can be used to wait for + /// their success or failure, after which the method can be retried. + /// + /// The pollable is not limited to the async operation that happens to be + /// in progress at the time of calling `subscribe` (if any). Theoretically, + /// `subscribe` only has to be called once per socket and can then be + /// (re)used for the remainder of the socket's lifetime. + /// + /// See + /// for a more information. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + io0_2_0::poll::Pollable Subscribe() const; + /// Initiate a graceful shutdown. + /// + /// - `receive`: The socket is not expecting to receive any data from + /// the peer. The `input-stream` associated with this socket will be + /// closed. Any data still in the receive queue at time of calling + /// this method will be discarded. + /// - `send`: The socket has no more data to send to the peer. The `output-stream` + /// associated with this socket will be closed and a FIN packet will be sent. + /// - `both`: Same effect as `receive` & `send` combined. + /// + /// This function is idempotent. Shutting a down a direction more than once + /// has no effect and returns `ok`. + /// + /// The shutdown function does not close (drop) the socket. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected Shutdown(tcp::ShutdownType shutdown_type) const; + TcpSocket(wit::ResourceImportBase &&); + TcpSocket(TcpSocket&&) = default; + TcpSocket& operator=(TcpSocket&&) = default; + }; + + } + namespace tcp_create_socket { + using Network = network::Network; + using ErrorCode = network::ErrorCode; + using IpAddressFamily = network::IpAddressFamily; + using TcpSocket = tcp::TcpSocket; + /// Create a new TCP socket. + /// + /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. + /// + /// This function does not require a network capability handle. This is considered to be safe because + /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect` + /// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world. + /// + /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. + /// + /// # Typical errors + /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References + /// - + /// - + /// - + /// - + std::expected CreateTcpSocket(network::IpAddressFamily address_family); + } + namespace ip_name_lookup { + using Pollable = io0_2_0::poll::Pollable; + using Network = network::Network; + using ErrorCode = network::ErrorCode; + using IpAddress = network::IpAddress; + class ResolveAddressStream : public wit::ResourceImportBase{ + + public: + + ~ResolveAddressStream(); + /// Returns the next address from the resolver. + /// + /// This function should be called multiple times. On each call, it will + /// return the next address in connection order preference. If all + /// addresses have been exhausted, this function returns `none`. + /// + /// This function never returns IPv4-mapped IPv6 addresses. + /// + /// # Typical errors + /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) + /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) + /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) + /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) + std::expected, network::ErrorCode> ResolveNextAddress() const; + /// Create a `pollable` which will resolve once the stream is ready for I/O. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. + io0_2_0::poll::Pollable Subscribe() const; + ResolveAddressStream(wit::ResourceImportBase &&); + ResolveAddressStream(ResolveAddressStream&&) = default; + ResolveAddressStream& operator=(ResolveAddressStream&&) = default; + }; + + /// Resolve an internet host name to a list of IP addresses. + /// + /// Unicode domain names are automatically converted to ASCII using IDNA encoding. + /// If the input is an IP address string, the address is parsed and returned + /// as-is without making any external requests. + /// + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. + /// + /// This function never blocks. It either immediately fails or immediately + /// returns successfully with a `resolve-address-stream` that can be used + /// to (asynchronously) fetch the results. + /// + /// # Typical errors + /// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. + /// + /// # References: + /// - + /// - + /// - + /// - + std::expected ResolveAddresses(std::reference_wrapper network, std::string_view name); + } + } + /// WASI Random is a random data API. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + namespace random0_2_0 { + namespace random { + /// Return `len` cryptographically-secure random or pseudo-random bytes. + /// + /// This function must produce data at least as cryptographically secure and + /// fast as an adequately seeded cryptographically-secure pseudo-random + /// number generator (CSPRNG). It must not block, from the perspective of + /// the calling program, under any circumstances, including on the first + /// request and on requests for numbers of bytes. The returned data must + /// always be unpredictable. + /// + /// This function must always return fresh data. Deterministic environments + /// must omit this function, rather than implementing it with deterministic + /// data. + wit::vector GetRandomBytes(uint64_t len); + /// Return a cryptographically-secure random or pseudo-random `u64` value. + /// + /// This function returns the same type of data as `get-random-bytes`, + /// represented as a `u64`. + uint64_t GetRandomU64(); + } + /// The insecure interface for insecure pseudo-random numbers. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + namespace insecure { + /// Return `len` insecure pseudo-random bytes. + /// + /// This function is not cryptographically secure. Do not use it for + /// anything related to security. + /// + /// There are no requirements on the values of the returned bytes, however + /// implementations are encouraged to return evenly distributed values with + /// a long period. + wit::vector GetInsecureRandomBytes(uint64_t len); + /// Return an insecure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-insecure-random-bytes`, represented as a `u64`. + uint64_t GetInsecureRandomU64(); + } + /// The insecure-seed interface for seeding hash-map DoS resistance. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + namespace insecure_seed { + /// Return a 128-bit value that may contain a pseudo-random value. + /// + /// The returned value is not required to be computed from a CSPRNG, and may + /// even be entirely deterministic. Host implementations are encouraged to + /// provide pseudo-random values to any program exposed to + /// attacker-controlled content, to enable DoS protection built into many + /// languages' hash-map implementations. + /// + /// This function is intended to only be called once, by a source language + /// to initialize Denial Of Service (DoS) protection in its hash-map + /// implementation. + /// + /// # Expected future evolution + /// + /// This will likely be changed to a value import, to prevent it from being + /// called multiple times and potentially used for purposes other than DoS + /// protection. + std::tuple InsecureSeed(); + } + } + /// A keyvalue interface that provides eventually consistent key-value operations. + /// + /// Each of these operations acts on a single key-value pair. + /// + /// The value in the key-value pair is defined as a `u8` byte array and the intention is that it is + /// the common denominator for all data types defined by different key-value stores to handle data, + /// ensuring compatibility between different key-value stores. Note: the clients will be expecting + /// serialization/deserialization overhead to be handled by the key-value store. The value could be + /// a serialized object from JSON, HTML or vendor-specific data types like AWS S3 objects. + /// + /// Data consistency in a key value store refers to the guarantee that once a write operation + /// completes, all subsequent read operations will return the value that was written. + /// + /// Any implementation of this interface must have enough consistency to guarantee "reading your + /// writes." In particular, this means that the client should never get a value that is older than + /// the one it wrote, but it MAY get a newer value if one was written around the same time. These + /// guarantees only apply to the same client (which will likely be provided by the host or an + /// external capability of some kind). In this context a "client" is referring to the caller or + /// guest that is consuming this interface. Once a write request is committed by a specific client, + /// all subsequent read requests by the same client will reflect that write or any subsequent + /// writes. Another client running in a different context may or may not immediately see the result + /// due to the replication lag. As an example of all of this, if a value at a given key is A, and + /// the client writes B, then immediately reads, it should get B. If something else writes C in + /// quick succession, then the client may get C. However, a client running in a separate context may + /// still see A or B + namespace keyvalue { + namespace store { + /// The set of errors which may be raised by functions in this package + struct Error { + /// The host does not recognize the store identifier requested. + struct NoSuchStore {}; + /// The requesting component does not have access to the specified store + /// (which may or may not exist). + struct AccessDenied {}; + /// Some implementation-specific error has occurred (e.g. I/O) + struct Other { wit::string value; }; + std::variant variants; + }; + /// A response to a `list-keys` operation. + struct KeyResponse { + /// The list of keys returned by the query. + wit::vector keys; + /// The continuation token to use to fetch the next page of keys. If this is `null`, then + /// there are no more keys to fetch. + std::optional cursor; + }; + class Bucket : public wit::ResourceImportBase{ + + public: + + ~Bucket(); + /// Get the value associated with the specified `key` + /// + /// The value is returned as an option. If the key-value pair exists in the + /// store, it returns `Ok(value)`. If the key does not exist in the + /// store, it returns `Ok(none)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected>, Error> Get(std::string_view key) const; + /// Set the value associated with the key in the store. If the key already + /// exists in the store, it overwrites the value. + /// + /// If the key does not exist in the store, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected Set(std::string_view key, std::span value) const; + /// Delete the key-value pair associated with the key in the store. + /// + /// If the key does not exist in the store, it does nothing. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected Delete(std::string_view key) const; + /// Check if the key exists in the store. + /// + /// If the key exists in the store, it returns `Ok(true)`. If the key does + /// not exist in the store, it returns `Ok(false)`. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected Exists(std::string_view key) const; + /// Get all the keys in the store with an optional cursor (for use in pagination). It + /// returns a list of keys. Please note that for most KeyValue implementations, this is a + /// can be a very expensive operation and so it should be used judiciously. Implementations + /// can return any number of keys in a single response, but they should never attempt to + /// send more data than is reasonable (i.e. on a small edge device, this may only be a few + /// KB, while on a large machine this could be several MB). Any response should also return + /// a cursor that can be used to fetch the next page of keys. See the `key-response` record + /// for more information. + /// + /// Note that the keys are not guaranteed to be returned in any particular order. + /// + /// If the store is empty, it returns an empty list. + /// + /// MAY show an out-of-date list of keys if there are concurrent writes to the store. + /// + /// If any error occurs, it returns an `Err(error)`. + std::expected ListKeys(std::optional cursor) const; + Bucket(wit::ResourceImportBase &&); + Bucket(Bucket&&) = default; + Bucket& operator=(Bucket&&) = default; + }; + + /// Get the bucket with the specified identifier. + /// + /// `identifier` must refer to a bucket provided by the host. + /// + /// `error::no-such-store` will be raised if the `identifier` is not recognized. + std::expected Open(std::string_view identifier); + } + /// A keyvalue interface that provides atomic operations. + /// + /// Atomic operations are single, indivisible operations. When a fault causes an atomic operation to + /// fail, it will appear to the invoker of the atomic operation that the action either completed + /// successfully or did nothing at all. + /// + /// Please note that this interface is bare functions that take a reference to a bucket. This is to + /// get around the current lack of a way to "extend" a resource with additional methods inside of + /// wit. Future version of the interface will instead extend these methods on the base `bucket` + /// resource. + namespace atomics { + using Bucket = store::Bucket; + using Error = store::Error; + class Cas : public wit::ResourceImportBase{ + + public: + + ~Cas(); + /// Construct a new CAS operation. Implementors can map the underlying functionality + /// (transactions, versions, etc) as desired. + static std::expected New(std::reference_wrapper bucket, std::string_view key); + /// Get the current value of the key (if it exists). This allows for avoiding reads if all + /// that is needed to ensure the atomicity of the operation + std::expected>, store::Error> Current() const; + Cas(wit::ResourceImportBase &&); + Cas(Cas&&) = default; + Cas& operator=(Cas&&) = default; + }; + + /// The error returned by a CAS operation + struct CasError { + /// A store error occurred when performing the operation + struct StoreError { store::Error value; }; + /// The CAS operation failed because the value was too old. This returns a new CAS handle + /// for easy retries. Implementors MUST return a CAS handle that has been updated to the + /// latest version or transaction. + struct CasFailed { atomics::Cas value; }; + std::variant variants; + }; + /// Atomically increment the value associated with the key in the store by the given delta. It + /// returns the new value. + /// + /// If the key does not exist in the store, it creates a new key-value pair with the value set + /// to the given delta. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected Increment(std::reference_wrapper bucket, std::string_view key, int64_t delta); + /// Perform the swap on a CAS operation. This consumes the CAS handle and returns an error if + /// the CAS operation failed. + std::expected Swap(Cas&& cas, std::span value); + } + /// A keyvalue interface that provides batch operations. + /// + /// A batch operation is an operation that operates on multiple keys at once. + /// + /// Batch operations are useful for reducing network round-trip time. For example, if you want to + /// get the values associated with 100 keys, you can either do 100 get operations or you can do 1 + /// batch get operation. The batch operation is faster because it only needs to make 1 network call + /// instead of 100. + /// + /// A batch operation does not guarantee atomicity, meaning that if the batch operation fails, some + /// of the keys may have been modified and some may not. + /// + /// This interface does has the same consistency guarantees as the `store` interface, meaning that + /// you should be able to "read your writes." + /// + /// Please note that this interface is bare functions that take a reference to a bucket. This is to + /// get around the current lack of a way to "extend" a resource with additional methods inside of + /// wit. Future version of the interface will instead extend these methods on the base `bucket` + /// resource. + namespace batch { + using Bucket = store::Bucket; + using Error = store::Error; + /// Get the key-value pairs associated with the keys in the store. It returns a list of + /// key-value pairs. + /// + /// If any of the keys do not exist in the store, it returns a `none` value for that pair in the + /// list. + /// + /// MAY show an out-of-date value if there are concurrent writes to the store. + /// + /// If any other error occurs, it returns an `Err(error)`. + std::expected>>>, store::Error> GetMany(std::reference_wrapper bucket, std::span keys); + /// Set the values associated with the keys in the store. If the key already exists in the + /// store, it overwrites the value. + /// + /// Note that the key-value pairs are not guaranteed to be set in the order they are provided. + /// + /// If any of the keys do not exist in the store, it creates a new key-value pair. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not + /// rollback the key-value pairs that were already set. Thus, this batch operation does not + /// guarantee atomicity, implying that some key-value pairs could be set while others might + /// fail. + /// + /// Other concurrent operations may also be able to see the partial results. + std::expected SetMany(std::reference_wrapper bucket, std::span> const> key_values); + /// Delete the key-value pairs associated with the keys in the store. + /// + /// Note that the key-value pairs are not guaranteed to be deleted in the order they are + /// provided. + /// + /// If any of the keys do not exist in the store, it skips the key. + /// + /// If any other error occurs, it returns an `Err(error)`. When an error occurs, it does not + /// rollback the key-value pairs that were already deleted. Thus, this batch operation does not + /// guarantee atomicity, implying that some key-value pairs could be deleted while others might + /// fail. + /// + /// Other concurrent operations may also be able to see the partial results. + std::expected DeleteMany(std::reference_wrapper bucket, std::span keys); + // export_interface Interface(Id { idx: 42 }) + } + } +} +/// This interface defines a handler of incoming HTTP Requests. It should +/// be exported by components which can respond to HTTP Requests. +namespace exports { + namespace wasi { + namespace http0_2_0 { + namespace incoming_handler { + using IncomingRequest = ::wasi::http0_2_0::types::IncomingRequest; + using ResponseOutparam = ::wasi::http0_2_0::types::ResponseOutparam; + /// This function is invoked with an incoming HTTP Request, and a resource + /// `response-outparam` which provides the capability to reply with an HTTP + /// Response. The response is sent by calling the `response-outparam.set` + /// method, which allows execution to continue after the response has been + /// sent. This enables both streaming to the response body, and performing other + /// work. + /// + /// The implementor of this function must write a response to the + /// `response-outparam` before returning, or else the caller will respond + /// with an error on its behalf. + void Handle(::wasi::http0_2_0::types::IncomingRequest&& request, ::wasi::http0_2_0::types::ResponseOutparam&& response_out); + } + } + } +} + +#endif diff --git a/templates/http-cpp/content/bindings/wit.h b/templates/http-cpp/content/bindings/wit.h new file mode 100644 index 0000000000..8a79db32c0 --- /dev/null +++ b/templates/http-cpp/content/bindings/wit.h @@ -0,0 +1,260 @@ +#pragma once + +#include +#include +#include +#include // size_t +#include +#include // unique_ptr +#include +#include +#include +#include // memcpy +#include // free +#include +#include + +namespace wit { +/// @brief Helper class to map between IDs and resources +/// @tparam R Type of the Resource +template class ResourceTable { + static std::map resources; + +public: + static R *lookup_resource(int32_t id) { + auto result = resources.find(id); + return result == resources.end() ? nullptr : &result->second; + } + static int32_t store_resource(R &&value) { + auto last = resources.rbegin(); + int32_t id = last == resources.rend() ? 0 : last->first + 1; + resources.insert(std::pair(id, std::move(value))); + return id; + } + static std::optional remove_resource(int32_t id) { + auto iter = resources.find(id); + std::optional result; + if (iter != resources.end()) { + result = std::move(iter->second); + resources.erase(iter); + } + return std::move(result); + } +}; + +/// @brief Replaces void in the error position of a result +struct Void {}; + +/// A string in linear memory, freed unconditionally using free +/// +/// A normal C++ string makes no guarantees about where the characters +/// are stored and how this is freed. +class string { + uint8_t const *data_; + size_t length; + // C++ is horrible! + //constexpr uint8_t const *const empty_ptr = (uint8_t const *)1; + static uint8_t const* empty_ptr() { return (uint8_t const *)1; } + +public: + // this constructor is helpful for creating vector + string(string const &b) : string(string::from_view(b.get_view())) {} + string(string &&b) : data_(b.data_), length(b.length) { b.data_ = nullptr; } + string &operator=(string const &) = delete; + string &operator=(string &&b) { + if (data_ && data_!=empty_ptr()) { + free(const_cast(data_)); + } + data_ = b.data_; + length = b.length; + b.data_ = nullptr; + return *this; + } + string(char const *d, size_t l) : data_((uint8_t const *)d), length(l) {} + char const *data() const { return (char const *)data_; } + size_t size() const { return length; } + bool empty() const { return !length; } + ~string() { + if (data_ && data_!=empty_ptr()) { + free(const_cast(data_)); + } + } + // leak the memory + void leak() { data_ = nullptr; } + // typically called by post + static void drop_raw(void *ptr) { free(ptr); } + std::string_view get_view() const { + return std::string_view((const char *)data_, length); + } + std::string to_string() const { + return std::string((const char *)data_, length); + } + static string from_view(std::string_view v) { + if (!v.size()) return string((char const*)empty_ptr(), 0); + char* addr = (char*)malloc(v.size()); + memcpy(addr, v.data(), v.size()); + return string(addr, v.size()); + } + char* begin() { + return (char*)data_; + } + char* end() { + return (char*)data_ + length; + } + char const* begin() const { + return (char const*)data_; + } + char const* end() const { + return (char const*)data_ + length; + } +}; + +/// A vector in linear memory, freed unconditionally using free +/// +/// You can't detach the data memory from a vector, nor create one +/// in a portable way from a buffer and lenght without copying. +template class vector { + T *data_; + size_t length; + + static T* empty_ptr() { return (T*)alignof(T); } + +public: + vector(vector const &) = delete; + vector(vector &&b) : data_(b.data_), length(b.length) { b.data_ = nullptr; } + vector &operator=(vector const &) = delete; + vector &operator=(vector &&b) { + if (data_ && length>0) { + free(data_); + } + data_ = b.data_; + length = b.length; + b.data_ = nullptr; + return *this; + } + vector(T *d, size_t l) : data_(d), length(l) {} + // Rust needs a nonzero pointer here (alignment is typical) + vector() : data_(empty_ptr()), length() {} + T const *data() const { return data_; } + T *data() { return data_; } + T &operator[](size_t n) { return data_[n]; } + T const &operator[](size_t n) const { return data_[n]; } + size_t size() const { return length; } + bool empty() const { return !length; } + ~vector() { + if (data_ && length>0) { + for (unsigned i=0;i allocate(size_t len) { + if (!len) return vector(empty_ptr(), 0); + return vector((T*)malloc(sizeof(T)*len), len); + } + void initialize(size_t n, T&& elem) { + new ((void*)(data_+n)) T(std::move(elem)); + } + // leak the memory + T* leak() { T*result = data_; data_ = nullptr; return result; } + // typically called by post + static void drop_raw(void *ptr) { if (ptr!=empty_ptr()) free(ptr); } + std::span get_view() const { return std::span(data_, length); } + std::span get_const_view() const { return std::span(data_, length); } + template static vector from_view(std::span const& a) { + auto result = vector::allocate(a.size()); + for (uint32_t i=0;i class ResourceExportBase { +public: + struct Deregister { + void operator()(R *ptr) const { + // probably always true because of unique_ptr wrapping, TODO: check +#ifdef WIT_SYMMETRIC + if (ptr->handle != nullptr) +#else + if (ptr->handle >= 0) +#endif + { + // we can't deallocate because the host calls Dtor + R::ResourceDrop(ptr->handle); + } + } + }; + typedef std::unique_ptr Owned; + +#ifdef WIT_SYMMETRIC + typedef uint8_t *handle_t; + static constexpr handle_t invalid = nullptr; +#else + typedef int32_t handle_t; + static const handle_t invalid = -1; +#endif + + handle_t handle; + + ResourceExportBase() : handle(R::ResourceNew((R *)this)) {} + // because this function is called by the host via Dtor we must not deregister + ~ResourceExportBase() {} + ResourceExportBase(ResourceExportBase const &) = delete; + ResourceExportBase(ResourceExportBase &&) = delete; + ResourceExportBase &operator=(ResourceExportBase &&b) = delete; + ResourceExportBase &operator=(ResourceExportBase const &) = delete; + handle_t get_handle() const { return handle; } + handle_t into_handle() { + handle_t result = handle; + handle = invalid; + return result; + } +}; + +/// @brief A Resource imported from the host (guest side) +/// +/// Wraps the identifier and can be forwarded but not duplicated +class ResourceImportBase { +public: +#ifdef WIT_SYMMETRIC + typedef uint8_t *handle_t; + static constexpr handle_t invalid = nullptr; +#else + typedef int32_t handle_t; + static const handle_t invalid = -1; +#endif + +protected: + handle_t handle; + +public: + ResourceImportBase(handle_t h = invalid) : handle(h) {} + ResourceImportBase(ResourceImportBase &&r) : handle(r.handle) { + r.handle = invalid; + } + ResourceImportBase(ResourceImportBase const &) = delete; + void set_handle(handle_t h) { handle = h; } + handle_t get_handle() const { return handle; } + handle_t into_handle() { + handle_t h = handle; + handle = invalid; + return h; + } + ResourceImportBase &operator=(ResourceImportBase &&r) { + assert(handle == invalid); + handle = r.handle; + r.handle = invalid; + return *this; + } + ResourceImportBase &operator=(ResourceImportBase const &r) = delete; +}; +} // namespace wit diff --git a/templates/http-cpp/content/main.cpp b/templates/http-cpp/content/main.cpp new file mode 100644 index 0000000000..b39e41f25c --- /dev/null +++ b/templates/http-cpp/content/main.cpp @@ -0,0 +1,48 @@ +#include "bindings/wit.h" +#include "bindings/http_trigger_cpp.h" +#include "bindings/wit.h" +#include + +using wasi::http0_2_0::types::Fields; +using wasi::http0_2_0::types::IncomingRequest; +using wasi::http0_2_0::types::OutgoingBody; +using wasi::http0_2_0::types::OutgoingResponse; +using wasi::http0_2_0::types::ResponseOutparam; + +namespace conv { + std::span spanify(const char* chs, size_t sz) { + return std::span(reinterpret_cast(const_cast(chs)), sz); + } + std::span spanify(const char* chs) { + return spanify(chs, strlen(chs)); + } + std::span spanify(wit::string s) { + const auto len = s.size(); + const auto chars = s.data(); + return spanify(chars, len); + } +} + +namespace exports::wasi::http0_2_0::incoming_handler { + void Handle(IncomingRequest&& request, ResponseOutparam&& response_out) { + Fields headers; + OutgoingResponse resp(std::move(headers)); + auto ogbod = resp.Body().value(); + ResponseOutparam::Set(std::move(response_out), std::move(resp)); + + auto pq = request.PathWithQuery(); + + if (pq.has_value()) { + const auto pq_text = pq.value(); + + auto out_stm = ogbod.Write().value(); + out_stm.BlockingWriteAndFlush(conv::spanify(pq_text)); + out_stm.BlockingWriteAndFlush(conv::spanify("\n")); + } else { + auto out_stm = ogbod.Write().value(); + out_stm.BlockingWriteAndFlush(conv::spanify("no path-and-query\n")); + } + + OutgoingBody::Finish(std::move(ogbod), std::nullopt); + } +} diff --git a/templates/http-cpp/content/spin.toml b/templates/http-cpp/content/spin.toml new file mode 100644 index 0000000000..8887b47bce --- /dev/null +++ b/templates/http-cpp/content/spin.toml @@ -0,0 +1,20 @@ +#:schema https://schemas.spinframework.dev/spin/manifest-v2/latest.json + +spin_manifest_version = 2 + +[application] +name = "{{project-name | kebab_case}}" +version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" + +[[trigger.http]] +route = "{{http-path}}" +component = "{{project-name | kebab_case}}" + +[component.{{project-name | kebab_case}}] +source = "main.wasm" +allowed_outbound_hosts = [] +[component.{{project-name | kebab_case}}.build] +command = "$WASI_SDK_PATH/bin/clang++ --sysroot=$WASI_SDK_PATH/share/wasi-sysroot -fno-exceptions -std=c++23 -I bindings -target wasm32-wasip2 main.cpp bindings/http_trigger.cpp bindings/http_trigger_component_type.o -mexec-model=reactor -o main.wasm" +watch = ["**/*.cpp"] diff --git a/templates/http-cpp/metadata/spin-template.toml b/templates/http-cpp/metadata/spin-template.toml new file mode 100644 index 0000000000..08dc028803 --- /dev/null +++ b/templates/http-cpp/metadata/spin-template.toml @@ -0,0 +1,8 @@ +manifest_version = "1" +id = "http-cpp" +description = "HTTP request handler using WASI P2, C++ and the WASI-SDK toolchain" +tags = ["http", "cpp", "c++"] + +[parameters] +project-description = { type = "string", prompt = "Description", default = "" } +http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }