Skip to content

Instantly share code, notes, and snippets.

@ydnar
Last active December 13, 2023 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ydnar/5cfbbdd3fd73a34754e4cf0cb3952b16 to your computer and use it in GitHub Desktop.
Save ydnar/5cfbbdd3fd73a34754e4cf0cb3952b16 to your computer and use it in GitHub Desktop.
wasi:cli/command

wasi:cli/command

Generating

  1. Install the wit-bindgen-cli crate via cargo install wit-bindgen-cli.
  2. Check out the wasi:cli repo.
  3. Run wit-bindgen c --world command wit in the wasi-cli directory.
// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT!
#include "command.h"
__attribute__((__import_module__("wasi:cli/environment@0.2.0-rc-2023-12-05"), __import_name__("get-environment")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_get_environment(int32_t);
__attribute__((__import_module__("wasi:cli/environment@0.2.0-rc-2023-12-05"), __import_name__("get-arguments")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_get_arguments(int32_t);
__attribute__((__import_module__("wasi:cli/environment@0.2.0-rc-2023-12-05"), __import_name__("initial-cwd")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_initial_cwd(int32_t);
__attribute__((__import_module__("wasi:cli/exit@0.2.0-rc-2023-12-05"), __import_name__("exit")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_exit_exit(int32_t);
__attribute__((__import_module__("wasi:io/error@0.2.0-rc-2023-11-10"), __import_name__("[method]error.to-debug-string")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_error_method_error_to_debug_string(int32_t, int32_t);
__attribute__((__import_module__("wasi:io/poll@0.2.0-rc-2023-11-10"), __import_name__("[method]pollable.ready")))
extern int32_t __wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_ready(int32_t);
__attribute__((__import_module__("wasi:io/poll@0.2.0-rc-2023-11-10"), __import_name__("[method]pollable.block")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_block(int32_t);
__attribute__((__import_module__("wasi:io/poll@0.2.0-rc-2023-11-10"), __import_name__("poll")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_poll(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]input-stream.read")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_read(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]input-stream.blocking-read")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_blocking_read(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]input-stream.skip")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_skip(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]input-stream.blocking-skip")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_blocking_skip(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]input-stream.subscribe")))
extern int32_t __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_subscribe(int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.check-write")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_check_write(int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.write")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_write(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.blocking-write-and-flush")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_write_and_flush(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.flush")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_flush(int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.blocking-flush")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_flush(int32_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.subscribe")))
extern int32_t __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_subscribe(int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.write-zeroes")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_write_zeroes(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.blocking-write-zeroes-and-flush")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_write_zeroes_and_flush(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.splice")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_splice(int32_t, int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[method]output-stream.blocking-splice")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_splice(int32_t, int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:cli/stdin@0.2.0-rc-2023-12-05"), __import_name__("get-stdin")))
extern int32_t __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stdin_get_stdin(void);
__attribute__((__import_module__("wasi:cli/stdout@0.2.0-rc-2023-12-05"), __import_name__("get-stdout")))
extern int32_t __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stdout_get_stdout(void);
__attribute__((__import_module__("wasi:cli/stderr@0.2.0-rc-2023-12-05"), __import_name__("get-stderr")))
extern int32_t __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stderr_get_stderr(void);
__attribute__((__import_module__("wasi:cli/terminal-stdin@0.2.0-rc-2023-12-05"), __import_name__("get-terminal-stdin")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_get_terminal_stdin(int32_t);
__attribute__((__import_module__("wasi:cli/terminal-stdout@0.2.0-rc-2023-12-05"), __import_name__("get-terminal-stdout")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_get_terminal_stdout(int32_t);
__attribute__((__import_module__("wasi:cli/terminal-stderr@0.2.0-rc-2023-12-05"), __import_name__("get-terminal-stderr")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_get_terminal_stderr(int32_t);
__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10"), __import_name__("now")))
extern int64_t __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_now(void);
__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10"), __import_name__("resolution")))
extern int64_t __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_resolution(void);
__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10"), __import_name__("subscribe-instant")))
extern int32_t __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_instant(int64_t);
__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10"), __import_name__("subscribe-duration")))
extern int32_t __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_duration(int64_t);
__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0-rc-2023-11-10"), __import_name__("now")))
extern void __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_now(int32_t);
__attribute__((__import_module__("wasi:clocks/wall-clock@0.2.0-rc-2023-11-10"), __import_name__("resolution")))
extern void __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_resolution(int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.read-via-stream")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read_via_stream(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.write-via-stream")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write_via_stream(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.append-via-stream")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_append_via_stream(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.advise")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.sync-data")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_sync_data(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.get-flags")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_get_flags(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.get-type")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_get_type(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.set-size")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.set-times")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.read")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read(int32_t, int64_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.write")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write(int32_t, int32_t, int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.read-directory")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read_directory(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.sync")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_sync(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.create-directory-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_create_directory_at(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.stat")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_stat(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.stat-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_stat_at(int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.set-times-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_times_at(int32_t, int32_t, int32_t, int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.link-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_link_at(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.open-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_open_at(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.readlink-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_readlink_at(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.remove-directory-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_remove_directory_at(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.rename-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_rename_at(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.symlink-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_symlink_at(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.unlink-file-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_unlink_file_at(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.is-same-object")))
extern int32_t __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_is_same_object(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.metadata-hash")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_metadata_hash(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]descriptor.metadata-hash-at")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_metadata_hash_at(int32_t, int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[method]directory-entry-stream.read-directory-entry")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_directory_entry_stream_read_directory_entry(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("filesystem-error-code")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_filesystem_error_code(int32_t, int32_t);
__attribute__((__import_module__("wasi:filesystem/preopens@0.2.0-rc-2023-11-10"), __import_name__("get-directories")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_preopens_get_directories(int32_t);
__attribute__((__import_module__("wasi:sockets/instance-network@0.2.0-rc-2023-11-10"), __import_name__("instance-network")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_instance_network_instance_network(void);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.start-bind")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.finish-bind")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_finish_bind(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.stream")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.local-address")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_local_address(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.remote-address")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_remote_address(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.address-family")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_address_family(int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.ipv6-only")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_ipv6_only(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.set-ipv6-only")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_ipv6_only(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.unicast-hop-limit")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_unicast_hop_limit(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.set-unicast-hop-limit")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.receive-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_receive_buffer_size(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.set-receive-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.send-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_send_buffer_size(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.set-send-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_send_buffer_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]udp-socket.subscribe")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_subscribe(int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]incoming-datagram-stream.receive")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_receive(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]incoming-datagram-stream.subscribe")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_subscribe(int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]outgoing-datagram-stream.check-send")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_check_send(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]outgoing-datagram-stream.send")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_send(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[method]outgoing-datagram-stream.subscribe")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_subscribe(int32_t);
__attribute__((__import_module__("wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10"), __import_name__("create-udp-socket")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_create_udp_socket(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.start-bind")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.finish-bind")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_bind(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.start-connect")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.finish-connect")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_connect(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.start-listen")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_start_listen(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.finish-listen")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_listen(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.accept")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_accept(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.local-address")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_local_address(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.remote-address")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_remote_address(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.is-listening")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_is_listening(int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.address-family")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_address_family(int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.ipv6-only")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_ipv6_only(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-ipv6-only")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_ipv6_only(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-listen-backlog-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.keep-alive-enabled")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_enabled(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-keep-alive-enabled")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.keep-alive-idle-time")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_idle_time(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.keep-alive-interval")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_interval(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-keep-alive-interval")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.keep-alive-count")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_count(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-keep-alive-count")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.hop-limit")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_hop_limit(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-hop-limit")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_hop_limit(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.receive-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_receive_buffer_size(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-receive-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.send-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_send_buffer_size(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.set-send-buffer-size")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.subscribe")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_subscribe(int32_t);
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[method]tcp-socket.shutdown")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_shutdown(int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10"), __import_name__("create-tcp-socket")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_create_tcp_socket(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10"), __import_name__("resolve-addresses")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_addresses(int32_t, int32_t, int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10"), __import_name__("[method]resolve-address-stream.resolve-next-address")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_resolve_next_address(int32_t, int32_t);
__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10"), __import_name__("[method]resolve-address-stream.subscribe")))
extern int32_t __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_subscribe(int32_t);
__attribute__((__import_module__("wasi:random/random@0.2.0-rc-2023-11-10"), __import_name__("get-random-bytes")))
extern void __wasm_import_wasi_random_0_2_0_rc_2023_11_10_random_get_random_bytes(int64_t, int32_t);
__attribute__((__import_module__("wasi:random/random@0.2.0-rc-2023-11-10"), __import_name__("get-random-u64")))
extern int64_t __wasm_import_wasi_random_0_2_0_rc_2023_11_10_random_get_random_u64(void);
__attribute__((__import_module__("wasi:random/insecure@0.2.0-rc-2023-11-10"), __import_name__("get-insecure-random-bytes")))
extern void __wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_bytes(int64_t, int32_t);
__attribute__((__import_module__("wasi:random/insecure@0.2.0-rc-2023-11-10"), __import_name__("get-insecure-random-u64")))
extern int64_t __wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_u64(void);
__attribute__((__import_module__("wasi:random/insecure-seed@0.2.0-rc-2023-11-10"), __import_name__("insecure-seed")))
extern void __wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_seed_insecure_seed(int32_t);
__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 wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_t *ptr) {
command_string_free(&ptr->f0);
command_string_free(&ptr->f1);
}
void wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_free(&ptr->ptr[i]);
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
command_string_free(&ptr->ptr[i]);
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_cli_0_2_0_rc_2023_12_05_environment_option_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_option_string_t *ptr) {
if (ptr->is_some) {
command_string_free(&ptr->val);
}
}
void wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_free(wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_t *ptr) {
if (!ptr->is_err) {
}
}
__attribute__((__import_module__("wasi:io/error@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]error")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_error_error_drop(int32_t handle);
void wasi_io_0_2_0_rc_2023_11_10_error_error_drop_own(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_error_error_drop(handle.__handle);
}
void wasi_io_0_2_0_rc_2023_11_10_error_error_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_error_error_drop(handle.__handle);
}
wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t wasi_io_0_2_0_rc_2023_11_10_error_borrow_error(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t arg) {
return (wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:io/poll@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]pollable")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop(int32_t handle);
void wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop_own(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop(handle.__handle);
}
void wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop(handle.__handle);
}
wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t arg) {
return (wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t) { arg.__handle };
}
void wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_free(wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_free(wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *ptr) {
switch ((int32_t) ptr->tag) {
case 0: {
break;
}
}
}
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]input-stream")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop(int32_t handle);
void wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop_own(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop(handle.__handle);
}
void wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop(handle.__handle);
}
wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t arg) {
return (wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:io/streams@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]output-stream")))
extern void __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop(int32_t handle);
void wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop_own(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop(handle.__handle);
}
void wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t handle) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop(handle.__handle);
}
wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t arg) {
return (wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t) { arg.__handle };
}
void wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_free(wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_t *ptr) {
if (!ptr->is_err) {
wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_free(&ptr->val.ok);
} else {
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_free(&ptr->val.err);
}
}
void wasi_io_0_2_0_rc_2023_11_10_streams_result_u64_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_u64_stream_error_t *ptr) {
if (!ptr->is_err) {
} else {
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_free(&ptr->val.err);
}
}
void wasi_io_0_2_0_rc_2023_11_10_streams_result_void_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_void_stream_error_t *ptr) {
if (!ptr->is_err) {
} else {
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_free(&ptr->val.err);
}
}
__attribute__((__import_module__("wasi:cli/terminal-input@0.2.0-rc-2023-12-05"), __import_name__("[resource-drop]terminal-input")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop(int32_t handle);
void wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop_own(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t handle) {
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop(handle.__handle);
}
void wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop_borrow(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t handle) {
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop(handle.__handle);
}
wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input_t wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t arg) {
return (wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:cli/terminal-output@0.2.0-rc-2023-12-05"), __import_name__("[resource-drop]terminal-output")))
extern void __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop(int32_t handle);
void wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop_own(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t handle) {
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop(handle.__handle);
}
void wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop_borrow(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t handle) {
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop(handle.__handle);
}
wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output_t wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t arg) {
return (wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output_t) { arg.__handle };
}
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_option_own_terminal_input_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_option_own_terminal_input_t *ptr) {
if (ptr->is_some) {
}
}
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_option_own_terminal_output_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_option_own_terminal_output_t *ptr) {
if (ptr->is_some) {
}
}
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_option_own_terminal_output_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_option_own_terminal_output_t *ptr) {
if (ptr->is_some) {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_t *ptr) {
if (ptr->is_some) {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ptr) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_free(&ptr->data_access_timestamp);
wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_free(&ptr->data_modification_timestamp);
wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_free(&ptr->status_change_timestamp);
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *ptr) {
switch ((int32_t) ptr->tag) {
case 2: {
break;
}
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_t *ptr) {
command_string_free(&ptr->name);
}
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]descriptor")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop(int32_t handle);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop_own(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t handle) {
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop(handle.__handle);
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop_borrow(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t handle) {
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop(handle.__handle);
}
wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t arg) {
return (wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:filesystem/types@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]directory-entry-stream")))
extern void __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop(int32_t handle);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop_own(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t handle) {
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop(handle.__handle);
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop_borrow(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t handle) {
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop(handle.__handle);
}
wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t arg) {
return (wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t) { arg.__handle };
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_input_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_input_stream_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_output_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_output_stream_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_void_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_void_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_flags_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_flags_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_type_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_type_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t *ptr) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_free(&ptr->f0);
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_tuple2_list_u8_bool_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_free(&ptr->val.ok);
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_filesize_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_filesize_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_directory_entry_stream_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_stat_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_stat_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_free(&ptr->val.ok);
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_descriptor_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_descriptor_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_t *ptr) {
if (!ptr->is_err) {
command_string_free(&ptr->val.ok);
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_metadata_hash_value_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_metadata_hash_value_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t *ptr) {
if (ptr->is_some) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_free(&ptr->val);
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_option_directory_entry_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_option_directory_entry_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_free(&ptr->val.ok);
} else {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_error_code_t *ptr) {
if (ptr->is_some) {
}
}
void wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_t *ptr) {
command_string_free(&ptr->f1);
}
void wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_free(&ptr->ptr[i]);
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
__attribute__((__import_module__("wasi:sockets/network@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]network")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t) { arg.__handle };
}
void wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_t *ptr) {
switch ((int32_t) ptr->tag) {
case 0: {
break;
}
case 1: {
break;
}
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_t *ptr) {
switch ((int32_t) ptr->tag) {
case 0: {
break;
}
case 1: {
break;
}
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ptr) {
wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_free(ptr);
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_t *ptr) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_free(&ptr->data);
wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_free(&ptr->remote_address);
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_t *ptr) {
if (ptr->is_some) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_free(&ptr->val);
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_t *ptr) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_free(&ptr->data);
wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_free(&ptr->remote_address);
}
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]udp-socket")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]incoming-datagram-stream")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t) { arg.__handle };
}
__attribute__((__import_module__("wasi:sockets/udp@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]outgoing-datagram-stream")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t) { arg.__handle };
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_void_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_void_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_ip_socket_address_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_free(&ptr->val.ok);
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_bool_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_bool_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u8_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u8_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u64_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u64_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_free(&ptr->ptr[i]);
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_list_incoming_datagram_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_free(&ptr->val.ok);
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_free(&ptr->ptr[i]);
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_result_own_udp_socket_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ptr) {
wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_free(ptr);
}
__attribute__((__import_module__("wasi:sockets/tcp@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]tcp-socket")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t) { arg.__handle };
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_void_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_void_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_ip_socket_address_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_free(&ptr->val.ok);
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_bool_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_bool_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_duration_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_duration_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u32_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u32_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u8_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u8_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u64_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u64_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_t *ptr) {
wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_free(ptr);
}
__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10"), __import_name__("[resource-drop]resolve-address-stream")))
extern void __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop(int32_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop(handle.__handle);
}
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t handle) {
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop(handle.__handle);
}
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t arg) {
return (wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t) { arg.__handle };
}
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr) {
if (!ptr->is_err) {
} else {
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t *ptr) {
if (ptr->is_some) {
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_free(&ptr->val);
}
}
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_option_ip_address_error_code_t *ptr) {
if (!ptr->is_err) {
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_free(&ptr->val.ok);
} else {
}
}
void wasi_random_0_2_0_rc_2023_11_10_random_list_u8_free(wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t *ptr) {
for (size_t i = 0; i < ptr->len; i++) {
}
if (ptr->len > 0) {
free(ptr->ptr);
}
}
void exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_free(exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_t *ptr) {
if (!ptr->is_err) {
}
}
void command_string_set(command_string_t *ret, char*s) {
ret->ptr = (uint8_t*) s;
ret->len = strlen(s);
}
void command_string_dup(command_string_t *ret, const char*s) {
ret->len = strlen(s);
ret->ptr = cabi_realloc(NULL, 0, 1, ret->len * 1);
memcpy(ret->ptr, s, ret->len * 1);
}
void command_string_free(command_string_t *ret) {
if (ret->len > 0) {
free(ret->ptr);
}
ret->ptr = NULL;
ret->len = 0;
}
// Component Adapters
void wasi_cli_0_2_0_rc_2023_12_05_environment_get_environment(wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_get_environment(ptr);
*ret = (wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t) { (wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
void wasi_cli_0_2_0_rc_2023_12_05_environment_get_arguments(wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_get_arguments(ptr);
*ret = (wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_t) { (command_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
bool wasi_cli_0_2_0_rc_2023_12_05_environment_initial_cwd(command_string_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_environment_initial_cwd(ptr);
wasi_cli_0_2_0_rc_2023_12_05_environment_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 = (command_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) };
break;
}
}
*ret = option.val;
return option.is_some;
}
void wasi_cli_0_2_0_rc_2023_12_05_exit_exit(wasi_cli_0_2_0_rc_2023_12_05_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_rc_2023_12_05_exit_exit(result);
}
void wasi_io_0_2_0_rc_2023_11_10_error_method_error_to_debug_string(wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t self, command_string_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_error_method_error_to_debug_string((self).__handle, ptr);
*ret = (command_string_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
bool wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_ready(wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t self) {
int32_t ret = __wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_ready((self).__handle);
return ret;
}
void wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_block(wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t self) {
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_method_pollable_block((self).__handle);
}
void wasi_io_0_2_0_rc_2023_11_10_poll_poll(wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_t *in, wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_poll_poll((int32_t) (*in).ptr, (int32_t) (*in).len, ptr);
*ret = (wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t) { (uint32_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
bool wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_read(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_read((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_t result;
switch ((int32_t) (*((uint8_t*) (ptr + 0)))) {
case 0: {
result.is_err = false;
result.val.ok = (wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) };
break;
}
case 1: {
result.is_err = true;
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_own_error_t) { *((int32_t*) (ptr + 8)) };
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_rc_2023_11_10_streams_method_input_stream_blocking_read(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_blocking_read((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_t result;
switch ((int32_t) (*((uint8_t*) (ptr + 0)))) {
case 0: {
result.is_err = false;
result.val.ok = (wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) };
break;
}
case 1: {
result.is_err = true;
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_own_error_t) { *((int32_t*) (ptr + 8)) };
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_rc_2023_11_10_streams_method_input_stream_skip(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_skip((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_input_stream_blocking_skip(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_blocking_skip((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_own_pollable_t wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_subscribe(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self) {
int32_t ret = __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_subscribe((self).__handle);
return (wasi_io_0_2_0_rc_2023_11_10_streams_own_pollable_t) { ret };
}
bool wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_check_write(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_check_write((self).__handle, ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_write(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *contents, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_write((self).__handle, (int32_t) (*contents).ptr, (int32_t) (*contents).len, ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_write_and_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *contents, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_write_and_flush((self).__handle, (int32_t) (*contents).ptr, (int32_t) (*contents).len, ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_flush((self).__handle, ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_flush((self).__handle, ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_own_pollable_t wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_subscribe(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self) {
int32_t ret = __wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_subscribe((self).__handle);
return (wasi_io_0_2_0_rc_2023_11_10_streams_own_pollable_t) { ret };
}
bool wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_write_zeroes(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_write_zeroes((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_write_zeroes_and_flush((self).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_splice(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_splice((self).__handle, (src).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_splice(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_blocking_splice((self).__handle, (src).__handle, (int64_t) (len), ptr);
wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_cli_0_2_0_rc_2023_12_05_stdin_own_input_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdin_get_stdin(void) {
int32_t ret = __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stdin_get_stdin();
return (wasi_cli_0_2_0_rc_2023_12_05_stdin_own_input_stream_t) { ret };
}
wasi_cli_0_2_0_rc_2023_12_05_stdout_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdout_get_stdout(void) {
int32_t ret = __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stdout_get_stdout();
return (wasi_cli_0_2_0_rc_2023_12_05_stdout_own_output_stream_t) { ret };
}
wasi_cli_0_2_0_rc_2023_12_05_stderr_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stderr_get_stderr(void) {
int32_t ret = __wasm_import_wasi_cli_0_2_0_rc_2023_12_05_stderr_get_stderr();
return (wasi_cli_0_2_0_rc_2023_12_05_stderr_own_output_stream_t) { ret };
}
bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_get_terminal_stdin(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_own_terminal_input_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_get_terminal_stdin(ptr);
wasi_cli_0_2_0_rc_2023_12_05_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_rc_2023_12_05_terminal_stdin_own_terminal_input_t) { *((int32_t*) (ptr + 4)) };
break;
}
}
*ret = option.val;
return option.is_some;
}
bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_get_terminal_stdout(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_own_terminal_output_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_get_terminal_stdout(ptr);
wasi_cli_0_2_0_rc_2023_12_05_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_rc_2023_12_05_terminal_stdout_own_terminal_output_t) { *((int32_t*) (ptr + 4)) };
break;
}
}
*ret = option.val;
return option.is_some;
}
bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_get_terminal_stderr(wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_own_terminal_output_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_get_terminal_stderr(ptr);
wasi_cli_0_2_0_rc_2023_12_05_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_rc_2023_12_05_terminal_stderr_own_terminal_output_t) { *((int32_t*) (ptr + 4)) };
break;
}
}
*ret = option.val;
return option.is_some;
}
wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_instant_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_now(void) {
int64_t ret = __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_now();
return (uint64_t) (ret);
}
wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_duration_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_resolution(void) {
int64_t ret = __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_resolution();
return (uint64_t) (ret);
}
wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_instant(wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_instant_t when) {
int32_t ret = __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_instant((int64_t) (when));
return (wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t) { ret };
}
wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_duration(wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_duration_t when) {
int32_t ret = __wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_duration((int64_t) (when));
return (wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t) { ret };
}
void wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_now(wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t *ret) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_now(ptr);
*ret = (wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 0))),
(uint32_t) (*((int32_t*) (ptr + 8))),
};
}
void wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_resolution(wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t *ret) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_resolution(ptr);
*ret = (wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 0))),
(uint32_t) (*((int32_t*) (ptr + 8))),
};
}
bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_input_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read_via_stream((self).__handle, (int64_t) (offset), ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_write_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write_via_stream((self).__handle, (int64_t) (offset), ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_append_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_append_via_stream((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_advise(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t length, wasi_filesystem_0_2_0_rc_2023_11_10_types_advice_t advice, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_advise((self).__handle, (int64_t) (offset), (int64_t) (length), (int32_t) advice, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_sync_data(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_sync_data((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_get_flags(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_flags_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_get_flags((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_get_type(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_type_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_get_type((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_set_size(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t size, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_size((self).__handle, (int64_t) (size), ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_set_times(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp;
variant7 = 2;
variant8 = (int64_t) ((*payload6).seconds);
variant9 = (int32_t) ((*payload6).nanoseconds);
break;
}
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_times((self).__handle, variant, variant2, variant3, variant7, variant8, variant9, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_read(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t length, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read((self).__handle, (int64_t) (length), (int64_t) (offset), ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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 = (wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t) {
(wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) },
(int32_t) (*((uint8_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_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t *buffer, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write((self).__handle, (int32_t) (*buffer).ptr, (int32_t) (*buffer).len, (int64_t) (offset), ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_read_directory(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read_directory((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_sync(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_sync((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_create_directory_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_create_directory_at((self).__handle, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_stat(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[104];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_stat((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 40))),
(uint32_t) (*((int32_t*) (ptr + 48))),
};
break;
}
}
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 64))),
(uint32_t) (*((int32_t*) (ptr + 72))),
};
break;
}
}
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 88))),
(uint32_t) (*((int32_t*) (ptr + 96))),
};
break;
}
}
result.val.ok = (wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t) {
(int32_t) (*((uint8_t*) (ptr + 8))),
(uint64_t) (*((int64_t*) (ptr + 16))),
(uint64_t) (*((int64_t*) (ptr + 24))),
option,
option0,
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_rc_2023_11_10_types_method_descriptor_stat_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[104];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_stat_at((self).__handle, path_flags, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 40))),
(uint32_t) (*((int32_t*) (ptr + 48))),
};
break;
}
}
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 64))),
(uint32_t) (*((int32_t*) (ptr + 72))),
};
break;
}
}
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_wall_clock_datetime_t) {
(uint64_t) (*((int64_t*) (ptr + 88))),
(uint32_t) (*((int32_t*) (ptr + 96))),
};
break;
}
}
result.val.ok = (wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t) {
(int32_t) (*((uint8_t*) (ptr + 8))),
(uint64_t) (*((int64_t*) (ptr + 16))),
(uint64_t) (*((int64_t*) (ptr + 24))),
option,
option0,
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_rc_2023_11_10_types_method_descriptor_set_times_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_datetime_t *payload6 = &(*data_modification_timestamp).val.timestamp;
variant7 = 2;
variant8 = (int64_t) ((*payload6).seconds);
variant9 = (int32_t) ((*payload6).nanoseconds);
break;
}
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_set_times_at((self).__handle, path_flags, (int32_t) (*path).ptr, (int32_t) (*path).len, variant, variant2, variant3, variant7, variant8, variant9, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_link_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t old_path_flags, command_string_t *old_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t new_descriptor, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_link_at((self).__handle, old_path_flags, (int32_t) (*old_path).ptr, (int32_t) (*old_path).len, (new_descriptor).__handle, (int32_t) (*new_path).ptr, (int32_t) (*new_path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_open_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_open_flags_t open_flags, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_flags_t flags, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_open_at((self).__handle, path_flags, (int32_t) (*path).ptr, (int32_t) (*path).len, open_flags, flags, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_readlink_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, command_string_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_readlink_at((self).__handle, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_t result;
switch ((int32_t) (*((uint8_t*) (ptr + 0)))) {
case 0: {
result.is_err = false;
result.val.ok = (command_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_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_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_remove_directory_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_remove_directory_at((self).__handle, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_rename_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *old_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t new_descriptor, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_rename_at((self).__handle, (int32_t) (*old_path).ptr, (int32_t) (*old_path).len, (new_descriptor).__handle, (int32_t) (*new_path).ptr, (int32_t) (*new_path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_symlink_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *old_path, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_symlink_at((self).__handle, (int32_t) (*old_path).ptr, (int32_t) (*old_path).len, (int32_t) (*new_path).ptr, (int32_t) (*new_path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_unlink_file_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_unlink_file_at((self).__handle, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_is_same_object(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t other) {
int32_t ret = __wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_is_same_object((self).__handle, (other).__handle);
return ret;
}
bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_metadata_hash(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[24];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_metadata_hash((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_metadata_hash_value_t) {
(uint64_t) (*((int64_t*) (ptr + 8))),
(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_rc_2023_11_10_types_method_descriptor_metadata_hash_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[24];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_metadata_hash_at((self).__handle, path_flags, (int32_t) (*path).ptr, (int32_t) (*path).len, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_metadata_hash_value_t) {
(uint64_t) (*((int64_t*) (ptr + 8))),
(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_rc_2023_11_10_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[20];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_method_directory_entry_stream_read_directory_entry((self).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_option_directory_entry_t option;
switch ((int32_t) (*((uint8_t*) (ptr + 4)))) {
case 0: {
option.is_some = false;
break;
}
case 1: {
option.is_some = true;
option.val = (wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_t) {
(int32_t) (*((uint8_t*) (ptr + 8))),
(command_string_t) { (uint8_t*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) },
};
break;
}
}
result.val.ok = option;
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_rc_2023_11_10_types_filesystem_error_code(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_error_t err_, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *ret) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_types_filesystem_error_code((err_).__handle, ptr);
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_preopens_get_directories(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_filesystem_0_2_0_rc_2023_11_10_preopens_get_directories(ptr);
*ret = (wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t) { (wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
wasi_sockets_0_2_0_rc_2023_11_10_instance_network_own_network_t wasi_sockets_0_2_0_rc_2023_11_10_instance_network_instance_network(void) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_instance_network_instance_network();
return (wasi_sockets_0_2_0_rc_2023_11_10_instance_network_own_network_t) { ret };
}
bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_start_bind(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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;
}
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_finish_bind(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_finish_bind((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_0_2_0_rc_2023_11_10_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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;
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t) {
(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t) { *((int32_t*) (ptr + 4)) },
(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_local_address(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[36];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_local_address((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_network_ipv4_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t) {
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 10)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 11)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 12)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 13)))),
},
};
break;
}
case 1: {
variant.val.ipv6 = (wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(uint32_t) (*((int32_t*) (ptr + 12))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 16)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 18)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 20)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 22)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 24)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 26)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 28)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 30)))),
},
(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_rc_2023_11_10_udp_method_udp_socket_remote_address(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[36];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_remote_address((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_network_ipv4_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t) {
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 10)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 11)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 12)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 13)))),
},
};
break;
}
case 1: {
variant.val.ipv6 = (wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(uint32_t) (*((int32_t*) (ptr + 12))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 16)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 18)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 20)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 22)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 24)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 26)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 28)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 30)))),
},
(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_rc_2023_11_10_udp_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_address_family(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_address_family((self).__handle);
return ret;
}
bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_ipv6_only((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_udp_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_rc_2023_11_10_udp_method_udp_socket_set_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_ipv6_only((self).__handle, value, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_unicast_hop_limit((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_unicast_hop_limit((self).__handle, (int32_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_receive_buffer_size((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_send_buffer_size((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_subscribe((self).__handle);
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_own_pollable_t) { ret };
}
bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_receive(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_receive((self).__handle, (int64_t) (max_results), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_list_incoming_datagram_t) { (wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_t*)(*((int32_t*) (ptr + 4))), (size_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;
}
}
wasi_sockets_0_2_0_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_subscribe((self).__handle);
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_own_pollable_t) { ret };
}
bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_check_send((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_outgoing_datagram_stream_send(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_send((self).__handle, (int32_t) (*datagrams).ptr, (int32_t) (*datagrams).len, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_subscribe((self).__handle);
return (wasi_sockets_0_2_0_rc_2023_11_10_udp_own_pollable_t) { ret };
}
bool wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_create_udp_socket(wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_create_udp_socket((int32_t) address_family, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_start_bind(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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;
}
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_finish_bind(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_bind((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_start_connect(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *remote_address, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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;
}
}
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_finish_connect(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[12];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_connect((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_tuple2_own_input_stream_own_output_stream_t) {
(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_input_stream_t) { *((int32_t*) (ptr + 4)) },
(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_start_listen(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_start_listen((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_finish_listen(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_listen((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_accept(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_accept((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t) {
(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t) { *((int32_t*) (ptr + 4)) },
(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_input_stream_t) { *((int32_t*) (ptr + 8)) },
(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_local_address(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[36];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_local_address((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_network_ipv4_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t) {
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 10)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 11)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 12)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 13)))),
},
};
break;
}
case 1: {
variant.val.ipv6 = (wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(uint32_t) (*((int32_t*) (ptr + 12))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 16)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 18)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 20)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 22)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 24)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 26)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 28)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 30)))),
},
(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_rc_2023_11_10_tcp_method_tcp_socket_remote_address(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[36];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_remote_address((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_network_ipv4_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t) {
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 10)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 11)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 12)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 13)))),
},
};
break;
}
case 1: {
variant.val.ipv6 = (wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(uint32_t) (*((int32_t*) (ptr + 12))),
(wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 16)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 18)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 20)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 22)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 24)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 26)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 28)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 30)))),
},
(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_rc_2023_11_10_tcp_method_tcp_socket_is_listening(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_is_listening((self).__handle);
return ret;
}
wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_address_family(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_address_family((self).__handle);
return ret;
}
bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_ipv6_only((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_ipv6_only((self).__handle, value, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_listen_backlog_size((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_enabled((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_enabled((self).__handle, value, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_idle_time((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_idle_time((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_interval((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_interval((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_count((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_count((self).__handle, (int32_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_hop_limit((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_hop_limit((self).__handle, (int32_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_receive_buffer_size((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_receive_buffer_size((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_send_buffer_size((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_send_buffer_size((self).__handle, (int64_t) (value), ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_subscribe((self).__handle);
return (wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_pollable_t) { ret };
}
bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_shutdown(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_shutdown_type_t shutdown_type, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err) {
__attribute__((__aligned__(1)))
uint8_t ret_area[2];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_shutdown((self).__handle, (int32_t) shutdown_type, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_create_socket_create_tcp_socket(wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_create_tcp_socket((int32_t) address_family, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_ip_name_lookup_resolve_addresses(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_network_t network, command_string_t *name, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_error_code_t *err) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_addresses((network).__handle, (int32_t) (*name).ptr, (int32_t) (*name).len, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_error_code_t *err) {
__attribute__((__aligned__(2)))
uint8_t ret_area[22];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_resolve_next_address((self).__handle, ptr);
wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_network_ipv4_address_t) {
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 6)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 7)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 8)))),
(uint8_t) ((int32_t) (*((uint8_t*) (ptr + 9)))),
};
break;
}
case 1: {
variant.val.ipv6 = (wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t) {
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 6)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 8)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 10)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 12)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 14)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 16)))),
(uint16_t) ((int32_t) (*((uint16_t*) (ptr + 18)))),
(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_rc_2023_11_10_ip_name_lookup_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t self) {
int32_t ret = __wasm_import_wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_subscribe((self).__handle);
return (wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_pollable_t) { ret };
}
void wasi_random_0_2_0_rc_2023_11_10_random_get_random_bytes(uint64_t len, wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_random_0_2_0_rc_2023_11_10_random_get_random_bytes((int64_t) (len), ptr);
*ret = (wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
uint64_t wasi_random_0_2_0_rc_2023_11_10_random_get_random_u64(void) {
int64_t ret = __wasm_import_wasi_random_0_2_0_rc_2023_11_10_random_get_random_u64();
return (uint64_t) (ret);
}
void wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_bytes(uint64_t len, wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t *ret) {
__attribute__((__aligned__(4)))
uint8_t ret_area[8];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_bytes((int64_t) (len), ptr);
*ret = (wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) };
}
uint64_t wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_u64(void) {
int64_t ret = __wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_get_insecure_random_u64();
return (uint64_t) (ret);
}
void wasi_random_0_2_0_rc_2023_11_10_insecure_seed_insecure_seed(wasi_random_0_2_0_rc_2023_11_10_insecure_seed_tuple2_u64_u64_t *ret) {
__attribute__((__aligned__(8)))
uint8_t ret_area[16];
int32_t ptr = (int32_t) &ret_area;
__wasm_import_wasi_random_0_2_0_rc_2023_11_10_insecure_seed_insecure_seed(ptr);
*ret = (wasi_random_0_2_0_rc_2023_11_10_insecure_seed_tuple2_u64_u64_t) {
(uint64_t) (*((int64_t*) (ptr + 0))),
(uint64_t) (*((int64_t*) (ptr + 8))),
};
}
__attribute__((__export_name__("wasi:cli/run@0.2.0-rc-2023-12-05#run")))
int32_t __wasm_export_exports_wasi_cli_0_2_0_rc_2023_12_05_run_run(void) {
exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_t ret;
ret.is_err = !exports_wasi_cli_0_2_0_rc_2023_12_05_run_run();
int32_t result;
if ((ret).is_err) {
result = 1;
} else {
result = 0;
}
return result;
}
extern void __component_type_object_force_link_command(void);
void __component_type_object_force_link_command_public_use_in_this_compilation_unit(void) {
__component_type_object_force_link_command();
}
// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT!
#ifndef __BINDINGS_COMMAND_H
#define __BINDINGS_COMMAND_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct {
uint8_t*ptr;
size_t len;
} command_string_t;
typedef struct {
command_string_t f0;
command_string_t f1;
} wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_t;
typedef struct {
wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_t *ptr;
size_t len;
} wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t;
typedef struct {
command_string_t *ptr;
size_t len;
} wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_t;
typedef struct {
bool is_some;
command_string_t val;
} wasi_cli_0_2_0_rc_2023_12_05_environment_option_string_t;
typedef struct {
bool is_err;
} wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_error_own_error_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_error_own_error_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t;
typedef struct {
wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t *ptr;
size_t len;
} wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_t;
typedef struct {
uint32_t *ptr;
size_t len;
} wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t;
typedef wasi_io_0_2_0_rc_2023_11_10_error_own_error_t wasi_io_0_2_0_rc_2023_11_10_streams_own_error_t;
// An error for input-stream and output-stream operations.
typedef struct {
uint8_t tag;
union {
wasi_io_0_2_0_rc_2023_11_10_streams_own_error_t last_operation_failed;
} val;
} wasi_io_0_2_0_rc_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_STREAMS_STREAM_ERROR_CLOSED 1
typedef struct wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t;
typedef struct wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t {
int32_t __handle;
} wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t;
typedef struct {
uint8_t *ptr;
size_t len;
} wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t;
typedef struct {
bool is_err;
union {
wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t ok;
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t err;
} val;
} wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_t;
typedef struct {
bool is_err;
union {
uint64_t ok;
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t err;
} val;
} wasi_io_0_2_0_rc_2023_11_10_streams_result_u64_stream_error_t;
typedef wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t wasi_io_0_2_0_rc_2023_11_10_streams_own_pollable_t;
typedef struct {
bool is_err;
union {
wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t err;
} val;
} wasi_io_0_2_0_rc_2023_11_10_streams_result_void_stream_error_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdin_own_input_stream_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdout_own_output_stream_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stderr_own_output_stream_t;
typedef struct wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t {
int32_t __handle;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t;
typedef struct wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input_t {
int32_t __handle;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input_t;
typedef struct wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t {
int32_t __handle;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t;
typedef struct wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output_t {
int32_t __handle;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output_t;
typedef wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_own_terminal_input_t;
typedef struct {
bool is_some;
wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_own_terminal_input_t val;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_option_own_terminal_input_t;
typedef wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_own_terminal_output_t;
typedef struct {
bool is_some;
wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_own_terminal_output_t val;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_option_own_terminal_output_t;
typedef wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_own_terminal_output_t;
typedef struct {
bool is_some;
wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_own_terminal_output_t val;
} wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_option_own_terminal_output_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_rc_2023_11_10_monotonic_clock_instant_t;
// A duration of time, in nanoseconds.
typedef uint64_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_duration_t;
typedef wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t;
// A time and date in seconds plus nanoseconds.
typedef struct {
uint64_t seconds;
uint32_t nanoseconds;
} wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t;
typedef wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t wasi_filesystem_0_2_0_rc_2023_11_10_types_datetime_t;
// File size or length of a region within a file.
typedef uint64_t wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_UNKNOWN 0
// The descriptor refers to a block device inode.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_BLOCK_DEVICE 1
// The descriptor refers to a character device inode.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_CHARACTER_DEVICE 2
// The descriptor refers to a directory inode.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_DIRECTORY 3
// The descriptor refers to a named pipe.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_FIFO 4
// The file refers to a symbolic link inode.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_SYMBOLIC_LINK 5
// The descriptor refers to a regular file inode.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_TYPE_REGULAR_FILE 6
// The descriptor refers to a socket.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_rc_2023_11_10_types_descriptor_flags_t;
// Read mode: Data can be read.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_DESCRIPTOR_FLAGS_READ (1 << 0)
// Write mode: Data can be written to.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_TYPES_DESCRIPTOR_FLAGS_MUTATE_DIRECTORY (1 << 5)
// Flags determining the method of how paths are resolved.
typedef uint8_t wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t;
// As long as the resolved path corresponds to a symbolic link, it is
// expanded.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_PATH_FLAGS_SYMLINK_FOLLOW (1 << 0)
// Open flags used by `open-at`.
typedef uint8_t wasi_filesystem_0_2_0_rc_2023_11_10_types_open_flags_t;
// Create file if it does not exist, similar to `O_CREAT` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_OPEN_FLAGS_CREATE (1 << 0)
// Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_OPEN_FLAGS_DIRECTORY (1 << 1)
// Fail if file already exists, similar to `O_EXCL` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_OPEN_FLAGS_EXCLUSIVE (1 << 2)
// Truncate file to size 0, similar to `O_TRUNC` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_OPEN_FLAGS_TRUNCATE (1 << 3)
// Number of hard links to an inode.
typedef uint64_t wasi_filesystem_0_2_0_rc_2023_11_10_types_link_count_t;
typedef struct {
bool is_some;
wasi_filesystem_0_2_0_rc_2023_11_10_types_datetime_t val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_t;
// File attributes.
//
// Note: This was called `filestat` in earlier versions of WASI.
typedef struct {
// File type.
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_type_t type;
// Number of hard links to the file.
wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_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_rc_2023_11_10_types_option_datetime_t status_change_timestamp;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t;
// When setting a timestamp, this gives the value to set it to.
typedef struct {
uint8_t tag;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_datetime_t timestamp;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t;
// Leave the timestamp set to its previous value.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_RC_2023_11_10_TYPES_NEW_TIMESTAMP_NOW 1
// Set the timestamp to the given value.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_NEW_TIMESTAMP_TIMESTAMP 2
// A directory entry.
typedef struct {
// The type of the file referred to by this directory entry.
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_type_t type;
// The name of the object.
command_string_t name;
} wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_error_code_t;
// Permission denied, similar to `EACCES` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_ACCESS 0
// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_WOULD_BLOCK 1
// Connection already in progress, similar to `EALREADY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_ALREADY 2
// Bad descriptor, similar to `EBADF` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_BAD_DESCRIPTOR 3
// Device or resource busy, similar to `EBUSY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_BUSY 4
// Resource deadlock would occur, similar to `EDEADLK` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_DEADLOCK 5
// Storage quota exceeded, similar to `EDQUOT` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_QUOTA 6
// File exists, similar to `EEXIST` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_EXIST 7
// File too large, similar to `EFBIG` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_FILE_TOO_LARGE 8
// Illegal byte sequence, similar to `EILSEQ` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_ILLEGAL_BYTE_SEQUENCE 9
// Operation in progress, similar to `EINPROGRESS` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_IN_PROGRESS 10
// Interrupted function, similar to `EINTR` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_INTERRUPTED 11
// Invalid argument, similar to `EINVAL` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_INVALID 12
// I/O error, similar to `EIO` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_IO 13
// Is a directory, similar to `EISDIR` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_IS_DIRECTORY 14
// Too many levels of symbolic links, similar to `ELOOP` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_LOOP 15
// Too many links, similar to `EMLINK` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_TOO_MANY_LINKS 16
// Message too large, similar to `EMSGSIZE` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_MESSAGE_SIZE 17
// Filename too long, similar to `ENAMETOOLONG` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NAME_TOO_LONG 18
// No such device, similar to `ENODEV` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NO_DEVICE 19
// No such file or directory, similar to `ENOENT` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NO_ENTRY 20
// No locks available, similar to `ENOLCK` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NO_LOCK 21
// Not enough space, similar to `ENOMEM` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_INSUFFICIENT_MEMORY 22
// No space left on device, similar to `ENOSPC` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_RC_2023_11_10_TYPES_ERROR_CODE_NOT_DIRECTORY 24
// Directory not empty, similar to `ENOTEMPTY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NOT_EMPTY 25
// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NOT_RECOVERABLE 26
// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_UNSUPPORTED 27
// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NO_TTY 28
// No such device or address, similar to `ENXIO` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_RC_2023_11_10_TYPES_ERROR_CODE_OVERFLOW 30
// Operation not permitted, similar to `EPERM` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_NOT_PERMITTED 31
// Broken pipe, similar to `EPIPE` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_PIPE 32
// Read-only file system, similar to `EROFS` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_READ_ONLY 33
// Invalid seek, similar to `ESPIPE` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_INVALID_SEEK 34
// Text file busy, similar to `ETXTBSY` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_TEXT_FILE_BUSY 35
// Cross-device link, similar to `EXDEV` in POSIX.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ERROR_CODE_CROSS_DEVICE 36
// File or memory access pattern advisory information.
typedef uint8_t wasi_filesystem_0_2_0_rc_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_TYPES_ADVICE_SEQUENTIAL 1
// The application expects to access the specified data in a random
// order.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_TYPES_ADVICE_RANDOM 2
// The application expects to access the specified data in the near
// future.
#define WASI_FILESYSTEM_0_2_0_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_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 {
// 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_rc_2023_11_10_types_metadata_hash_value_t;
typedef struct wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t {
int32_t __handle;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t;
typedef struct wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t {
int32_t __handle;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t;
typedef struct wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t {
int32_t __handle;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t;
typedef struct wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t {
int32_t __handle;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t wasi_filesystem_0_2_0_rc_2023_11_10_types_own_input_stream_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_own_input_stream_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_input_stream_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_output_stream_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_void_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_flags_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_flags_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_type_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_type_error_code_t;
typedef struct {
uint8_t *ptr;
size_t len;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t;
typedef struct {
wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t f0;
bool f1;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_tuple2_list_u8_bool_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_filesize_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_directory_entry_stream_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_stat_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_descriptor_error_code_t;
typedef struct {
bool is_err;
union {
command_string_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_metadata_hash_value_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_metadata_hash_value_error_code_t;
typedef struct {
bool is_some;
wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_t val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t;
typedef struct {
bool is_err;
union {
wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t ok;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t err;
} val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_result_option_directory_entry_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_error_t;
typedef struct {
bool is_some;
wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t val;
} wasi_filesystem_0_2_0_rc_2023_11_10_types_option_error_code_t;
typedef wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t wasi_filesystem_0_2_0_rc_2023_11_10_preopens_own_descriptor_t;
typedef struct {
wasi_filesystem_0_2_0_rc_2023_11_10_preopens_own_descriptor_t f0;
command_string_t f1;
} wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_t;
typedef struct {
wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_t *ptr;
size_t len;
} wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_network_error_code_t;
// Unknown error
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_UNKNOWN 0
// Access denied.
//
// POSIX equivalent: EACCES, EPERM
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_ACCESS_DENIED 1
// The operation is not supported.
//
// POSIX equivalent: EOPNOTSUPP
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_NOT_SUPPORTED 2
// One of the arguments is invalid.
//
// POSIX equivalent: EINVAL
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_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_RC_2023_11_10_NETWORK_ERROR_CODE_OUT_OF_MEMORY 4
// The operation timed out before it could finish completely.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_NETWORK_ERROR_CODE_WOULD_BLOCK 8
// The operation is not valid in the socket's current state.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_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_RC_2023_11_10_NETWORK_ERROR_CODE_ADDRESS_IN_USE 12
// The remote address is not reachable
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_REMOTE_UNREACHABLE 13
// The connection was forcefully rejected
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_CONNECTION_REFUSED 14
// The connection was reset.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_CONNECTION_RESET 15
// A connection was aborted.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_CONNECTION_ABORTED 16
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_DATAGRAM_TOO_LARGE 17
// Name does not exist or has no suitable associated IP addresses.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_NAME_UNRESOLVABLE 18
// A temporary failure in name resolution occurred.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_TEMPORARY_RESOLVER_FAILURE 19
// A permanent failure in name resolution occurred.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_ERROR_CODE_PERMANENT_RESOLVER_FAILURE 20
typedef uint8_t wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_family_t;
// Similar to `AF_INET` in POSIX.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_ADDRESS_FAMILY_IPV4 0
// Similar to `AF_INET6` in POSIX.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_ADDRESS_FAMILY_IPV6 1
typedef struct {
uint8_t f0;
uint8_t f1;
uint8_t f2;
uint8_t f3;
} wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t;
typedef struct {
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_rc_2023_11_10_network_ipv6_address_t;
typedef struct {
uint8_t tag;
union {
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t ipv4;
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t ipv6;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_t;
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_ADDRESS_IPV4 0
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_ADDRESS_IPV6 1
typedef struct {
uint16_t port;
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_address_t address;
} wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_socket_address_t;
typedef struct {
uint16_t port;
uint32_t flow_info;
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_address_t address;
uint32_t scope_id;
} wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t;
typedef struct {
uint8_t tag;
union {
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv4_socket_address_t ipv4;
wasi_sockets_0_2_0_rc_2023_11_10_network_ipv6_socket_address_t ipv6;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_t;
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_SOCKET_ADDRESS_IPV4 0
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_NETWORK_IP_SOCKET_ADDRESS_IPV6 1
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t wasi_sockets_0_2_0_rc_2023_11_10_instance_network_own_network_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_error_code_t wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_t wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_address_family_t;
typedef struct {
uint8_t *ptr;
size_t len;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_t;
// A received datagram.
typedef struct {
// The payload.
//
// Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes.
wasi_sockets_0_2_0_rc_2023_11_10_udp_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_rc_2023_11_10_udp_ip_socket_address_t remote_address;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_t;
typedef struct {
bool is_some;
wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_t;
// A datagram to be sent out.
typedef struct {
// The payload.
wasi_sockets_0_2_0_rc_2023_11_10_udp_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_rc_2023_11_10_udp_option_ip_socket_address_t remote_address;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_network_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_void_error_code_t;
typedef struct {
wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t f0;
wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t f1;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_ip_socket_address_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_ip_socket_address_error_code_t;
typedef struct {
bool is_err;
union {
bool ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_bool_error_code_t;
typedef struct {
bool is_err;
union {
uint8_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u8_error_code_t;
typedef struct {
bool is_err;
union {
uint64_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u64_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_own_pollable_t;
typedef struct {
wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_t *ptr;
size_t len;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_result_list_incoming_datagram_error_code_t;
typedef struct {
wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_t *ptr;
size_t len;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_error_code_t wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_ip_address_family_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_own_udp_socket_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_own_udp_socket_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_result_own_udp_socket_error_code_t;
typedef wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_duration_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_error_code_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_address_family_t;
typedef uint8_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_shutdown_type_t;
// Similar to `SHUT_RD` in POSIX.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_TCP_SHUTDOWN_TYPE_RECEIVE 0
// Similar to `SHUT_WR` in POSIX.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_TCP_SHUTDOWN_TYPE_SEND 1
// Similar to `SHUT_RDWR` in POSIX.
#define WASI_SOCKETS_0_2_0_RC_2023_11_10_TCP_SHUTDOWN_TYPE_BOTH 2
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_network_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_void_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_input_stream_t;
typedef wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_output_stream_t;
typedef struct {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_input_stream_t f0;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_output_stream_t f1;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple2_own_input_stream_own_output_stream_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple2_own_input_stream_own_output_stream_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t;
typedef struct {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t f0;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_input_stream_t f1;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_output_stream_t f2;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_ip_socket_address_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_ip_socket_address_error_code_t;
typedef struct {
bool is_err;
union {
bool ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_bool_error_code_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_duration_error_code_t;
typedef struct {
bool is_err;
union {
uint32_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u32_error_code_t;
typedef struct {
bool is_err;
union {
uint8_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u8_error_code_t;
typedef struct {
bool is_err;
union {
uint64_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u64_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_pollable_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_error_code_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_ip_address_family_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_own_tcp_socket_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_own_tcp_socket_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_result_own_tcp_socket_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_error_code_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_error_code_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t;
typedef struct wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t {
int32_t __handle;
} wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t;
typedef wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_network_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_own_resolve_address_stream_error_code_t;
typedef struct {
bool is_some;
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_t val;
} wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t;
typedef struct {
bool is_err;
union {
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t ok;
wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_error_code_t err;
} val;
} wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_option_ip_address_error_code_t;
typedef wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_pollable_t;
typedef struct {
uint8_t *ptr;
size_t len;
} wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t;
typedef struct {
uint64_t f0;
uint64_t f1;
} wasi_random_0_2_0_rc_2023_11_10_insecure_seed_tuple2_u64_u64_t;
typedef struct {
bool is_err;
} exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_t;
// Imported Functions from `wasi:cli/environment@0.2.0-rc-2023-12-05`
// 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_rc_2023_12_05_environment_get_environment(wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t *ret);
// Get the POSIX-style arguments to the program.
extern void wasi_cli_0_2_0_rc_2023_12_05_environment_get_arguments(wasi_cli_0_2_0_rc_2023_12_05_environment_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_rc_2023_12_05_environment_initial_cwd(command_string_t *ret);
// Imported Functions from `wasi:cli/exit@0.2.0-rc-2023-12-05`
// Exit the current instance and any linked instances.
extern void wasi_cli_0_2_0_rc_2023_12_05_exit_exit(wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_t *status);
// Imported Functions from `wasi:io/error@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_error_method_error_to_debug_string(wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t self, command_string_t *ret);
// Imported Functions from `wasi:io/poll@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_poll_method_pollable_ready(wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_poll_method_pollable_block(wasi_io_0_2_0_rc_2023_11_10_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<u32>` 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_rc_2023_11_10_poll_poll(wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_t *in, wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t *ret);
// Imported Functions from `wasi:io/streams@0.2.0-rc-2023-11-10`
// Perform a non-blocking read from the stream.
//
// 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_rc_2023_11_10_streams_method_input_stream_read(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ret, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_input_stream_blocking_read(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ret, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_input_stream_skip(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_input_stream_blocking_skip(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t self, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_own_pollable_t wasi_io_0_2_0_rc_2023_11_10_streams_method_input_stream_subscribe(wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_check_write(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err);
// Perform a write. This function never blocks.
//
// 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_rc_2023_11_10_streams_method_output_stream_write(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *contents, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_write_and_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *contents, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_own_pollable_t wasi_io_0_2_0_rc_2023_11_10_streams_method_output_stream_subscribe(wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_write_zeroes(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_write_zeroes_and_flush(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, uint64_t len, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_splice(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_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_rc_2023_11_10_streams_method_output_stream_blocking_splice(wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t self, wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t src, uint64_t len, uint64_t *ret, wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *err);
// Imported Functions from `wasi:cli/stdin@0.2.0-rc-2023-12-05`
extern wasi_cli_0_2_0_rc_2023_12_05_stdin_own_input_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdin_get_stdin(void);
// Imported Functions from `wasi:cli/stdout@0.2.0-rc-2023-12-05`
extern wasi_cli_0_2_0_rc_2023_12_05_stdout_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stdout_get_stdout(void);
// Imported Functions from `wasi:cli/stderr@0.2.0-rc-2023-12-05`
extern wasi_cli_0_2_0_rc_2023_12_05_stderr_own_output_stream_t wasi_cli_0_2_0_rc_2023_12_05_stderr_get_stderr(void);
// Imported Functions from `wasi:cli/terminal-stdin@0.2.0-rc-2023-12-05`
// If stdin is connected to a terminal, return a `terminal-input` handle
// allowing further interaction with it.
extern bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_get_terminal_stdin(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_own_terminal_input_t *ret);
// Imported Functions from `wasi:cli/terminal-stdout@0.2.0-rc-2023-12-05`
// If stdout is connected to a terminal, return a `terminal-output` handle
// allowing further interaction with it.
extern bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_get_terminal_stdout(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_own_terminal_output_t *ret);
// Imported Functions from `wasi:cli/terminal-stderr@0.2.0-rc-2023-12-05`
// If stderr is connected to a terminal, return a `terminal-output` handle
// allowing further interaction with it.
extern bool wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_get_terminal_stderr(wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_own_terminal_output_t *ret);
// Imported Functions from `wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_monotonic_clock_instant_t wasi_clocks_0_2_0_rc_2023_11_10_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_rc_2023_11_10_monotonic_clock_duration_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_resolution(void);
// Create a `pollable` which will resolve once the specified instant
// occured.
extern wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_instant(wasi_clocks_0_2_0_rc_2023_11_10_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_rc_2023_11_10_monotonic_clock_own_pollable_t wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_subscribe_duration(wasi_clocks_0_2_0_rc_2023_11_10_monotonic_clock_duration_t when);
// Imported Functions from `wasi:clocks/wall-clock@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_wall_clock_now(wasi_clocks_0_2_0_rc_2023_11_10_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_rc_2023_11_10_wall_clock_resolution(wasi_clocks_0_2_0_rc_2023_11_10_wall_clock_datetime_t *ret);
// Imported Functions from `wasi:filesystem/types@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_types_method_descriptor_read_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_input_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_write_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_append_via_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_output_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_advise(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t length, wasi_filesystem_0_2_0_rc_2023_11_10_types_advice_t advice, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_sync_data(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_get_flags(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_flags_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_get_type(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_type_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_set_size(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t size, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_set_times(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_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<u8, error-code>`.
//
// Note: This is similar to `pread` in POSIX.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_read(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t length, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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<u8, error-code>`.
//
// Note: This is similar to `pwrite` in POSIX.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_write(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t *buffer, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t offset, wasi_filesystem_0_2_0_rc_2023_11_10_types_filesize_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_read_directory(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_sync(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err);
// Create a directory.
//
// Note: This is similar to `mkdirat` in POSIX.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_create_directory_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_stat(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_stat_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_set_times_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_access_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *data_modification_timestamp, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err);
// Create a hard link.
//
// Note: This is similar to `linkat` in POSIX.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_link_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t old_path_flags, command_string_t *old_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t new_descriptor, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_open_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_open_flags_t open_flags, wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_flags_t flags, wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_readlink_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, command_string_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_remove_directory_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err);
// Rename a filesystem object.
//
// Note: This is similar to `renameat` in POSIX.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_descriptor_rename_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *old_path, wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t new_descriptor, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_symlink_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *old_path, command_string_t *new_path, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_unlink_file_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_is_same_object(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_metadata_hash(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_method_descriptor_metadata_hash_at(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_path_flags_t path_flags, command_string_t *path, wasi_filesystem_0_2_0_rc_2023_11_10_types_metadata_hash_value_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *err);
// Read a single directory entry from a `directory-entry-stream`.
extern bool wasi_filesystem_0_2_0_rc_2023_11_10_types_method_directory_entry_stream_read_directory_entry(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t self, wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t *ret, wasi_filesystem_0_2_0_rc_2023_11_10_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_rc_2023_11_10_types_filesystem_error_code(wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_error_t err_, wasi_filesystem_0_2_0_rc_2023_11_10_types_error_code_t *ret);
// Imported Functions from `wasi:filesystem/preopens@0.2.0-rc-2023-11-10`
// Return the set of preopened directories, and their path.
extern void wasi_filesystem_0_2_0_rc_2023_11_10_preopens_get_directories(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t *ret);
// Imported Functions from `wasi:sockets/instance-network@0.2.0-rc-2023-11-10`
// Get a handle to the default network.
extern wasi_sockets_0_2_0_rc_2023_11_10_instance_network_own_network_t wasi_sockets_0_2_0_rc_2023_11_10_instance_network_instance_network(void);
// Imported Functions from `wasi:sockets/udp@0.2.0-rc-2023-11-10`
// 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.
//
// Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.
//
// # Typical `start` errors
// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
// - `invalid-state`: The socket is already bound. (EINVAL)
//
// # Typical `finish` errors
// - `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)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html>
// - <https://man7.org/linux/man-pages/man2/bind.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
// - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_start_bind(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_finish_bind(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_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`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
// - `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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html>
// - <https://man7.org/linux/man-pages/man2/connect.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
// - <https://man.freebsd.org/cgi/man.cgi?connect>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *maybe_remote_address, wasi_sockets_0_2_0_rc_2023_11_10_udp_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html>
// - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
// - <https://man.freebsd.org/cgi/man.cgi?getsockname>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_local_address(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html>
// - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
// - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_remote_address(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_address_family(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self);
// Whether IPv4 compatibility (dual-stack) mode is disabled or not.
//
// Equivalent to the IPV6_V6ONLY socket option.
//
// # Typical errors
// - `not-supported`: (get/set) `this` socket is an IPv4 socket.
// - `invalid-state`: (set) The socket is already bound.
// - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_udp_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_rc_2023_11_10_udp_method_udp_socket_unicast_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_unicast_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint8_t value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_udp_socket_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_set_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_udp_socket_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html>
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html>
// - <https://man7.org/linux/man-pages/man2/recv.2.html>
// - <https://man7.org/linux/man-pages/man2/recvmmsg.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom>
// - <https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)>
// - <https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_receive(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t self, uint64_t max_results, wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_incoming_datagram_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_method_outgoing_datagram_stream_check_send(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
// - `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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html>
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html>
// - <https://man7.org/linux/man-pages/man2/send.2.html>
// - <https://man7.org/linux/man-pages/man2/sendmmsg.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg>
// - <https://man.freebsd.org/cgi/man.cgi?query=send&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_send(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self, wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_t *datagrams, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_udp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_udp_method_outgoing_datagram_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t self);
// Imported Functions from `wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10`
// Create a new UDP socket.
//
// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX.
//
// 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:
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
// - <https://man7.org/linux/man-pages/man2/socket.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_create_udp_socket(wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_own_udp_socket_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_error_code_t *err);
// Imported Functions from `wasi:sockets/tcp@0.2.0-rc-2023-11-10`
// 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.
//
// When a socket is not explicitly bound, the first invocation to a listen or connect operation will
// implicitly bind the socket.
//
// Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.
//
// # Typical `start` 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, but the socket has `ipv6-only` enabled. (EINVAL)
// - `invalid-state`: The socket is already bound. (EINVAL)
//
// # Typical `finish` errors
// - `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)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html>
// - <https://man7.org/linux/man-pages/man2/bind.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind>
// - <https://man.freebsd.org/cgi/man.cgi?query=bind&sektion=2&format=html>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_start_bind(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *local_address, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_bind(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_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
//
// POSIX mentions:
// > If connect() fails, the state of the socket is unspecified. Conforming applications should
// > close the file descriptor and create a new socket before attempting to reconnect.
//
// WASI prescribes the following behavior:
// - If `connect` fails because an input/state validation error, the socket should remain usable.
// - If a connection was actually attempted but failed, the socket should become unusable for further network communication.
// Besides `drop`, any method after such a failure may return an error.
//
// # Typical `start` 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, but the socket has `ipv6-only` enabled. (EINVAL, EADDRNOTAVAIL on Illumos)
// - `invalid-argument`: `remote-address` is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
// - `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 Connection state. (EISCONN)
// - `invalid-state`: The socket is already in the Listener state. (EOPNOTSUPP, EINVAL on Windows)
//
// # Typical `finish` errors
// - `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)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html>
// - <https://man7.org/linux/man-pages/man2/connect.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect>
// - <https://man.freebsd.org/cgi/man.cgi?connect>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_start_connect(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_network_t network, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *remote_address, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_connect(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple2_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// Start listening for new connections.
//
// Transitions the socket into the Listener state.
//
// Unlike POSIX:
// - this function is async. This enables interactive WASI hosts to inject permission prompts.
// - the socket must already be explicitly bound.
//
// # Typical `start` errors
// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ)
// - `invalid-state`: The socket is already in the Connection state. (EISCONN, EINVAL on BSD)
// - `invalid-state`: The socket is already in the Listener state.
//
// # Typical `finish` errors
// - `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)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html>
// - <https://man7.org/linux/man-pages/man2/listen.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen>
// - <https://man.freebsd.org/cgi/man.cgi?query=listen&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_start_listen(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_finish_listen(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// Accept a new client socket.
//
// The returned socket is bound and in the Connection state. The following properties are inherited from the listener socket:
// - `address-family`
// - `ipv6-only`
// - `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 Listener 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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html>
// - <https://man7.org/linux/man-pages/man2/accept.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept>
// - <https://man.freebsd.org/cgi/man.cgi?query=accept&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_accept(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_tuple3_own_tcp_socket_own_input_stream_own_output_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html>
// - <https://man7.org/linux/man-pages/man2/getsockname.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getsockname>
// - <https://man.freebsd.org/cgi/man.cgi?getsockname>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_local_address(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// Get the remote address.
//
// # Typical errors
// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html>
// - <https://man7.org/linux/man-pages/man2/getpeername.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-getpeername>
// - <https://man.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2&n=1>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_remote_address(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// Whether the socket is listening for new connections.
//
// Equivalent to the SO_ACCEPTCONN socket option.
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_is_listening(wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_ip_address_family_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_address_family(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self);
// Whether IPv4 compatibility (dual-stack) mode is disabled or not.
//
// Equivalent to the IPV6_V6ONLY socket option.
//
// # Typical errors
// - `invalid-state`: (set) The socket is already bound.
// - `not-supported`: (get/set) `this` socket is an IPv4 socket.
// - `not-supported`: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_ipv6_only(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// 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 already in the Connection state.
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_listen_backlog_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_enabled(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_enabled(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, bool value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_idle_time(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_idle_time(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_interval(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_interval(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_duration_t value, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_tcp_method_tcp_socket_keep_alive_count(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint32_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_keep_alive_count(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint32_t value, wasi_sockets_0_2_0_rc_2023_11_10_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.
// - `invalid-state`: (set) The socket is already in the Connection state.
// - `invalid-state`: (set) The socket is already in the Listener state.
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint8_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_hop_limit(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint8_t value, wasi_sockets_0_2_0_rc_2023_11_10_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.
// - `invalid-state`: (set) The socket is already in the Connection state.
// - `invalid-state`: (set) The socket is already in the Listener state.
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_receive_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_set_send_buffer_size(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, uint64_t value, wasi_sockets_0_2_0_rc_2023_11_10_tcp_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_rc_2023_11_10_tcp_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self);
// Initiate a graceful shutdown.
//
// - receive: the socket is not expecting to receive any more data from the peer. All subsequent read
// operations on the `input-stream` associated with this socket will return an End Of Stream indication.
// Any data still in the receive queue at time of calling `shutdown` will be discarded.
// - send: the socket is not expecting to send any more data to the peer. All subsequent write
// operations on the `output-stream` associated with this socket will return an error.
// - both: same effect as receive & send combined.
//
// The shutdown function does not close (drop) the socket.
//
// # Typical errors
// - `invalid-state`: The socket is not in the Connection state. (ENOTCONN)
//
// # References
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html>
// - <https://man7.org/linux/man-pages/man2/shutdown.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown>
// - <https://man.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_method_tcp_socket_shutdown(wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t self, wasi_sockets_0_2_0_rc_2023_11_10_tcp_shutdown_type_t shutdown_type, wasi_sockets_0_2_0_rc_2023_11_10_tcp_error_code_t *err);
// Imported Functions from `wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10`
// Create a new TCP socket.
//
// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
//
// 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`/`listen`/`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
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
// - <https://man7.org/linux/man-pages/man2/socket.2.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_create_tcp_socket(wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_ip_address_family_t address_family, wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_own_tcp_socket_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_error_code_t *err);
// Imported Functions from `wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10`
// 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:
// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
extern bool wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_addresses(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_network_t network, command_string_t *name, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_resolve_next_address(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t self, wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t *ret, wasi_sockets_0_2_0_rc_2023_11_10_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_rc_2023_11_10_ip_name_lookup_own_pollable_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_method_resolve_address_stream_subscribe(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t self);
// Imported Functions from `wasi:random/random@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_random_get_random_bytes(uint64_t len, wasi_random_0_2_0_rc_2023_11_10_random_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_rc_2023_11_10_random_get_random_u64(void);
// Imported Functions from `wasi:random/insecure@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_insecure_get_insecure_random_bytes(uint64_t len, wasi_random_0_2_0_rc_2023_11_10_random_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_rc_2023_11_10_insecure_get_insecure_random_u64(void);
// Imported Functions from `wasi:random/insecure-seed@0.2.0-rc-2023-11-10`
// 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_rc_2023_11_10_insecure_seed_insecure_seed(wasi_random_0_2_0_rc_2023_11_10_insecure_seed_tuple2_u64_u64_t *ret);
// Exported Functions from `wasi:cli/run@0.2.0-rc-2023-12-05`
bool exports_wasi_cli_0_2_0_rc_2023_12_05_run_run(void);
// Helper Functions
void wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_tuple2_string_string_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_list_tuple2_string_string_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_list_string_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_environment_option_string_free(wasi_cli_0_2_0_rc_2023_12_05_environment_option_string_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_free(wasi_cli_0_2_0_rc_2023_12_05_exit_result_void_void_t *ptr);
extern void wasi_io_0_2_0_rc_2023_11_10_error_error_drop_own(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_error_error_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t handle);
extern wasi_io_0_2_0_rc_2023_11_10_error_borrow_error_t wasi_io_0_2_0_rc_2023_11_10_error_borrow_error(wasi_io_0_2_0_rc_2023_11_10_error_own_error_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop_own(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_poll_pollable_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t handle);
extern wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable_t wasi_io_0_2_0_rc_2023_11_10_poll_borrow_pollable(wasi_io_0_2_0_rc_2023_11_10_poll_own_pollable_t handle);
void wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_free(wasi_io_0_2_0_rc_2023_11_10_poll_list_borrow_pollable_t *ptr);
void wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_free(wasi_io_0_2_0_rc_2023_11_10_poll_list_u32_t *ptr);
void wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_stream_error_t *ptr);
extern void wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop_own(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_streams_input_stream_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t handle);
extern wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream_t wasi_io_0_2_0_rc_2023_11_10_streams_borrow_input_stream(wasi_io_0_2_0_rc_2023_11_10_streams_own_input_stream_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop_own(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t handle);
extern void wasi_io_0_2_0_rc_2023_11_10_streams_output_stream_drop_borrow(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t handle);
extern wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream_t wasi_io_0_2_0_rc_2023_11_10_streams_borrow_output_stream(wasi_io_0_2_0_rc_2023_11_10_streams_own_output_stream_t handle);
void wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_free(wasi_io_0_2_0_rc_2023_11_10_streams_list_u8_t *ptr);
void wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_list_u8_stream_error_t *ptr);
void wasi_io_0_2_0_rc_2023_11_10_streams_result_u64_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_u64_stream_error_t *ptr);
void wasi_io_0_2_0_rc_2023_11_10_streams_result_void_stream_error_free(wasi_io_0_2_0_rc_2023_11_10_streams_result_void_stream_error_t *ptr);
extern void wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop_own(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t handle);
extern void wasi_cli_0_2_0_rc_2023_12_05_terminal_input_terminal_input_drop_borrow(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t handle);
extern wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input_t wasi_cli_0_2_0_rc_2023_12_05_terminal_input_borrow_terminal_input(wasi_cli_0_2_0_rc_2023_12_05_terminal_input_own_terminal_input_t handle);
extern void wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop_own(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t handle);
extern void wasi_cli_0_2_0_rc_2023_12_05_terminal_output_terminal_output_drop_borrow(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t handle);
extern wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output_t wasi_cli_0_2_0_rc_2023_12_05_terminal_output_borrow_terminal_output(wasi_cli_0_2_0_rc_2023_12_05_terminal_output_own_terminal_output_t handle);
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_option_own_terminal_input_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdin_option_own_terminal_input_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_option_own_terminal_output_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stdout_option_own_terminal_output_t *ptr);
void wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_option_own_terminal_output_free(wasi_cli_0_2_0_rc_2023_12_05_terminal_stderr_option_own_terminal_output_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_datetime_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_stat_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_new_timestamp_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_t *ptr);
extern void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop_own(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t handle);
extern void wasi_filesystem_0_2_0_rc_2023_11_10_types_descriptor_drop_borrow(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t handle);
extern wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor_t wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_descriptor(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_descriptor_t handle);
extern void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop_own(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t handle);
extern void wasi_filesystem_0_2_0_rc_2023_11_10_types_directory_entry_stream_drop_borrow(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t handle);
extern wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream_t wasi_filesystem_0_2_0_rc_2023_11_10_types_borrow_directory_entry_stream(wasi_filesystem_0_2_0_rc_2023_11_10_types_own_directory_entry_stream_t handle);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_input_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_input_stream_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_output_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_output_stream_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_void_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_void_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_flags_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_flags_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_type_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_type_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_list_u8_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_tuple2_list_u8_bool_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_tuple2_list_u8_bool_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_tuple2_list_u8_bool_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_filesize_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_filesize_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_directory_entry_stream_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_directory_entry_stream_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_stat_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_descriptor_stat_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_descriptor_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_own_descriptor_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_string_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_metadata_hash_value_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_metadata_hash_value_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_directory_entry_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_result_option_directory_entry_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_result_option_directory_entry_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_types_option_error_code_free(wasi_filesystem_0_2_0_rc_2023_11_10_types_option_error_code_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_tuple2_own_descriptor_string_t *ptr);
void wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_free(wasi_filesystem_0_2_0_rc_2023_11_10_preopens_list_tuple2_own_descriptor_string_t *ptr);
extern void wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_network_network_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network_t wasi_sockets_0_2_0_rc_2023_11_10_network_borrow_network(wasi_sockets_0_2_0_rc_2023_11_10_network_own_network_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_network_ip_address_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_network_ip_socket_address_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_ip_socket_address_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_u8_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_option_ip_socket_address_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_t *ptr);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_udp_socket_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_udp_socket(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_udp_socket_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_incoming_datagram_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_incoming_datagram_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_incoming_datagram_stream_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_udp_outgoing_datagram_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream_t wasi_sockets_0_2_0_rc_2023_11_10_udp_borrow_outgoing_datagram_stream(wasi_sockets_0_2_0_rc_2023_11_10_udp_own_outgoing_datagram_stream_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_void_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_void_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_tuple2_own_incoming_datagram_stream_own_outgoing_datagram_stream_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_ip_socket_address_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_bool_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_bool_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u8_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u8_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u64_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_u64_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_incoming_datagram_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_result_list_incoming_datagram_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_result_list_incoming_datagram_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_list_outgoing_datagram_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_result_own_udp_socket_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_udp_create_socket_result_own_udp_socket_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_ip_socket_address_t *ptr);
extern void wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_tcp_tcp_socket_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket_t wasi_sockets_0_2_0_rc_2023_11_10_tcp_borrow_tcp_socket(wasi_sockets_0_2_0_rc_2023_11_10_tcp_own_tcp_socket_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_void_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_void_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple2_own_input_stream_own_output_stream_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_tuple3_own_tcp_socket_own_input_stream_own_output_stream_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_ip_socket_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_ip_socket_address_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_bool_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_bool_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_duration_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_duration_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u32_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u32_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u8_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u8_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u64_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_result_u64_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_result_own_tcp_socket_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_tcp_create_socket_result_own_tcp_socket_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_ip_address_t *ptr);
extern void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop_own(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t handle);
extern void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_resolve_address_stream_drop_borrow(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t handle);
extern wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream_t wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_borrow_resolve_address_stream(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_own_resolve_address_stream_t handle);
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_own_resolve_address_stream_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_own_resolve_address_stream_error_code_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_option_ip_address_t *ptr);
void wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_option_ip_address_error_code_free(wasi_sockets_0_2_0_rc_2023_11_10_ip_name_lookup_result_option_ip_address_error_code_t *ptr);
void wasi_random_0_2_0_rc_2023_11_10_random_list_u8_free(wasi_random_0_2_0_rc_2023_11_10_random_list_u8_t *ptr);
void exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_free(exports_wasi_cli_0_2_0_rc_2023_12_05_run_result_void_void_t *ptr);
// Transfers ownership of `s` into the string `ret`
void command_string_set(command_string_t *ret, char*s);
// Creates a copy of the input nul-terminate string `s` and
// stores it into the component model string `ret`.
void command_string_dup(command_string_t *ret, const char*s);
// Deallocates the string pointed to by `ret`, deallocating
// the memory behind the string.
void command_string_free(command_string_t *ret);
#ifdef __cplusplus
}
#endif
#endif
  • Imports:
    • interface wasi:cli/environment@0.2.0-rc-2023-12-05
    • interface wasi:cli/exit@0.2.0-rc-2023-12-05
    • interface wasi:io/error@0.2.0-rc-2023-11-10
    • interface wasi:io/poll@0.2.0-rc-2023-11-10
    • interface wasi:io/streams@0.2.0-rc-2023-11-10
    • interface wasi:cli/stdin@0.2.0-rc-2023-12-05
    • interface wasi:cli/stdout@0.2.0-rc-2023-12-05
    • interface wasi:cli/stderr@0.2.0-rc-2023-12-05
    • interface wasi:cli/terminal-input@0.2.0-rc-2023-12-05
    • interface wasi:cli/terminal-output@0.2.0-rc-2023-12-05
    • interface wasi:cli/terminal-stdin@0.2.0-rc-2023-12-05
    • interface wasi:cli/terminal-stdout@0.2.0-rc-2023-12-05
    • interface wasi:cli/terminal-stderr@0.2.0-rc-2023-12-05
    • interface wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10
    • interface wasi:clocks/wall-clock@0.2.0-rc-2023-11-10
    • interface wasi:filesystem/types@0.2.0-rc-2023-11-10
    • interface wasi:filesystem/preopens@0.2.0-rc-2023-11-10
    • interface wasi:sockets/network@0.2.0-rc-2023-11-10
    • interface wasi:sockets/instance-network@0.2.0-rc-2023-11-10
    • interface wasi:sockets/udp@0.2.0-rc-2023-11-10
    • interface wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10
    • interface wasi:sockets/tcp@0.2.0-rc-2023-11-10
    • interface wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10
    • interface wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10
    • interface wasi:random/random@0.2.0-rc-2023-11-10
    • interface wasi:random/insecure@0.2.0-rc-2023-11-10
    • interface wasi:random/insecure-seed@0.2.0-rc-2023-11-10
  • Exports:
    • interface wasi:cli/run@0.2.0-rc-2023-12-05

Functions

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.

Return values
  • list<(string, string)>

Get the POSIX-style arguments to the program.

Return values
  • list<string>

Return a path that programs should use as their initial current working directory, interpreting . as shorthand for this.

Return values
  • option<string>

Functions

Exit the current instance and any linked instances.

Params

Types

A resource which represents some error information.

The only method provided by this resource is to-debug-string, which provides some human-readable information about the error.

In the wasi:io package, this resource is returned through the wasi:io/streams/stream-error type.

To provide more specific error information, other interfaces may provide functions to further "downcast" this error into more specific error information. For example, errors returned in streams derived from filesystem types to be described using the filesystem's own error-code type, using the function wasi:filesystem/types/filesystem-error-code, which takes a parameter borrow<error> and returns option<wasi:filesystem/types/error-code>.

The set of functions which can "downcast" an error into a more concrete type is open.

Functions

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.

Params
Return values
  • string

A poll API intended to let users wait for I/O events on multiple handles at once.


Types

pollable represents a single I/O event which may be ready, or not.

Functions

Return the readiness of a pollable. This function never blocks.

Returns true when the pollable is ready, and false otherwise.

Params
Return values
  • bool

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.

Params

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

Params
Return values
  • list<u32>

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.


Types

error

#### `type pollable` [`pollable`](#pollable)

#### `variant stream-error`

An error for input-stream and output-stream operations.

Variant Cases
  • last-operation-failed: own<error>

    The last operation (a write or flush) failed before completion.

    More information is available in the error payload.

  • closed

    The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.

An input bytestream.

input-streams are non-blocking to the extent practical on underlying platforms. I/O operations always return promptly; if fewer bytes are promptly available than requested, they return the number of bytes promptly available, which could even be zero. To wait for data to be available, use the subscribe function to obtain a pollable which can be polled for using wasi:io/poll.

An output bytestream.

output-streams are non-blocking to the extent practical on underlying platforms. Except where specified otherwise, I/O operations also always return promptly, after the number of bytes that can be written promptly, which could even be zero. To wait for the stream to be ready to accept data, the subscribe function to obtain a pollable which can be polled for using wasi:io/poll.

Functions

Perform a non-blocking read from the stream.

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.

Params
Return values

Read bytes from a stream, after blocking until at least one byte can be read. Except for blocking, behavior is identical to read.

Params
Return values

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.

Params
Return values

Skip bytes from a stream, after blocking until at least one byte can be skipped. Except for blocking behavior, identical to skip.

Params
Return values

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 pollables created with this function are dropped.

Params
Return values

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.

Params
Return values

Perform a write. This function never blocks.

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.

Params
Return values

Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.

This is a convenience wrapper around the use of check-write, subscribe, write, and flush, and is implemented with the following pseudo-code:

let pollable = this.subscribe();
while !contents.is_empty() {
  // Wait for the stream to become writable
  pollable.block();
  let Ok(n) = this.check-write(); // eliding error handling
  let len = min(n, contents.len());
  let (chunk, rest) = contents.split_at(len);
  this.write(chunk  );            // eliding error handling
  contents = rest;
}
this.flush();
// Wait for completion of `flush`
pollable.block();
// Check for any errors that arose during `flush`
let _ = this.check-write();         // eliding error handling
Params
Return values

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.

Params
Return values

Request to flush buffered output, and block until flush completes and stream is ready for writing again.

Params
Return values

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 pollables created with this function are dropped.

Params
Return values

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.

Params
Return values

Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.

This is a convenience wrapper around the use of check-write, subscribe, write-zeroes, and flush, and is implemented with the following pseudo-code:

let pollable = this.subscribe();
while num_zeroes != 0 {
  // Wait for the stream to become writable
  pollable.block();
  let Ok(n) = this.check-write(); // eliding error handling
  let len = min(n, num_zeroes);
  this.write-zeroes(len);         // eliding error handling
  num_zeroes -= len;
}
this.flush();
// Wait for completion of `flush`
pollable.block();
// Check for any errors that arose during `flush`
let _ = this.check-write();         // eliding error handling
Params
Return values

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.

Params
Return values

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.

Params
Return values

Types

input-stream

----

Functions

Return values

Types

output-stream

----

Functions

Return values

Types

output-stream

----

Functions

Return values

Types

The input side of a terminal.


Types

The output side of a terminal.

An interface providing an optional terminal-input for stdin as a link-time authority.


Types

terminal-input

----

Functions

If stdin is connected to a terminal, return a terminal-input handle allowing further interaction with it.

Return values

An interface providing an optional terminal-output for stdout as a link-time authority.


Types

terminal-output

----

Functions

If stdout is connected to a terminal, return a terminal-output handle allowing further interaction with it.

Return values

An interface providing an optional terminal-output for stderr as a link-time authority.


Types

terminal-output

----

Functions

If stderr is connected to a terminal, return a terminal-output handle allowing further interaction with it.

Return values

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.


Types

pollable

#### `type instant` `u64`

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.

u64

A duration of time, in nanoseconds.


Functions

Read the current value of the clock.

The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

Return values

Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

Return values

Create a pollable which will resolve once the specified instant occured.

Params
Return values

Create a pollable which will resolve once the given duration has elapsed, starting at the time at which this function was called. occured.

Params
Return values

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.


Types

A time and date in seconds plus nanoseconds.

Record Fields

Functions

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.

Return values

Query the resolution of the clock.

The nanoseconds field of the output is always less than 1000000000.

Return values

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 strings, 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.


Types

input-stream

#### `type output-stream` [`output-stream`](#output_stream)

#### `type error` [`error`](#error)

#### `type datetime` [`datetime`](#datetime)

#### `type filesize` `u64`

File size or length of a region within a file.

The type of a filesystem object referenced by a descriptor.

Note: This was called filetype in earlier versions of WASI.

Enum Cases
  • unknown

    The type of the descriptor or file is unknown or is different from any of the other types specified.

  • block-device

    The descriptor refers to a block device inode.

  • character-device

    The descriptor refers to a character device inode.

  • directory

    The descriptor refers to a directory inode.

  • fifo

    The descriptor refers to a named pipe.

  • symbolic-link

    The file refers to a symbolic link inode.

  • regular-file

    The descriptor refers to a regular file inode.

  • socket

    The descriptor refers to a socket.

Descriptor flags.

Note: This was called fdflags in earlier versions of WASI.

Flags members
  • read:

    Read mode: Data can be read.

  • write:

    Write mode: Data can be written to.

  • file-integrity-sync:

    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.

  • data-integrity-sync:

    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.

  • requested-write-sync:

    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.

  • mutate-directory:

    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.

Flags determining the method of how paths are resolved.

Flags members
  • symlink-follow:

    As long as the resolved path corresponds to a symbolic link, it is expanded.

Open flags used by open-at.

Flags members
  • create:

    Create file if it does not exist, similar to `O_CREAT` in POSIX.

  • directory:

    Fail if not a directory, similar to `O_DIRECTORY` in POSIX.

  • exclusive:

    Fail if file already exists, similar to `O_EXCL` in POSIX.

  • truncate:

    Truncate file to size 0, similar to `O_TRUNC` in POSIX.

u64

Number of hard links to an inode.

File attributes.

Note: This was called filestat in earlier versions of WASI.

Record Fields
  • type: descriptor-type

    File type.

  • link-count: link-count

    Number of hard links to the file.

  • size: filesize

    For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.

  • data-access-timestamp: option<datetime>

    Last data access timestamp.

    If the option is none, the platform doesn't maintain an access timestamp for this file.

  • data-modification-timestamp: option<datetime>

    Last data modification timestamp.

    If the option is none, the platform doesn't maintain a modification timestamp for this file.

  • status-change-timestamp: option<datetime>

    Last file status-change timestamp.

    If the option is none, the platform doesn't maintain a status-change timestamp for this file.

When setting a timestamp, this gives the value to set it to.

Variant Cases
  • no-change

    Leave the timestamp set to its previous value.

  • now

    Set the timestamp to the current time of the system clock associated with the filesystem.

  • timestamp: datetime

    Set the timestamp to the given value.

A directory entry.

Record Fields
  • type: descriptor-type

    The type of the file referred to by this directory entry.

  • name: string

    The name of the object.

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 Cases
  • access

    Permission denied, similar to `EACCES` in POSIX.

  • would-block

    Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.

  • already

    Connection already in progress, similar to `EALREADY` in POSIX.

  • bad-descriptor

    Bad descriptor, similar to `EBADF` in POSIX.

  • busy

    Device or resource busy, similar to `EBUSY` in POSIX.

  • deadlock

    Resource deadlock would occur, similar to `EDEADLK` in POSIX.

  • quota

    Storage quota exceeded, similar to `EDQUOT` in POSIX.

  • exist

    File exists, similar to `EEXIST` in POSIX.

  • file-too-large

    File too large, similar to `EFBIG` in POSIX.

  • illegal-byte-sequence

    Illegal byte sequence, similar to `EILSEQ` in POSIX.

  • in-progress

    Operation in progress, similar to `EINPROGRESS` in POSIX.

  • interrupted

    Interrupted function, similar to `EINTR` in POSIX.

  • invalid

    Invalid argument, similar to `EINVAL` in POSIX.

  • io

    I/O error, similar to `EIO` in POSIX.

  • is-directory

    Is a directory, similar to `EISDIR` in POSIX.

  • loop

    Too many levels of symbolic links, similar to `ELOOP` in POSIX.

  • too-many-links

    Too many links, similar to `EMLINK` in POSIX.

  • message-size

    Message too large, similar to `EMSGSIZE` in POSIX.

  • name-too-long

    Filename too long, similar to `ENAMETOOLONG` in POSIX.

  • no-device

    No such device, similar to `ENODEV` in POSIX.

  • no-entry

    No such file or directory, similar to `ENOENT` in POSIX.

  • no-lock

    No locks available, similar to `ENOLCK` in POSIX.

  • insufficient-memory

    Not enough space, similar to `ENOMEM` in POSIX.

  • insufficient-space

    No space left on device, similar to `ENOSPC` in POSIX.

  • not-directory

    Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.

  • not-empty

    Directory not empty, similar to `ENOTEMPTY` in POSIX.

  • not-recoverable

    State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.

  • unsupported

    Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.

  • no-tty

    Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.

  • no-such-device

    No such device or address, similar to `ENXIO` in POSIX.

  • overflow

    Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.

  • not-permitted

    Operation not permitted, similar to `EPERM` in POSIX.

  • pipe

    Broken pipe, similar to `EPIPE` in POSIX.

  • read-only

    Read-only file system, similar to `EROFS` in POSIX.

  • invalid-seek

    Invalid seek, similar to `ESPIPE` in POSIX.

  • text-file-busy

    Text file busy, similar to `ETXTBSY` in POSIX.

  • cross-device

    Cross-device link, similar to `EXDEV` in POSIX.

File or memory access pattern advisory information.

Enum Cases
  • normal

    The application has no advice to give on its behavior with respect to the specified data.

  • sequential

    The application expects to access the specified data sequentially from lower offsets to higher offsets.

  • random

    The application expects to access the specified data in a random order.

  • will-need

    The application expects to access the specified data in the near future.

  • dont-need

    The application expects that it will not access the specified data in the near future.

  • no-reuse

    The application expects to access the specified data once and then not reuse it thereafter.

A 128-bit hash value, split into parts because wasm doesn't have a 128-bit integer type.

Record Fields
  • lower: u64

    64 bits of a 128-bit hash value.

  • upper: u64

    Another 64 bits of a 128-bit hash value.

A descriptor is a reference to a filesystem object, which may be a file, directory, named pipe, special file, or other object on which filesystem calls may be made.

A stream of directory entries.

Functions

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

Provide file advisory information on a descriptor.

This is similar to posix_fadvise in POSIX.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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<u8, error-code>.

Note: This is similar to pread in POSIX.

Params
Return values

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<u8, error-code>.

Note: This is similar to pwrite in POSIX.

Params
Return values

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.

Params
Return values

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.

Params
Return values

Create a directory.

Note: This is similar to mkdirat in POSIX.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

Create a hard link.

Note: This is similar to linkat in POSIX.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values

Rename a filesystem object.

Note: This is similar to renameat in POSIX.

Params
Return values

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.

Params
Return values

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.

Params
Return values

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.

Params
Return values
  • bool

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.

Params
Return values

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.

Params
Return values

Read a single directory entry from a directory-entry-stream.

Params
Return values

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.

Params
Return values

Types

descriptor

----

Functions

Return the set of preopened directories, and their path.

Return values

Types

An opaque resource that represents access to (a subset of) the network. This enables context-based security for networking. There is no need for this to map 1:1 to a physical network interface.

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 Cases
  • unknown

    Unknown error

  • access-denied

    Access denied.

    POSIX equivalent: EACCES, EPERM

  • not-supported

    The operation is not supported.

    POSIX equivalent: EOPNOTSUPP

  • invalid-argument

    One of the arguments is invalid.

    POSIX equivalent: EINVAL

  • out-of-memory

    Not enough memory to complete the operation.

    POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY

  • timeout

    The operation timed out before it could finish completely.

  • concurrency-conflict

    This operation is incompatible with another asynchronous operation that is already in progress.

    POSIX equivalent: EALREADY

  • not-in-progress

    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 futures are natively supported.

  • would-block

    The operation has been aborted because it could not be completed immediately.

    Note: this is scheduled to be removed when futures are natively supported.

  • invalid-state

    The operation is not valid in the socket's current state.

  • new-socket-limit

    A new socket resource could not be created because of a system limit.

  • address-not-bindable

    A bind operation failed because the provided address is not an address that the `network` can bind to.

  • address-in-use

    A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.

  • remote-unreachable

    The remote address is not reachable

  • connection-refused

    The connection was forcefully rejected

  • connection-reset

    The connection was reset.

  • connection-aborted

    A connection was aborted.

  • datagram-too-large

  • name-unresolvable

    Name does not exist or has no suitable associated IP addresses.

  • temporary-resolver-failure

    A temporary failure in name resolution occurred.

  • permanent-resolver-failure

    A permanent failure in name resolution occurred.

Enum Cases
  • ipv4

    Similar to `AF_INET` in POSIX.

  • ipv6

    Similar to `AF_INET6` in POSIX.

Tuple Fields
  • 0: u8
  • 1: u8
  • 2: u8
  • 3: u8
Tuple Fields
  • 0: u16
  • 1: u16
  • 2: u16
  • 3: u16
  • 4: u16
  • 5: u16
  • 6: u16
  • 7: u16
Variant Cases
Record Fields
Record Fields
Variant Cases

This interface provides a value-export of the default network handle..


Types

network

----

Functions

Get a handle to the default network.

Return values

Types

pollable

#### `type network` [`network`](#network)

#### `type error-code` [`error-code`](#error_code)

#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

#### `record incoming-datagram`

A received datagram.

Record Fields
  • data: list<u8>

    The payload.

    Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes.

  • remote-address: ip-socket-address

    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.

A datagram to be sent out.

Record Fields
  • data: list<u8>

    The payload.

  • remote-address: option<ip-socket-address>

    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.

A UDP socket handle.


Functions

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.

Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.

Typical start errors

  • invalid-argument: The local-address has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows)
  • invalid-state: The socket is already bound. (EINVAL)

Typical finish errors

  • 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)

References

Params
Return values
Params
Return values

Set up inbound & outbound communication channels, optionally to a specific peer.

This function only changes the local socket configuration and does not generate any network traffic. On success, the remote-address of the socket is updated. The local-address may be updated as well, based on the best network path to remote-address.

When a remote-address is provided, the returned streams are limited to communicating with that specific peer:

  • send can only be used to send to this destination.
  • receive will only return datagrams sent from the provided remote-address.

This method may be called multiple times on the same socket to change its association, but only the most recently returned pair of streams will be operational. Implementations may trap if the streams returned by a previous invocation haven't been dropped yet before calling stream again.

The POSIX equivalent in pseudo-code is:

if (was previously connected) {
  connect(s, AF_UNSPEC)
}
if (remote_address is Some) {
  connect(s, remote_address)
}

Unlike in POSIX, the socket must already be explicitly bound.

Typical errors

  • invalid-argument: The remote-address has the wrong address family. (EAFNOSUPPORT)
  • invalid-argument: remote-address is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
  • 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

Params
Return values

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

Params
Return values

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

Params
Return values

Whether this is a IPv4 or IPv6 socket.

Equivalent to the SO_DOMAIN socket option.

Params
Return values

Whether IPv4 compatibility (dual-stack) mode is disabled or not.

Equivalent to the IPV6_V6ONLY socket option.

Typical errors

  • not-supported: (get/set) this socket is an IPv4 socket.
  • invalid-state: (set) The socket is already bound.
  • not-supported: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
Params
Return values
Params
Return values

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.
Params
Return values
Params
Return values

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.
Params
Return values
Params
Return values
Params
Return values
Params
Return values

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.

Params
Return values

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

Params
Return values

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.

Params
Return values

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.

Params
Return values

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: remote-address is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
  • 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

Params
Return values

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.

Params
Return values

Types

network

#### `type error-code` [`error-code`](#error_code)

#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

#### `type udp-socket` [`udp-socket`](#udp_socket)

----

Functions

Create a new UDP socket.

Similar to socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP) in POSIX.

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:

Params
Return values

Types

input-stream

#### `type output-stream` [`output-stream`](#output_stream)

#### `type pollable` [`pollable`](#pollable)

#### `type duration` [`duration`](#duration)

#### `type network` [`network`](#network)

#### `type error-code` [`error-code`](#error_code)

#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

#### `enum shutdown-type`

Enum Cases
  • receive

    Similar to `SHUT_RD` in POSIX.

  • send

    Similar to `SHUT_WR` in POSIX.

  • both

    Similar to `SHUT_RDWR` in POSIX.

A TCP socket handle.

Functions

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.

When a socket is not explicitly bound, the first invocation to a listen or connect operation will implicitly bind the socket.

Unlike in POSIX, this function is async. This enables interactive WASI hosts to inject permission prompts.

Typical start 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, but the socket has ipv6-only enabled. (EINVAL)
  • invalid-state: The socket is already bound. (EINVAL)

Typical finish errors

  • 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)

References

Params
Return values
Params
Return values

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

POSIX mentions:

If connect() fails, the state of the socket is unspecified. Conforming applications should close the file descriptor and create a new socket before attempting to reconnect.

WASI prescribes the following behavior:

  • If connect fails because an input/state validation error, the socket should remain usable.
  • If a connection was actually attempted but failed, the socket should become unusable for further network communication. Besides drop, any method after such a failure may return an error.

Typical start 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, but the socket has ipv6-only enabled. (EINVAL, EADDRNOTAVAIL on Illumos)
  • invalid-argument: remote-address is a non-IPv4-mapped IPv6 address, but the socket was bound to a specific IPv4-mapped IPv6 address. (or vice versa)
  • 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 Connection state. (EISCONN)
  • invalid-state: The socket is already in the Listener state. (EOPNOTSUPP, EINVAL on Windows)

Typical finish errors

  • 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)

References

Params
Return values
Params
Return values

Start listening for new connections.

Transitions the socket into the Listener state.

Unlike POSIX:

  • this function is async. This enables interactive WASI hosts to inject permission prompts.
  • the socket must already be explicitly bound.

Typical start errors

  • invalid-state: The socket is not bound to any local address. (EDESTADDRREQ)
  • invalid-state: The socket is already in the Connection state. (EISCONN, EINVAL on BSD)
  • invalid-state: The socket is already in the Listener state.

Typical finish errors

  • 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)

References

Params
Return values
Params
Return values

Accept a new client socket.

The returned socket is bound and in the Connection state. The following properties are inherited from the listener socket:

  • address-family
  • ipv6-only
  • 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 Listener 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

Params
Return values

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

Params
Return values

Get the remote address.

Typical errors

  • invalid-state: The socket is not connected to a remote address. (ENOTCONN)

References

Params
Return values

Whether the socket is listening for new connections.

Equivalent to the SO_ACCEPTCONN socket option.

Params
Return values
  • bool

Whether this is a IPv4 or IPv6 socket.

Equivalent to the SO_DOMAIN socket option.

Params
Return values

Whether IPv4 compatibility (dual-stack) mode is disabled or not.

Equivalent to the IPV6_V6ONLY socket option.

Typical errors

  • invalid-state: (set) The socket is already bound.
  • not-supported: (get/set) this socket is an IPv4 socket.
  • not-supported: (set) Host does not support dual-stack sockets. (Implementations are not required to.)
Params
Return values
Params
Return values

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 already in the Connection state.
Params
Return values

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.

Params
Return values
Params
Return values

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.
Params
Return values
Params
Return values

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.
Params
Return values
Params
Return values

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.
Params
Return values
Params
Return values

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.
  • invalid-state: (set) The socket is already in the Connection state.
  • invalid-state: (set) The socket is already in the Listener state.
Params
Return values
Params
Return values

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.
  • invalid-state: (set) The socket is already in the Connection state.
  • invalid-state: (set) The socket is already in the Listener state.
Params
Return values
Params
Return values
Params
Return values
Params
Return values

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.

Params
Return values

Initiate a graceful shutdown.

  • receive: the socket is not expecting to receive any more data from the peer. All subsequent read operations on the input-stream associated with this socket will return an End Of Stream indication. Any data still in the receive queue at time of calling shutdown will be discarded.
  • send: the socket is not expecting to send any more data to the peer. All subsequent write operations on the output-stream associated with this socket will return an error.
  • both: same effect as receive & send combined.

The shutdown function does not close (drop) the socket.

Typical errors

  • invalid-state: The socket is not in the Connection state. (ENOTCONN)

References

Params
Return values

Types

network

#### `type error-code` [`error-code`](#error_code)

#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

#### `type tcp-socket` [`tcp-socket`](#tcp_socket)

----

Functions

Create a new TCP socket.

Similar to socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP) in POSIX.

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/listen/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

Params
Return values

Types

pollable

#### `type network` [`network`](#network)

#### `type error-code` [`error-code`](#error_code)

#### `type ip-address` [`ip-address`](#ip_address)

#### `resource resolve-address-stream`


Functions

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:

Params
Return values

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)
Params
Return values

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.

Params
Return values

WASI Random is a random data API.

It is intended to be portable at least between Unix-family platforms and Windows.


Functions

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.

Params
Return values
  • list<u8>

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.

Return values
  • u64

The insecure interface for insecure pseudo-random numbers.

It is intended to be portable at least between Unix-family platforms and Windows.


Functions

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.

Params
Return values
  • list<u8>

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.

Return values
  • u64

The insecure-seed interface for seeding hash-map DoS resistance.

It is intended to be portable at least between Unix-family platforms and Windows.


Functions

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.

Return values
  • (u64, u64)

Functions

Run the program.

Return values
  • result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment