From 4b740ffba162b815c74c36f6610a6453a3e2f37f Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 27 Nov 2024 13:24:28 -0800 Subject: [PATCH] Update to wit-bindgen 0.36. (#98) * Update to wit-bindgen 0.36. The main change here is that the Rust modules now include the WIT interface documentation as documentation comments, so that they show up in the cargo doc documentation. * Update CI to wit-bindgen 0.36 too. --- .github/workflows/main.yml | 2 +- Cargo.toml | 2 +- src/bindings.rs | 107 +++++++++++++++++++++++++++++++++---- src/command.rs | 51 +++++++++++++++--- src/proxy.rs | 35 +++++++++--- 5 files changed, 170 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa7c3d7..b756f52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,6 +72,6 @@ jobs: run: | ./ci/vendor-wit.sh git diff --exit-code - - run: cargo install wit-bindgen-cli@0.33.0 --locked + - run: cargo install wit-bindgen-cli@0.36.0 --locked - run: ./ci/regenerate.sh - run: git diff --exit-code diff --git a/Cargo.toml b/Cargo.toml index cd6bc41..37b94d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ wasi = { version = "0.13", path = ".", default-features = false } members = ["./crates/*"] [dependencies] -wit-bindgen-rt = { version = "0.33.0", features = ["bitflags"] } +wit-bindgen-rt = { version = "0.36.0", features = ["bitflags"] } # When built as part of libstd compiler_builtins = { version = "0.1", optional = true } diff --git a/src/bindings.rs b/src/bindings.rs index 136926f..c591af6 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,6 +1,11 @@ -#[allow(dead_code)] +// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT! +// Options used: +// * std_feature +// * runtime_path: "wit_bindgen_rt" +// * type_section_suffix: "rust-wasi-from-crates-io" +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod wasi { - #[allow(dead_code)] pub mod cli { #[allow(dead_code, clippy::all)] pub mod environment { @@ -244,6 +249,11 @@ pub mod wasi { } } } + /// Terminal input. + /// + /// In the future, this may include functions for disabling echoing, + /// disabling input buffering so that keyboard events are sent through + /// immediately, querying supported features, and so on. #[allow(dead_code, clippy::all)] pub mod terminal_input { #[used] @@ -289,6 +299,11 @@ pub mod wasi { } } } + /// Terminal output. + /// + /// In the future, this may include functions for querying the terminal + /// size, being notified of terminal size changes, querying supported + /// features, and so on. #[allow(dead_code, clippy::all)] pub mod terminal_output { #[used] @@ -334,6 +349,8 @@ pub mod wasi { } } } + /// An interface providing an optional `terminal-input` for stdin as a + /// link-time authority. #[allow(dead_code, clippy::all)] pub mod terminal_stdin { #[used] @@ -378,6 +395,8 @@ pub mod wasi { } } } + /// An interface providing an optional `terminal-output` for stdout as a + /// link-time authority. #[allow(dead_code, clippy::all)] pub mod terminal_stdout { #[used] @@ -422,6 +441,8 @@ pub mod wasi { } } } + /// An interface providing an optional `terminal-output` for stderr as a + /// link-time authority. #[allow(dead_code, clippy::all)] pub mod terminal_stderr { #[used] @@ -467,8 +488,15 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod clocks { + /// 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. #[allow(dead_code, clippy::all)] pub mod monotonic_clock { #[used] @@ -565,6 +593,20 @@ pub mod wasi { } } } + /// 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. #[allow(dead_code, clippy::all)] pub mod wall_clock { #[used] @@ -658,8 +700,31 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod filesystem { + /// WASI filesystem is a filesystem API primarily intended to let users run WASI + /// programs that access their files on their existing filesystems, without + /// significant overhead. + /// + /// It is intended to be roughly portable between Unix-family platforms and + /// Windows, though it does not hide many of the major differences. + /// + /// Paths are passed as interface-type `string`s, meaning they must consist of + /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain + /// paths which are not accessible by this API. + /// + /// The directory separator in WASI is always the forward-slash (`/`). + /// + /// All paths in WASI are relative paths, and are interpreted relative to a + /// `descriptor` referring to a base directory. If a `path` argument to any WASI + /// function starts with `/`, or if any step of resolving a `path`, including + /// `..` and symbolic link steps, reaches a directory outside of the base + /// directory, or reaches a symlink to an absolute or rooted path in the + /// underlying filesystem, the function fails with `error-code::not-permitted`. + /// + /// For more information about WASI path resolution and sandboxing, see + /// [WASI filesystem path resolution]. + /// + /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md #[allow(dead_code, clippy::all)] pub mod types { #[used] @@ -3286,8 +3351,10 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod http { + /// This interface defines all of the types and methods for implementing + /// HTTP Requests and Responses, both incoming and outgoing, as well as + /// their headers, trailers, and bodies. #[allow(dead_code, clippy::all)] pub mod types { #[used] @@ -8912,6 +8979,8 @@ pub mod wasi { } } } + /// This interface defines a handler of outgoing HTTP Requests. It should be + /// imported by components which wish to make HTTP Requests. #[allow(dead_code, clippy::all)] pub mod outgoing_handler { #[used] @@ -9426,8 +9495,9 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod io { + /// A poll API intended to let users wait for I/O events on multiple handles + /// at once. #[allow(dead_code, clippy::all)] pub mod poll { #[used] @@ -9682,6 +9752,11 @@ pub mod wasi { } } } + /// 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. #[allow(dead_code, clippy::all)] pub mod streams { #[used] @@ -10785,8 +10860,11 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod random { + /// WASI Random is a random data API. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. #[allow(dead_code, clippy::all)] pub mod random { #[used] @@ -10851,6 +10929,10 @@ pub mod wasi { } } } + /// The insecure interface for insecure pseudo-random numbers. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. #[allow(dead_code, clippy::all)] pub mod insecure { #[used] @@ -10911,6 +10993,10 @@ pub mod wasi { } } } + /// The insecure-seed interface for seeding hash-map DoS resistance. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. #[allow(dead_code, clippy::all)] pub mod insecure_seed { #[used] @@ -10958,7 +11044,6 @@ pub mod wasi { } } } - #[allow(dead_code)] pub mod sockets { #[allow(dead_code, clippy::all)] pub mod network { @@ -11367,6 +11452,7 @@ pub mod wasi { } } } + /// This interface provides a value-export of the default network handle.. #[allow(dead_code, clippy::all)] pub mod instance_network { #[used] @@ -15249,6 +15335,7 @@ pub mod wasi { } } } +#[rustfmt::skip] mod _rt { use core::fmt; use core::marker; @@ -15444,7 +15531,7 @@ mod _rt { extern crate alloc as alloc_crate; } #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.33.0:rust:wasi:bindings:encoded worldrust-wasi-from-crates-io"] +#[link_section = "component-type:wit-bindgen:0.36.0:rust:wasi:bindings:encoded worldrust-wasi-from-crates-io"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 15623] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x88y\x01A\x02\x01AO\x01\ @@ -15757,7 +15844,7 @@ get-insecure-random-bytes\x01\x01\x01@\0\0w\x04\0\x17get-insecure-random-u64\x01 \x02\x03\0\x1awasi:random/insecure@0.2.2\x050\x01B\x03\x01o\x02ww\x01@\0\0\0\x04\ \0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-seed@0.2.2\x051\x04\0\x12\ rust:wasi/bindings\x04\0\x0b\x0e\x01\0\x08bindings\x03\0\0\0G\x09producers\x01\x0c\ -processed-by\x02\x0dwit-component\x070.218.0\x10wit-bindgen-rust\x060.33.0"; +processed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/src/command.rs b/src/command.rs index be24129..6870ec3 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,3 +1,38 @@ +// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT! +// Options used: +// * std_feature +// * runtime_path: "wit_bindgen_rt" +// * with "wasi:cli/environment@0.2.2" = "crate::cli::environment" +// * with "wasi:cli/exit@0.2.2" = "crate::cli::exit" +// * with "wasi:cli/stdin@0.2.2" = "crate::cli::stdin" +// * with "wasi:cli/stdout@0.2.2" = "crate::cli::stdout" +// * with "wasi:cli/stderr@0.2.2" = "crate::cli::stderr" +// * with "wasi:cli/terminal-input@0.2.2" = "crate::cli::terminal_input" +// * with "wasi:cli/terminal-output@0.2.2" = "crate::cli::terminal_output" +// * with "wasi:cli/terminal-stdin@0.2.2" = "crate::cli::terminal_stdin" +// * with "wasi:cli/terminal-stdout@0.2.2" = "crate::cli::terminal_stdout" +// * with "wasi:cli/terminal-stderr@0.2.2" = "crate::cli::terminal_stderr" +// * with "wasi:clocks/monotonic-clock@0.2.2" = "crate::clocks::monotonic_clock" +// * with "wasi:clocks/wall-clock@0.2.2" = "crate::clocks::wall_clock" +// * with "wasi:filesystem/types@0.2.2" = "crate::filesystem::types" +// * with "wasi:filesystem/preopens@0.2.2" = "crate::filesystem::preopens" +// * with "wasi:io/error@0.2.2" = "crate::io::error" +// * with "wasi:io/poll@0.2.2" = "crate::io::poll" +// * with "wasi:io/streams@0.2.2" = "crate::io::streams" +// * with "wasi:random/random@0.2.2" = "crate::random::random" +// * with "wasi:random/insecure@0.2.2" = "crate::random::insecure" +// * with "wasi:random/insecure-seed@0.2.2" = "crate::random::insecure_seed" +// * with "wasi:sockets/network@0.2.2" = "crate::sockets::network" +// * with "wasi:sockets/instance-network@0.2.2" = "crate::sockets::instance_network" +// * with "wasi:sockets/tcp@0.2.2" = "crate::sockets::tcp" +// * with "wasi:sockets/tcp-create-socket@0.2.2" = "crate::sockets::tcp_create_socket" +// * with "wasi:sockets/udp@0.2.2" = "crate::sockets::udp" +// * with "wasi:sockets/udp-create-socket@0.2.2" = "crate::sockets::udp_create_socket" +// * with "wasi:sockets/ip-name-lookup@0.2.2" = "crate::sockets::ip_name_lookup" +// * type_section_suffix: "rust-wasi-from-crates-io-command-world" +// * default-bindings-module: "wasi" +// * export-macro-name: _export_command +// * pub-export-macro use crate::cli::environment as __with_name0; use crate::cli::exit as __with_name1; use crate::io::error as __with_name2; @@ -25,11 +60,10 @@ use crate::sockets::ip_name_lookup as __with_name23; use crate::random::random as __with_name24; use crate::random::insecure as __with_name25; use crate::random::insecure_seed as __with_name26; -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod exports { - #[allow(dead_code)] pub mod wasi { - #[allow(dead_code)] pub mod cli { #[allow(dead_code, clippy::all)] pub mod run { @@ -67,6 +101,7 @@ pub mod exports { } } } +#[rustfmt::skip] mod _rt { #[cfg(target_arch = "wasm32")] pub fn run_ctors_once() { @@ -101,7 +136,7 @@ macro_rules! __export_command_impl { exports::wasi::cli::run::__export_wasi_cli_run_0_2_2_cabi!($ty with_types_in $($path_to_types_root)*:: exports::wasi::cli::run); const _ : () = { #[cfg(target_arch = "wasm32")] #[link_section = - "component-type:wit-bindgen:0.33.0:wasi:cli@0.2.2:command:imports and exportsrust-wasi-from-crates-io-command-world"] + "component-type:wit-bindgen:0.36.0:wasi:cli@0.2.2:command:imports and exportsrust-wasi-from-crates-io-command-world"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE : [u8; 10773] = * b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x97S\x01A\x02\x01AI\x01\ @@ -320,15 +355,15 @@ nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.2\x05*\x01B\x03\x01 o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\ seed@0.2.2\x05+\x01B\x03\x01j\0\0\x01@\0\0\0\x04\0\x03run\x01\x01\x04\0\x12wasi:\ cli/run@0.2.2\x05,\x04\0\x16wasi:cli/command@0.2.2\x04\0\x0b\x0d\x01\0\x07comman\ -d\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.218.0\x10\ -wit-bindgen-rust\x060.33.0"; +d\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10\ +wit-bindgen-rust\x060.36.0"; }; }; } #[doc(inline)] pub use __export_command_impl as _export_command; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.33.0:wasi:cli@0.2.2:command-with-all-of-its-exports-removed:encoded worldrust-wasi-from-crates-io-command-world"] +#[link_section = "component-type:wit-bindgen:0.36.0:wasi:cli@0.2.2:command-with-all-of-its-exports-removed:encoded worldrust-wasi-from-crates-io-command-world"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 10794] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8cS\x01A\x02\x01AG\x01\ @@ -547,7 +582,7 @@ nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.2\x05*\x01B\x03\x01 o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\ seed@0.2.2\x05+\x04\06wasi:cli/command-with-all-of-its-exports-removed@0.2.2\x04\ \0\x0b-\x01\0'command-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\ -\x0cprocessed-by\x02\x0dwit-component\x070.218.0\x10wit-bindgen-rust\x060.33.0"; +\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/src/proxy.rs b/src/proxy.rs index ce9ccd7..9ea4a07 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -1,3 +1,22 @@ +// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT! +// Options used: +// * std_feature +// * runtime_path: "wit_bindgen_rt" +// * with "wasi:cli/stdin@0.2.2" = "crate::cli::stdin" +// * with "wasi:cli/stdout@0.2.2" = "crate::cli::stdout" +// * with "wasi:cli/stderr@0.2.2" = "crate::cli::stderr" +// * with "wasi:clocks/monotonic-clock@0.2.2" = "crate::clocks::monotonic_clock" +// * with "wasi:clocks/wall-clock@0.2.2" = "crate::clocks::wall_clock" +// * with "wasi:io/error@0.2.2" = "crate::io::error" +// * with "wasi:io/poll@0.2.2" = "crate::io::poll" +// * with "wasi:io/streams@0.2.2" = "crate::io::streams" +// * with "wasi:random/random@0.2.2" = "crate::random::random" +// * with "wasi:http/types@0.2.2" = "crate::http::types" +// * with "wasi:http/outgoing-handler@0.2.2" = "crate::http::outgoing_handler" +// * type_section_suffix: "rust-wasi-from-crates-io-proxy-world" +// * default-bindings-module: "wasi" +// * export-macro-name: _export_proxy +// * pub-export-macro use crate::io::poll as __with_name0; use crate::clocks::monotonic_clock as __with_name1; use crate::clocks::wall_clock as __with_name2; @@ -9,12 +28,13 @@ use crate::cli::stderr as __with_name7; use crate::cli::stdin as __with_name8; use crate::http::types as __with_name9; use crate::http::outgoing_handler as __with_name10; -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod exports { - #[allow(dead_code)] pub mod wasi { - #[allow(dead_code)] pub mod http { + /// This interface defines a handler of incoming HTTP Requests. It should + /// be exported by components which can respond to HTTP Requests. #[allow(dead_code, clippy::all)] pub mod incoming_handler { #[used] @@ -65,6 +85,7 @@ pub mod exports { } } } +#[rustfmt::skip] mod _rt { #[cfg(target_arch = "wasm32")] pub fn run_ctors_once() { @@ -99,7 +120,7 @@ macro_rules! __export_proxy_impl { exports::wasi::http::incoming_handler::__export_wasi_http_incoming_handler_0_2_2_cabi!($ty with_types_in $($path_to_types_root)*:: exports::wasi::http::incoming_handler); const _ : () = { #[cfg(target_arch = "wasm32")] #[link_section = - "component-type:wit-bindgen:0.33.0:wasi:http@0.2.2:proxy:imports and exportsrust-wasi-from-crates-io-proxy-world"] + "component-type:wit-bindgen:0.36.0:wasi:http@0.2.2:proxy:imports and exportsrust-wasi-from-crates-io-proxy-world"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE : [u8; 7040] = * b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x846\x01A\x02\x01A#\x01\ @@ -242,14 +263,14 @@ incoming-request\x02\x03\0\x09\x11response-outparam\x01B\x08\x02\x03\x02\x01\x14 m\x03\0\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\ \0\x06handle\x01\x06\x04\0\x20wasi:http/incoming-handler@0.2.2\x05\x16\x04\0\x15\ wasi:http/proxy@0.2.2\x04\0\x0b\x0b\x01\0\x05proxy\x03\0\0\0G\x09producers\x01\x0c\ -processed-by\x02\x0dwit-component\x070.218.0\x10wit-bindgen-rust\x060.33.0"; +processed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0"; }; }; } #[doc(inline)] pub use __export_proxy_impl as _export_proxy; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.33.0:wasi:http@0.2.2:proxy-with-all-of-its-exports-removed:encoded worldrust-wasi-from-crates-io-proxy-world"] +#[link_section = "component-type:wit-bindgen:0.36.0:wasi:http@0.2.2:proxy-with-all-of-its-exports-removed:encoded worldrust-wasi-from-crates-io-proxy-world"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 6921] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xed4\x01A\x02\x01A\x1f\ @@ -389,7 +410,7 @@ i\x05\x01j\x01\x0b\x01\x07\x01@\x02\x07request\x08\x07options\x0a\0\x0c\x04\0\x0 handle\x01\x0d\x03\0\x20wasi:http/outgoing-handler@0.2.2\x05\x13\x04\05wasi:http\ /proxy-with-all-of-its-exports-removed@0.2.2\x04\0\x0b+\x01\0%proxy-with-all-of-\ its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-compo\ -nent\x070.218.0\x10wit-bindgen-rust\x060.33.0"; +nent\x070.220.0\x10wit-bindgen-rust\x060.36.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() {