Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 31337d8

Browse files
authored
Merge pull request #82 from lann/stdio-errors
stdio: Update interfaces to support error results
2 parents b330ee8 + 924181b commit 31337d8

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

wit-0.3.0-draft/stdio.wit

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,59 @@
1+
@since(version = 0.3.0-rc-2025-08-15)
2+
interface stdio {
3+
@since(version = 0.3.0-rc-2025-08-15)
4+
enum error-code {
5+
/// Input/output error
6+
io,
7+
/// Invalid or incomplete multibyte or wide character
8+
illegal-byte-sequence,
9+
/// Broken pipe
10+
pipe,
11+
}
12+
}
13+
114
@since(version = 0.3.0-rc-2025-08-15)
215
interface stdin {
16+
/// Return a stream for reading from stdin.
17+
///
18+
/// This function returns a stream which provides data read from stdin,
19+
/// and a future to signal read results.
20+
///
21+
/// If the stream's readable end is dropped the future will resolve to success.
22+
///
23+
/// If the stream's writable end is dropped the future will either resolve to
24+
/// success if stdin was closed by the writer or to an error-code if reading
25+
/// failed for some other reason.
26+
///
27+
/// Multiple streams may be active at the same time. The behavior of concurrent
28+
/// reads is implementation-specific.
329
@since(version = 0.3.0-rc-2025-08-15)
4-
get-stdin: func() -> stream<u8>;
30+
read-via-stream: func() -> tuple<stream<u8>, future<result<_, error-code>>>;
531
}
632

733
@since(version = 0.3.0-rc-2025-08-15)
834
interface stdout {
35+
/// Write the given stream to stdout.
36+
///
37+
/// If the stream's writable end is dropped this function will either return
38+
/// success once the entire contents of the stream have been written or an
39+
/// error-code representing a failure.
40+
///
41+
/// Otherwise if there is an error the readable end of the stream will be
42+
/// dropped and this function will return an error-code.
943
@since(version = 0.3.0-rc-2025-08-15)
10-
set-stdout: func(data: stream<u8>);
44+
write-via-stream: async func(data: stream<u8>) -> result<_, error-code>;
1145
}
1246

1347
@since(version = 0.3.0-rc-2025-08-15)
1448
interface stderr {
49+
/// Write the given stream to stderr.
50+
///
51+
/// If the stream's writable end is dropped this function will either return
52+
/// success once the entire contents of the stream have been written or an
53+
/// error-code representing a failure.
54+
///
55+
/// Otherwise if there is an error the readable end of the stream will be
56+
/// dropped and this function will return an error-code.
1557
@since(version = 0.3.0-rc-2025-08-15)
16-
set-stderr: func(data: stream<u8>);
58+
write-via-stream: async func(data: stream<u8>) -> result<_, error-code>;
1759
}

0 commit comments

Comments
 (0)