|
| 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 the data received from the |
| 19 | + /// file, and a `future` providing additional error information in case an |
| 20 | + /// error is encountered. |
| 21 | + /// |
| 22 | + /// If the stream is dropped by the writer (`stream.read` returns `dropped`), |
| 23 | + /// the future will resolve either successfully if stdin was closed by the other |
| 24 | + /// end or an error if the read failed. |
| 25 | + /// |
| 26 | + /// Multiple streams may be active at the same time. The behavior of concurrent |
| 27 | + /// reads is implementation-specific. |
3 | 28 | @since(version = 0.3.0-rc-2025-08-15) |
4 | | - get-stdin: func() -> stream<u8>; |
| 29 | + read-stdin: func() -> tuple<stream<u8>, future<result<_, error-code>>>; |
5 | 30 | } |
6 | 31 |
|
7 | 32 | @since(version = 0.3.0-rc-2025-08-15) |
8 | 33 | interface stdout { |
| 34 | + /// Append from the given stream to stdout. |
| 35 | + /// |
| 36 | + /// If the stream's writable end is dropped this function will either return |
| 37 | + /// success once the entire contents of the stream have been written or an |
| 38 | + /// error-code representing a failure. |
| 39 | + /// |
| 40 | + /// Otherwise if there is an error the readable end of the stream will be |
| 41 | + /// dropped and this function will return an error-code. |
9 | 42 | @since(version = 0.3.0-rc-2025-08-15) |
10 | | - set-stdout: func(data: stream<u8>); |
| 43 | + append-stdout: async func(data: stream<u8>) -> result<_, error-code>; |
11 | 44 | } |
12 | 45 |
|
13 | 46 | @since(version = 0.3.0-rc-2025-08-15) |
14 | 47 | interface stderr { |
| 48 | + /// Append from the given stream to stderr. |
| 49 | + /// |
| 50 | + /// If the stream's writable end is dropped this function will either return |
| 51 | + /// success once the entire contents of the stream have been written or an |
| 52 | + /// error-code representing a failure. |
| 53 | + /// |
| 54 | + /// Otherwise if there is an error the readable end of the stream will be |
| 55 | + /// dropped and this function will return an error-code. |
15 | 56 | @since(version = 0.3.0-rc-2025-08-15) |
16 | | - set-stderr: func(data: stream<u8>); |
| 57 | + append-stderr: async func(data: stream<u8>) -> result<_, error-code>; |
17 | 58 | } |
0 commit comments