diff --git a/Cargo.lock b/Cargo.lock index ba11331..6fd390d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,8 +249,7 @@ dependencies = [ [[package]] name = "wit-bindgen" version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43552cfa071f246cfd99e5dbb23710dfe7336b3259e09339818483359470749" +source = "git+https://github.com/bytecodealliance/wit-bindgen.git?branch=main#646d3b4be2b0b02cfdace6fa0614c504ed53c801" dependencies = [ "bitflags", "wit-bindgen-rust-macro", @@ -259,8 +258,7 @@ dependencies = [ [[package]] name = "wit-bindgen-core" version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4738d1c9a78e97bc7f664bfafd5d8e67d7bb26faa5c41e6d628e8bbdad3ec351" +source = "git+https://github.com/bytecodealliance/wit-bindgen.git?branch=main#646d3b4be2b0b02cfdace6fa0614c504ed53c801" dependencies = [ "anyhow", "heck", @@ -270,8 +268,7 @@ dependencies = [ [[package]] name = "wit-bindgen-rust" version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1130ce1f531bc9f9a75922244aa773bf5e2117fda1ef4a86b9f98d6b8135eb46" +source = "git+https://github.com/bytecodealliance/wit-bindgen.git?branch=main#646d3b4be2b0b02cfdace6fa0614c504ed53c801" dependencies = [ "anyhow", "heck", @@ -286,8 +283,7 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07296369e4d598e7e79b64eef66f724d83324ea671bcf677d78fc5cf92604ae5" +source = "git+https://github.com/bytecodealliance/wit-bindgen.git?branch=main#646d3b4be2b0b02cfdace6fa0614c504ed53c801" dependencies = [ "anyhow", "macro-string", diff --git a/Cargo.toml b/Cargo.toml index 08aa7bc..b1979a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,4 @@ members = [ ] [workspace.dependencies] -wit-bindgen = "0.58.0" +wit-bindgen = { version = "0.58.0", git = "https://github.com/bytecodealliance/wit-bindgen.git", branch = "main" } diff --git a/Makefile b/Makefile index 18fcad1..87646fc 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,9 @@ components: $(foreach component,$(COMPONENTS),lib/$(component).wasm $(foreach co define BUILD_COMPONENT +.PHONY: components/$1 +components/$1: lib/$1.wasm lib/$1.debug.wasm + lib/$1.wasm: Cargo.toml Cargo.lock wit/deps $(shell find components/$1 -type f) cargo build -p $1 --target wasm32-unknown-unknown --release wasm-tools component new target/wasm32-unknown-unknown/release/$(subst -,_,$1).wasm -o lib/$1.wasm diff --git a/components/stderr-to-stdout/src/lib.rs b/components/stderr-to-stdout/src/lib.rs index 415cab3..e1efe16 100644 --- a/components/stderr-to-stdout/src/lib.rs +++ b/components/stderr-to-stdout/src/lib.rs @@ -1,20 +1,31 @@ #![no_main] -use crate::exports::wasi::cli::stderr::Guest; -use crate::wasi::cli::stdout::get_stdout; -use crate::wasi::io::streams::OutputStream; +use crate::exports::wasi::cli::stderr::{ErrorCode, Guest}; +use crate::wasi::cli::stdout; pub(crate) struct StderrToStdout; impl Guest for StderrToStdout { - fn get_stderr() -> OutputStream { - get_stdout() + #[doc = "/ Write the given stream to stderr."] + #[doc = "/"] + #[doc = "/ If the stream\'s writable end is dropped this function will either return"] + #[doc = "/ success once the entire contents of the stream have been written or an"] + #[doc = "/ error-code representing a failure."] + #[doc = "/"] + #[doc = "/ Otherwise if there is an error the readable end of the stream will be"] + #[doc = "/ dropped and this function will return an error-code."] + #[allow(async_fn_in_trait)] + fn write_via_stream( + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> { + stdout::write_via_stream(data) } } wit_bindgen::generate!({ path: "../../wit", world: "stderr-to-stdout", + merge_structurally_equal_types: true, generate_all }); diff --git a/components/stdout-to-stderr/src/lib.rs b/components/stdout-to-stderr/src/lib.rs index eac0d4e..7c65b6a 100644 --- a/components/stdout-to-stderr/src/lib.rs +++ b/components/stdout-to-stderr/src/lib.rs @@ -1,20 +1,31 @@ #![no_main] -use crate::exports::wasi::cli::stdout::Guest; -use crate::wasi::cli::stderr::get_stderr; -use crate::wasi::io::streams::OutputStream; +use crate::exports::wasi::cli::stdout::{ErrorCode, Guest}; +use crate::wasi::cli::stderr; pub(crate) struct StdoutToStderr; impl Guest for StdoutToStderr { - fn get_stdout() -> OutputStream { - get_stderr() + #[doc = "/ Write the given stream to stdout."] + #[doc = "/"] + #[doc = "/ If the stream\'s writable end is dropped this function will either return"] + #[doc = "/ success once the entire contents of the stream have been written or an"] + #[doc = "/ error-code representing a failure."] + #[doc = "/"] + #[doc = "/ Otherwise if there is an error the readable end of the stream will be"] + #[doc = "/ dropped and this function will return an error-code."] + #[allow(async_fn_in_trait)] + fn write_via_stream( + data: wit_bindgen::rt::async_support::StreamReader, + ) -> wit_bindgen::rt::async_support::FutureReader> { + stderr::write_via_stream(data) } } wit_bindgen::generate!({ path: "../../wit", world: "stdout-to-stderr", + merge_structurally_equal_types: true, generate_all }); diff --git a/wit/deps/wasi-cli-0.2.6/package.wit b/wit/deps/wasi-cli-0.2.6/package.wit deleted file mode 100644 index d7a3ca4..0000000 --- a/wit/deps/wasi-cli-0.2.6/package.wit +++ /dev/null @@ -1,261 +0,0 @@ -package wasi:cli@0.2.6; - -@since(version = 0.2.0) -interface environment { - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. - @since(version = 0.2.0) - get-environment: func() -> list>; - - /// Get the POSIX-style arguments to the program. - @since(version = 0.2.0) - get-arguments: func() -> list; - - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. - @since(version = 0.2.0) - initial-cwd: func() -> option; -} - -@since(version = 0.2.0) -interface exit { - /// Exit the current instance and any linked instances. - @since(version = 0.2.0) - exit: func(status: result); - - /// Exit the current instance and any linked instances, reporting the - /// specified status code to the host. - /// - /// The meaning of the code depends on the context, with 0 usually meaning - /// "success", and other values indicating various types of failure. - /// - /// This function does not return; the effect is analogous to a trap, but - /// without the connotation that something bad has happened. - @unstable(feature = cli-exit-with-code) - exit-with-code: func(status-code: u8); -} - -@since(version = 0.2.0) -interface run { - /// Run the program. - @since(version = 0.2.0) - run: func() -> result; -} - -@since(version = 0.2.0) -interface stdin { - @since(version = 0.2.0) - use wasi:io/streams@0.2.6.{input-stream}; - - @since(version = 0.2.0) - get-stdin: func() -> input-stream; -} - -@since(version = 0.2.0) -interface stdout { - @since(version = 0.2.0) - use wasi:io/streams@0.2.6.{output-stream}; - - @since(version = 0.2.0) - get-stdout: func() -> output-stream; -} - -@since(version = 0.2.0) -interface stderr { - @since(version = 0.2.0) - use wasi:io/streams@0.2.6.{output-stream}; - - @since(version = 0.2.0) - get-stderr: func() -> output-stream; -} - -/// 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. -@since(version = 0.2.0) -interface terminal-input { - /// The input side of a terminal. - @since(version = 0.2.0) - resource terminal-input; -} - -/// 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. -@since(version = 0.2.0) -interface terminal-output { - /// The output side of a terminal. - @since(version = 0.2.0) - resource terminal-output; -} - -/// An interface providing an optional `terminal-input` for stdin as a -/// link-time authority. -@since(version = 0.2.0) -interface terminal-stdin { - @since(version = 0.2.0) - use terminal-input.{terminal-input}; - - /// If stdin is connected to a terminal, return a `terminal-input` handle - /// allowing further interaction with it. - @since(version = 0.2.0) - get-terminal-stdin: func() -> option; -} - -/// An interface providing an optional `terminal-output` for stdout as a -/// link-time authority. -@since(version = 0.2.0) -interface terminal-stdout { - @since(version = 0.2.0) - use terminal-output.{terminal-output}; - - /// If stdout is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. - @since(version = 0.2.0) - get-terminal-stdout: func() -> option; -} - -/// An interface providing an optional `terminal-output` for stderr as a -/// link-time authority. -@since(version = 0.2.0) -interface terminal-stderr { - @since(version = 0.2.0) - use terminal-output.{terminal-output}; - - /// If stderr is connected to a terminal, return a `terminal-output` handle - /// allowing further interaction with it. - @since(version = 0.2.0) - get-terminal-stderr: func() -> option; -} - -@since(version = 0.2.0) -world imports { - @since(version = 0.2.0) - import environment; - @since(version = 0.2.0) - import exit; - @since(version = 0.2.0) - import wasi:io/error@0.2.6; - @since(version = 0.2.0) - import wasi:io/poll@0.2.6; - @since(version = 0.2.0) - import wasi:io/streams@0.2.6; - @since(version = 0.2.0) - import stdin; - @since(version = 0.2.0) - import stdout; - @since(version = 0.2.0) - import stderr; - @since(version = 0.2.0) - import terminal-input; - @since(version = 0.2.0) - import terminal-output; - @since(version = 0.2.0) - import terminal-stdin; - @since(version = 0.2.0) - import terminal-stdout; - @since(version = 0.2.0) - import terminal-stderr; - @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.6; - @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.6; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.2.6; - @since(version = 0.2.0) - import wasi:filesystem/types@0.2.6; - @since(version = 0.2.0) - import wasi:filesystem/preopens@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/network@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/instance-network@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/udp@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/udp-create-socket@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/tcp@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/tcp-create-socket@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/ip-name-lookup@0.2.6; - @since(version = 0.2.0) - import wasi:random/random@0.2.6; - @since(version = 0.2.0) - import wasi:random/insecure@0.2.6; - @since(version = 0.2.0) - import wasi:random/insecure-seed@0.2.6; -} -@since(version = 0.2.0) -world command { - @since(version = 0.2.0) - import environment; - @since(version = 0.2.0) - import exit; - @since(version = 0.2.0) - import wasi:io/error@0.2.6; - @since(version = 0.2.0) - import wasi:io/poll@0.2.6; - @since(version = 0.2.0) - import wasi:io/streams@0.2.6; - @since(version = 0.2.0) - import stdin; - @since(version = 0.2.0) - import stdout; - @since(version = 0.2.0) - import stderr; - @since(version = 0.2.0) - import terminal-input; - @since(version = 0.2.0) - import terminal-output; - @since(version = 0.2.0) - import terminal-stdin; - @since(version = 0.2.0) - import terminal-stdout; - @since(version = 0.2.0) - import terminal-stderr; - @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.6; - @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.6; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.2.6; - @since(version = 0.2.0) - import wasi:filesystem/types@0.2.6; - @since(version = 0.2.0) - import wasi:filesystem/preopens@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/network@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/instance-network@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/udp@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/udp-create-socket@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/tcp@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/tcp-create-socket@0.2.6; - @since(version = 0.2.0) - import wasi:sockets/ip-name-lookup@0.2.6; - @since(version = 0.2.0) - import wasi:random/random@0.2.6; - @since(version = 0.2.0) - import wasi:random/insecure@0.2.6; - @since(version = 0.2.0) - import wasi:random/insecure-seed@0.2.6; - - @since(version = 0.2.0) - export run; -} diff --git a/wit/deps/wasi-cli-0.3.0/package.wit b/wit/deps/wasi-cli-0.3.0/package.wit new file mode 100644 index 0000000..7aae56c --- /dev/null +++ b/wit/deps/wasi-cli-0.3.0/package.wit @@ -0,0 +1,256 @@ +package wasi:cli@0.3.0; + +@since(version = 0.3.0) +interface environment { + /// Get the POSIX-style environment variables. + /// + /// Each environment variable is provided as a pair of string variable names + /// and string value. + /// + /// Morally, these are a value import, but until value imports are available + /// in the component model, this import function should return the same + /// values each time it is called. + @since(version = 0.3.0) + get-environment: func() -> list>; + + /// Get the POSIX-style arguments to the program. + @since(version = 0.3.0) + get-arguments: func() -> list; + + /// Return a path that programs should use as their initial current working + /// directory, interpreting `.` as shorthand for this. + @since(version = 0.3.0) + get-initial-cwd: func() -> option; +} + +@since(version = 0.3.0) +interface exit { + /// Exit the current instance and any linked instances. + @since(version = 0.3.0) + exit: func(status: result); + + /// Exit the current instance and any linked instances, reporting the + /// specified status code to the host. + /// + /// The meaning of the code depends on the context, with 0 usually meaning + /// "success", and other values indicating various types of failure. + /// + /// This function does not return; the effect is analogous to a trap, but + /// without the connotation that something bad has happened. + @since(version = 0.3.0) + exit-with-code: func(status-code: u8); +} + +@since(version = 0.3.0) +interface run { + /// Run the program. + @since(version = 0.3.0) + run: async func() -> result; +} + +@since(version = 0.3.0) +interface types { + @since(version = 0.3.0) + enum error-code { + /// Input/output error + io, + /// Invalid or incomplete multibyte or wide character + illegal-byte-sequence, + /// Broken pipe + pipe, + } +} + +@since(version = 0.3.0) +interface stdin { + use types.{error-code}; + + /// Return a stream for reading from stdin. + /// + /// This function returns a stream which provides data read from stdin, + /// and a future to signal read results. + /// + /// If the stream's readable end is dropped the future will resolve to success. + /// + /// If the stream's writable end is dropped the future will either resolve to + /// success if stdin was closed by the writer or to an error-code if reading + /// failed for some other reason. + /// + /// Multiple streams may be active at the same time. The behavior of concurrent + /// reads is implementation-specific. + @since(version = 0.3.0) + read-via-stream: func() -> tuple, future>>; +} + +@since(version = 0.3.0) +interface stdout { + use types.{error-code}; + + /// Write the given stream to stdout. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. + @since(version = 0.3.0) + write-via-stream: func(data: stream) -> future>; +} + +@since(version = 0.3.0) +interface stderr { + use types.{error-code}; + + /// Write the given stream to stderr. + /// + /// If the stream's writable end is dropped this function will either return + /// success once the entire contents of the stream have been written or an + /// error-code representing a failure. + /// + /// Otherwise if there is an error the readable end of the stream will be + /// dropped and this function will return an error-code. + @since(version = 0.3.0) + write-via-stream: func(data: stream) -> future>; +} + +/// 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. +@since(version = 0.3.0) +interface terminal-input { + /// The input side of a terminal. + @since(version = 0.3.0) + resource terminal-input; +} + +/// 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. +@since(version = 0.3.0) +interface terminal-output { + /// The output side of a terminal. + @since(version = 0.3.0) + resource terminal-output; +} + +/// An interface providing an optional `terminal-input` for stdin as a +/// link-time authority. +@since(version = 0.3.0) +interface terminal-stdin { + @since(version = 0.3.0) + use terminal-input.{terminal-input}; + + /// If stdin is connected to a terminal, return a `terminal-input` handle + /// allowing further interaction with it. + @since(version = 0.3.0) + get-terminal-stdin: func() -> option; +} + +/// An interface providing an optional `terminal-output` for stdout as a +/// link-time authority. +@since(version = 0.3.0) +interface terminal-stdout { + @since(version = 0.3.0) + use terminal-output.{terminal-output}; + + /// If stdout is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + @since(version = 0.3.0) + get-terminal-stdout: func() -> option; +} + +/// An interface providing an optional `terminal-output` for stderr as a +/// link-time authority. +@since(version = 0.3.0) +interface terminal-stderr { + @since(version = 0.3.0) + use terminal-output.{terminal-output}; + + /// If stderr is connected to a terminal, return a `terminal-output` handle + /// allowing further interaction with it. + @since(version = 0.3.0) + get-terminal-stderr: func() -> option; +} + +@since(version = 0.3.0) +world imports { + @since(version = 0.3.0) + import environment; + @since(version = 0.3.0) + import exit; + @since(version = 0.3.0) + import types; + @since(version = 0.3.0) + import stdin; + @since(version = 0.3.0) + import stdout; + @since(version = 0.3.0) + import stderr; + @since(version = 0.3.0) + import terminal-input; + @since(version = 0.3.0) + import terminal-output; + @since(version = 0.3.0) + import terminal-stdin; + @since(version = 0.3.0) + import terminal-stdout; + @since(version = 0.3.0) + import terminal-stderr; + import wasi:clocks/types@0.3.0; + import wasi:clocks/monotonic-clock@0.3.0; + import wasi:clocks/system-clock@0.3.0; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.3.0; + import wasi:filesystem/types@0.3.0; + import wasi:filesystem/preopens@0.3.0; + import wasi:sockets/types@0.3.0; + import wasi:sockets/ip-name-lookup@0.3.0; + import wasi:random/random@0.3.0; + import wasi:random/insecure@0.3.0; + import wasi:random/insecure-seed@0.3.0; +} +@since(version = 0.3.0) +world command { + @since(version = 0.3.0) + import environment; + @since(version = 0.3.0) + import exit; + @since(version = 0.3.0) + import types; + @since(version = 0.3.0) + import stdin; + @since(version = 0.3.0) + import stdout; + @since(version = 0.3.0) + import stderr; + @since(version = 0.3.0) + import terminal-input; + @since(version = 0.3.0) + import terminal-output; + @since(version = 0.3.0) + import terminal-stdin; + @since(version = 0.3.0) + import terminal-stdout; + @since(version = 0.3.0) + import terminal-stderr; + import wasi:clocks/types@0.3.0; + import wasi:clocks/monotonic-clock@0.3.0; + import wasi:clocks/system-clock@0.3.0; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.3.0; + import wasi:filesystem/types@0.3.0; + import wasi:filesystem/preopens@0.3.0; + import wasi:sockets/types@0.3.0; + import wasi:sockets/ip-name-lookup@0.3.0; + import wasi:random/random@0.3.0; + import wasi:random/insecure@0.3.0; + import wasi:random/insecure-seed@0.3.0; + + @since(version = 0.3.0) + export run; +} diff --git a/wit/deps/wasi-clocks-0.2.6/package.wit b/wit/deps/wasi-clocks-0.2.6/package.wit deleted file mode 100644 index 7004aa8..0000000 --- a/wit/deps/wasi-clocks-0.2.6/package.wit +++ /dev/null @@ -1,43 +0,0 @@ -package wasi:clocks@0.2.6; - -interface monotonic-clock { - use wasi:io/poll@0.2.6.{pollable}; - - type instant = u64; - - type duration = u64; - - now: func() -> instant; - - resolution: func() -> duration; - - subscribe-instant: func(when: instant) -> pollable; - - subscribe-duration: func(when: duration) -> pollable; -} - -interface wall-clock { - record datetime { - seconds: u64, - nanoseconds: u32, - } - - now: func() -> datetime; - - resolution: func() -> datetime; -} - -interface timezone { - use wall-clock.{datetime}; - - record timezone-display { - utc-offset: s32, - name: string, - in-daylight-saving-time: bool, - } - - display: func(when: datetime) -> timezone-display; - - utc-offset: func(when: datetime) -> s32; -} - diff --git a/wit/deps/wasi-clocks-0.3.0/package.wit b/wit/deps/wasi-clocks-0.3.0/package.wit new file mode 100644 index 0000000..871adf0 --- /dev/null +++ b/wit/deps/wasi-clocks-0.3.0/package.wit @@ -0,0 +1,43 @@ +package wasi:clocks@0.3.0; + +interface types { + type duration = u64; +} + +interface monotonic-clock { + use types.{duration}; + + type mark = u64; + + now: func() -> mark; + + get-resolution: func() -> duration; + + wait-until: async func(when: mark); + + wait-for: async func(how-long: duration); +} + +interface system-clock { + use types.{duration}; + + record instant { + seconds: s64, + nanoseconds: u32, + } + + now: func() -> instant; + + get-resolution: func() -> duration; +} + +interface timezone { + use system-clock.{instant}; + + iana-id: func() -> option; + + utc-offset: func(when: instant) -> option; + + to-debug-string: func() -> string; +} + diff --git a/wit/deps/wasi-filesystem-0.2.6/package.wit b/wit/deps/wasi-filesystem-0.2.6/package.wit deleted file mode 100644 index 78bbb1e..0000000 --- a/wit/deps/wasi-filesystem-0.2.6/package.wit +++ /dev/null @@ -1,158 +0,0 @@ -package wasi:filesystem@0.2.6; - -interface types { - use wasi:io/streams@0.2.6.{input-stream, output-stream, error}; - use wasi:clocks/wall-clock@0.2.6.{datetime}; - - type filesize = u64; - - enum descriptor-type { - unknown, - block-device, - character-device, - directory, - fifo, - symbolic-link, - regular-file, - socket, - } - - flags descriptor-flags { - read, - write, - file-integrity-sync, - data-integrity-sync, - requested-write-sync, - mutate-directory, - } - - flags path-flags { - symlink-follow, - } - - flags open-flags { - create, - directory, - exclusive, - truncate, - } - - type link-count = u64; - - record descriptor-stat { - %type: descriptor-type, - link-count: link-count, - size: filesize, - data-access-timestamp: option, - data-modification-timestamp: option, - status-change-timestamp: option, - } - - variant new-timestamp { - no-change, - now, - timestamp(datetime), - } - - record directory-entry { - %type: descriptor-type, - name: string, - } - - enum error-code { - access, - would-block, - already, - bad-descriptor, - busy, - deadlock, - quota, - exist, - file-too-large, - illegal-byte-sequence, - in-progress, - interrupted, - invalid, - io, - is-directory, - loop, - too-many-links, - message-size, - name-too-long, - no-device, - no-entry, - no-lock, - insufficient-memory, - insufficient-space, - not-directory, - not-empty, - not-recoverable, - unsupported, - no-tty, - no-such-device, - overflow, - not-permitted, - pipe, - read-only, - invalid-seek, - text-file-busy, - cross-device, - } - - enum advice { - normal, - sequential, - random, - will-need, - dont-need, - no-reuse, - } - - record metadata-hash-value { - lower: u64, - upper: u64, - } - - resource descriptor { - read-via-stream: func(offset: filesize) -> result; - write-via-stream: func(offset: filesize) -> result; - append-via-stream: func() -> result; - advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; - sync-data: func() -> result<_, error-code>; - get-flags: func() -> result; - get-type: func() -> result; - set-size: func(size: filesize) -> result<_, error-code>; - set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; - read: func(length: filesize, offset: filesize) -> result, bool>, error-code>; - write: func(buffer: list, offset: filesize) -> result; - read-directory: func() -> result; - sync: func() -> result<_, error-code>; - create-directory-at: func(path: string) -> result<_, error-code>; - stat: func() -> result; - stat-at: func(path-flags: path-flags, path: string) -> result; - set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; - link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; - open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; - readlink-at: func(path: string) -> result; - remove-directory-at: func(path: string) -> result<_, error-code>; - rename-at: func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; - symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>; - unlink-file-at: func(path: string) -> result<_, error-code>; - is-same-object: func(other: borrow) -> bool; - metadata-hash: func() -> result; - metadata-hash-at: func(path-flags: path-flags, path: string) -> result; - } - - resource directory-entry-stream { - read-directory-entry: func() -> result, error-code>; - } - - filesystem-error-code: func(err: borrow) -> option; -} - -interface preopens { - use types.{descriptor}; - - get-directories: func() -> list>; -} - diff --git a/wit/deps/wasi-filesystem-0.3.0/package.wit b/wit/deps/wasi-filesystem-0.3.0/package.wit new file mode 100644 index 0000000..492d2ca --- /dev/null +++ b/wit/deps/wasi-filesystem-0.3.0/package.wit @@ -0,0 +1,149 @@ +package wasi:filesystem@0.3.0; + +interface types { + use wasi:clocks/system-clock@0.3.0.{instant}; + + type filesize = u64; + + variant descriptor-type { + block-device, + character-device, + directory, + fifo, + symbolic-link, + regular-file, + socket, + other(option), + } + + flags descriptor-flags { + read, + write, + file-integrity-sync, + data-integrity-sync, + requested-write-sync, + mutate-directory, + } + + flags path-flags { + symlink-follow, + } + + flags open-flags { + create, + directory, + exclusive, + truncate, + } + + type link-count = u64; + + record descriptor-stat { + %type: descriptor-type, + link-count: link-count, + size: filesize, + data-access-timestamp: option, + data-modification-timestamp: option, + status-change-timestamp: option, + } + + variant new-timestamp { + no-change, + now, + timestamp(instant), + } + + record directory-entry { + %type: descriptor-type, + name: string, + } + + variant error-code { + access, + already, + bad-descriptor, + busy, + deadlock, + quota, + exist, + file-too-large, + illegal-byte-sequence, + in-progress, + interrupted, + invalid, + io, + is-directory, + loop, + too-many-links, + message-size, + name-too-long, + no-device, + no-entry, + no-lock, + insufficient-memory, + insufficient-space, + not-directory, + not-empty, + not-recoverable, + unsupported, + no-tty, + no-such-device, + overflow, + not-permitted, + pipe, + read-only, + invalid-seek, + text-file-busy, + cross-device, + other(option), + } + + enum advice { + normal, + sequential, + random, + will-need, + dont-need, + no-reuse, + } + + record metadata-hash-value { + lower: u64, + upper: u64, + } + + resource descriptor { + read-via-stream: func(offset: filesize) -> tuple, future>>; + write-via-stream: func(data: stream, offset: filesize) -> future>; + append-via-stream: func(data: stream) -> future>; + advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; + sync-data: async func() -> result<_, error-code>; + get-flags: async func() -> result; + get-type: async func() -> result; + set-size: async func(size: filesize) -> result<_, error-code>; + set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; + read-directory: func() -> tuple, future>>; + sync: async func() -> result<_, error-code>; + create-directory-at: async func(path: string) -> result<_, error-code>; + stat: async func() -> result; + stat-at: async func(path-flags: path-flags, path: string) -> result; + set-times-at: async func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; + link-at: async func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; + open-at: async func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; + readlink-at: async func(path: string) -> result; + remove-directory-at: async func(path: string) -> result<_, error-code>; + rename-at: async func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; + symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>; + unlink-file-at: async func(path: string) -> result<_, error-code>; + is-same-object: async func(other: borrow) -> bool; + metadata-hash: async func() -> result; + metadata-hash-at: async func(path-flags: path-flags, path: string) -> result; + } +} + +interface preopens { + use types.{descriptor}; + + get-directories: func() -> list>; +} + diff --git a/wit/deps/wasi-io-0.2.6/package.wit b/wit/deps/wasi-io-0.2.6/package.wit deleted file mode 100644 index 72fefbe..0000000 --- a/wit/deps/wasi-io-0.2.6/package.wit +++ /dev/null @@ -1,48 +0,0 @@ -package wasi:io@0.2.6; - -interface error { - resource error { - to-debug-string: func() -> string; - } -} - -interface poll { - resource pollable { - ready: func() -> bool; - block: func(); - } - - poll: func(in: list>) -> list; -} - -interface streams { - use error.{error}; - use poll.{pollable}; - - variant stream-error { - last-operation-failed(error), - closed, - } - - resource input-stream { - read: func(len: u64) -> result, stream-error>; - blocking-read: func(len: u64) -> result, stream-error>; - skip: func(len: u64) -> result; - blocking-skip: func(len: u64) -> result; - subscribe: func() -> pollable; - } - - resource output-stream { - check-write: func() -> result; - write: func(contents: list) -> result<_, stream-error>; - blocking-write-and-flush: func(contents: list) -> result<_, stream-error>; - flush: func() -> result<_, stream-error>; - blocking-flush: func() -> result<_, stream-error>; - subscribe: func() -> pollable; - write-zeroes: func(len: u64) -> result<_, stream-error>; - blocking-write-zeroes-and-flush: func(len: u64) -> result<_, stream-error>; - splice: func(src: borrow, len: u64) -> result; - blocking-splice: func(src: borrow, len: u64) -> result; - } -} - diff --git a/wit/deps/wasi-random-0.2.6/package.wit b/wit/deps/wasi-random-0.2.6/package.wit deleted file mode 100644 index 7adcffa..0000000 --- a/wit/deps/wasi-random-0.2.6/package.wit +++ /dev/null @@ -1,18 +0,0 @@ -package wasi:random@0.2.6; - -interface random { - get-random-bytes: func(len: u64) -> list; - - get-random-u64: func() -> u64; -} - -interface insecure { - get-insecure-random-bytes: func(len: u64) -> list; - - get-insecure-random-u64: func() -> u64; -} - -interface insecure-seed { - insecure-seed: func() -> tuple; -} - diff --git a/wit/deps/wasi-random-0.3.0/package.wit b/wit/deps/wasi-random-0.3.0/package.wit new file mode 100644 index 0000000..f6cfb81 --- /dev/null +++ b/wit/deps/wasi-random-0.3.0/package.wit @@ -0,0 +1,18 @@ +package wasi:random@0.3.0; + +interface random { + get-random-bytes: func(max-len: u64) -> list; + + get-random-u64: func() -> u64; +} + +interface insecure { + get-insecure-random-bytes: func(max-len: u64) -> list; + + get-insecure-random-u64: func() -> u64; +} + +interface insecure-seed { + get-insecure-seed: func() -> tuple; +} + diff --git a/wit/deps/wasi-sockets-0.2.6/package.wit b/wit/deps/wasi-sockets-0.2.6/package.wit deleted file mode 100644 index 6bd7f21..0000000 --- a/wit/deps/wasi-sockets-0.2.6/package.wit +++ /dev/null @@ -1,183 +0,0 @@ -package wasi:sockets@0.2.6; - -interface network { - use wasi:io/error@0.2.6.{error}; - - resource network; - - enum error-code { - unknown, - access-denied, - not-supported, - invalid-argument, - out-of-memory, - timeout, - concurrency-conflict, - not-in-progress, - would-block, - invalid-state, - new-socket-limit, - address-not-bindable, - address-in-use, - remote-unreachable, - connection-refused, - connection-reset, - connection-aborted, - datagram-too-large, - name-unresolvable, - temporary-resolver-failure, - permanent-resolver-failure, - } - - enum ip-address-family { - ipv4, - ipv6, - } - - type ipv4-address = tuple; - - type ipv6-address = tuple; - - variant ip-address { - ipv4(ipv4-address), - ipv6(ipv6-address), - } - - record ipv4-socket-address { - port: u16, - address: ipv4-address, - } - - record ipv6-socket-address { - port: u16, - flow-info: u32, - address: ipv6-address, - scope-id: u32, - } - - variant ip-socket-address { - ipv4(ipv4-socket-address), - ipv6(ipv6-socket-address), - } - - network-error-code: func(err: borrow) -> option; -} - -interface instance-network { - use network.{network}; - - instance-network: func() -> network; -} - -interface udp { - use wasi:io/poll@0.2.6.{pollable}; - use network.{network, error-code, ip-socket-address, ip-address-family}; - - record incoming-datagram { - data: list, - remote-address: ip-socket-address, - } - - record outgoing-datagram { - data: list, - remote-address: option, - } - - resource udp-socket { - start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; - finish-bind: func() -> result<_, error-code>; - %stream: func(remote-address: option) -> result, error-code>; - local-address: func() -> result; - remote-address: func() -> result; - address-family: func() -> ip-address-family; - unicast-hop-limit: func() -> result; - set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; - receive-buffer-size: func() -> result; - set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - send-buffer-size: func() -> result; - set-send-buffer-size: func(value: u64) -> result<_, error-code>; - subscribe: func() -> pollable; - } - - resource incoming-datagram-stream { - receive: func(max-results: u64) -> result, error-code>; - subscribe: func() -> pollable; - } - - resource outgoing-datagram-stream { - check-send: func() -> result; - send: func(datagrams: list) -> result; - subscribe: func() -> pollable; - } -} - -interface udp-create-socket { - use network.{network, error-code, ip-address-family}; - use udp.{udp-socket}; - - create-udp-socket: func(address-family: ip-address-family) -> result; -} - -interface tcp { - use wasi:io/streams@0.2.6.{input-stream, output-stream}; - use wasi:io/poll@0.2.6.{pollable}; - use wasi:clocks/monotonic-clock@0.2.6.{duration}; - use network.{network, error-code, ip-socket-address, ip-address-family}; - - enum shutdown-type { - receive, - send, - both, - } - - resource tcp-socket { - start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; - finish-bind: func() -> result<_, error-code>; - start-connect: func(network: borrow, remote-address: ip-socket-address) -> result<_, error-code>; - finish-connect: func() -> result, error-code>; - start-listen: func() -> result<_, error-code>; - finish-listen: func() -> result<_, error-code>; - accept: func() -> result, error-code>; - local-address: func() -> result; - remote-address: func() -> result; - is-listening: func() -> bool; - address-family: func() -> ip-address-family; - set-listen-backlog-size: func(value: u64) -> result<_, error-code>; - keep-alive-enabled: func() -> result; - set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; - keep-alive-idle-time: func() -> result; - set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; - keep-alive-interval: func() -> result; - set-keep-alive-interval: func(value: duration) -> result<_, error-code>; - keep-alive-count: func() -> result; - set-keep-alive-count: func(value: u32) -> result<_, error-code>; - hop-limit: func() -> result; - set-hop-limit: func(value: u8) -> result<_, error-code>; - receive-buffer-size: func() -> result; - set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - send-buffer-size: func() -> result; - set-send-buffer-size: func(value: u64) -> result<_, error-code>; - subscribe: func() -> pollable; - shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>; - } -} - -interface tcp-create-socket { - use network.{network, error-code, ip-address-family}; - use tcp.{tcp-socket}; - - create-tcp-socket: func(address-family: ip-address-family) -> result; -} - -interface ip-name-lookup { - use wasi:io/poll@0.2.6.{pollable}; - use network.{network, error-code, ip-address}; - - resource resolve-address-stream { - resolve-next-address: func() -> result, error-code>; - subscribe: func() -> pollable; - } - - resolve-addresses: func(network: borrow, name: string) -> result; -} - diff --git a/wit/deps/wasi-sockets-0.3.0/package.wit b/wit/deps/wasi-sockets-0.3.0/package.wit new file mode 100644 index 0000000..da14ae8 --- /dev/null +++ b/wit/deps/wasi-sockets-0.3.0/package.wit @@ -0,0 +1,116 @@ +package wasi:sockets@0.3.0; + +interface types { + use wasi:clocks/types@0.3.0.{duration}; + + variant error-code { + access-denied, + not-supported, + invalid-argument, + out-of-memory, + timeout, + invalid-state, + address-not-bindable, + address-in-use, + remote-unreachable, + connection-refused, + connection-broken, + connection-reset, + connection-aborted, + datagram-too-large, + other(option), + } + + enum ip-address-family { + ipv4, + ipv6, + } + + type ipv4-address = tuple; + + type ipv6-address = tuple; + + variant ip-address { + ipv4(ipv4-address), + ipv6(ipv6-address), + } + + record ipv4-socket-address { + port: u16, + address: ipv4-address, + } + + record ipv6-socket-address { + port: u16, + flow-info: u32, + address: ipv6-address, + scope-id: u32, + } + + variant ip-socket-address { + ipv4(ipv4-socket-address), + ipv6(ipv6-socket-address), + } + + resource tcp-socket { + create: static func(address-family: ip-address-family) -> result; + bind: func(local-address: ip-socket-address) -> result<_, error-code>; + connect: async func(remote-address: ip-socket-address) -> result<_, error-code>; + listen: func() -> result, error-code>; + send: func(data: stream) -> future>; + receive: func() -> tuple, future>>; + get-local-address: func() -> result; + get-remote-address: func() -> result; + get-is-listening: func() -> bool; + get-address-family: func() -> ip-address-family; + set-listen-backlog-size: func(value: u64) -> result<_, error-code>; + get-keep-alive-enabled: func() -> result; + set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; + get-keep-alive-idle-time: func() -> result; + set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; + get-keep-alive-interval: func() -> result; + set-keep-alive-interval: func(value: duration) -> result<_, error-code>; + get-keep-alive-count: func() -> result; + set-keep-alive-count: func(value: u32) -> result<_, error-code>; + get-hop-limit: func() -> result; + set-hop-limit: func(value: u8) -> result<_, error-code>; + get-receive-buffer-size: func() -> result; + set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + get-send-buffer-size: func() -> result; + set-send-buffer-size: func(value: u64) -> result<_, error-code>; + } + + resource udp-socket { + create: static func(address-family: ip-address-family) -> result; + bind: func(local-address: ip-socket-address) -> result<_, error-code>; + connect: func(remote-address: ip-socket-address) -> result<_, error-code>; + disconnect: func() -> result<_, error-code>; + send: async func(data: list, remote-address: option) -> result<_, error-code>; + receive: async func() -> result, ip-socket-address>, error-code>; + get-local-address: func() -> result; + get-remote-address: func() -> result; + get-address-family: func() -> ip-address-family; + get-unicast-hop-limit: func() -> result; + set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; + get-receive-buffer-size: func() -> result; + set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + get-send-buffer-size: func() -> result; + set-send-buffer-size: func(value: u64) -> result<_, error-code>; + } +} + +interface ip-name-lookup { + use types.{ip-address}; + + variant error-code { + access-denied, + invalid-argument, + name-unresolvable, + temporary-resolver-failure, + permanent-resolver-failure, + other(option), + } + + resolve-addresses: async func(name: string) -> result, error-code>; +} + diff --git a/wit/worlds.wit b/wit/worlds.wit index 949618e..656317f 100644 --- a/wit/worlds.wit +++ b/wit/worlds.wit @@ -1,11 +1,11 @@ package componentized:cli; world stderr-to-stdout { - import wasi:cli/stdout@0.2.6; - export wasi:cli/stderr@0.2.6; + import wasi:cli/stdout@0.3.0; + export wasi:cli/stderr@0.3.0; } world stdout-to-stderr { - import wasi:cli/stderr@0.2.6; - export wasi:cli/stdout@0.2.6; + import wasi:cli/stderr@0.3.0; + export wasi:cli/stdout@0.3.0; } diff --git a/wkg.lock b/wkg.lock index c924860..c886d90 100644 --- a/wkg.lock +++ b/wkg.lock @@ -7,6 +7,6 @@ name = "wasi:cli" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.2.6" -version = "0.2.6" -digest = "sha256:fdbe84136b3dd46d94305ef37f24f3cf04a70cc2026dca2592ac2ec0c9de15c7" +requirement = "=0.3.0" +version = "0.3.0" +digest = "sha256:3a2d58743b67a057f7210b9a73d3b21b34ec7895ffe34d1cb092927307156e40"