Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions wit-0.3.0-draft/stdio.wit
Original file line number Diff line number Diff line change
@@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pipe is already expressible, by stream.write returning copy-result.dropped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, is it the case that copy-result.dropped means the stream is over, and that's when the error code is delivered, so we need a pipe-like code for distinguishing that case from others?

Copy link
Collaborator Author

@lann lann Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for reading dropped is eos. I'm not sure what the intent is for writes but the docs say it "doesn't signify an error." 🤷

}
}

@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<u8>;
read-via-stream: func() -> tuple<stream<u8>, future<result<_, error-code>>>;
}

@since(version = 0.3.0-rc-2025-08-15)
interface 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
/// 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<u8>);
write-via-stream: async func(data: stream<u8>) -> result<_, error-code>;
}

@since(version = 0.3.0-rc-2025-08-15)
interface 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
/// 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<u8>);
write-via-stream: async func(data: stream<u8>) -> result<_, error-code>;
}