|
| 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 | + |
1 | 14 | @since(version = 0.3.0-rc-2025-08-15)
|
2 | 15 | 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. |
3 | 29 | @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>>>; |
5 | 31 | }
|
6 | 32 |
|
7 | 33 | @since(version = 0.3.0-rc-2025-08-15)
|
8 | 34 | 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. |
9 | 43 | @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>; |
11 | 45 | }
|
12 | 46 |
|
13 | 47 | @since(version = 0.3.0-rc-2025-08-15)
|
14 | 48 | 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. |
15 | 57 | @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>; |
17 | 59 | }
|
0 commit comments