From 382be466ad201e28f36a10ad4f7dd8ae449e8e7d Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Mon, 8 Sep 2025 17:38:47 -0400 Subject: [PATCH 1/2] stdio: Update interfaces to support error results --- wit-0.3.0-draft/stdio.wit | 48 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/wit-0.3.0-draft/stdio.wit b/wit-0.3.0-draft/stdio.wit index 6c99a56..3b9c09c 100644 --- a/wit-0.3.0-draft/stdio.wit +++ b/wit-0.3.0-draft/stdio.wit @@ -1,17 +1,59 @@ +@since(version = 0.3.0-rc-2025-08-15) +interface stdio { + @since(version = 0.3.0-rc-2025-08-15) + 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-rc-2025-08-15) interface stdin { + /// 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-rc-2025-08-15) - get-stdin: func() -> stream; + read-stdin: func() -> tuple, future>>; } @since(version = 0.3.0-rc-2025-08-15) interface stdout { + /// Append from 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-rc-2025-08-15) - set-stdout: func(data: stream); + append-stdout: async func(data: stream) -> result<_, error-code>; } @since(version = 0.3.0-rc-2025-08-15) interface stderr { + /// Append from 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-rc-2025-08-15) - set-stderr: func(data: stream); + append-stderr: async func(data: stream) -> result<_, error-code>; } From 924181b64546c173a38a1c54f754628c928c3c36 Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Mon, 15 Sep 2025 13:19:56 -0400 Subject: [PATCH 2/2] stdio: Tweak method names --- wit-0.3.0-draft/stdio.wit | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wit-0.3.0-draft/stdio.wit b/wit-0.3.0-draft/stdio.wit index 3b9c09c..c1bc8ac 100644 --- a/wit-0.3.0-draft/stdio.wit +++ b/wit-0.3.0-draft/stdio.wit @@ -27,12 +27,12 @@ interface stdin { /// Multiple streams may be active at the same time. The behavior of concurrent /// reads is implementation-specific. @since(version = 0.3.0-rc-2025-08-15) - read-stdin: func() -> tuple, future>>; + read-via-stream: func() -> tuple, future>>; } @since(version = 0.3.0-rc-2025-08-15) interface stdout { - /// Append from the given stream to stdout. + /// 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 @@ -41,12 +41,12 @@ interface stdout { /// 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-rc-2025-08-15) - append-stdout: async func(data: stream) -> result<_, error-code>; + write-via-stream: async func(data: stream) -> result<_, error-code>; } @since(version = 0.3.0-rc-2025-08-15) interface stderr { - /// Append from the given stream to stderr. + /// 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 @@ -55,5 +55,5 @@ interface stderr { /// 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-rc-2025-08-15) - append-stderr: async func(data: stream) -> result<_, error-code>; + write-via-stream: async func(data: stream) -> result<_, error-code>; }