55///
66/// In the future, the component model is expected to add built-in stream types;
77/// when it does, they are expected to subsume this API.
8+ @since (version = 0.2.0 )
89interface streams {
910 use error . {error };
1011 use poll . {pollable };
1112
1213 /// An error for input-stream and output-stream operations.
14+ @since (version = 0.2.0 )
1315 variant stream-error {
1416 /// The last operation (a write or flush) failed before completion.
1517 ///
@@ -29,6 +31,7 @@ interface streams {
2931 /// available, which could even be zero. To wait for data to be available,
3032 /// use the `subscribe` function to obtain a `pollable` which can be polled
3133 /// for using `wasi:io/poll` .
34+ @since (version = 0.2.0 )
3235 resource input-stream {
3336 /// Perform a non-blocking read from the stream.
3437 ///
@@ -56,13 +59,15 @@ interface streams {
5659 /// is not possible to allocate in wasm32, or not desirable to allocate as
5760 /// as a return value by the callee. The callee may return a list of bytes
5861 /// less than `len` in size while more bytes are available for reading.
62+ @since (version = 0.2.0 )
5963 read : func (
6064 /// The maximum number of bytes to read
6165 len : u64
6266 ) -> result <list <u8 >, stream-error >;
6367
6468 /// Read bytes from a stream, after blocking until at least one byte can
6569 /// be read. Except for blocking, behavior is identical to `read` .
70+ @since (version = 0.2.0 )
6671 blocking-read : func (
6772 /// The maximum number of bytes to read
6873 len : u64
@@ -72,13 +77,15 @@ interface streams {
7277 ///
7378 /// Behaves identical to `read` , except instead of returning a list
7479 /// of bytes, returns the number of bytes consumed from the stream.
80+ @since (version = 0.2.0 )
7581 skip : func (
7682 /// The maximum number of bytes to skip.
7783 len : u64 ,
7884 ) -> result <u64 , stream-error >;
7985
8086 /// Skip bytes from a stream, after blocking until at least one byte
8187 /// can be skipped. Except for blocking behavior, identical to `skip` .
88+ @since (version = 0.2.0 )
8289 blocking-skip : func (
8390 /// The maximum number of bytes to skip.
8491 len : u64 ,
@@ -90,6 +97,7 @@ interface streams {
9097 /// The created `pollable` is a child resource of the `input-stream` .
9198 /// Implementations may trap if the `input-stream` is dropped before
9299 /// all derived `pollable` s created with this function are dropped.
100+ @since (version = 0.2.0 )
93101 subscribe : func () -> pollable ;
94102 }
95103
@@ -102,6 +110,7 @@ interface streams {
102110 /// promptly, which could even be zero. To wait for the stream to be ready to
103111 /// accept data, the `subscribe` function to obtain a `pollable` which can be
104112 /// polled for using `wasi:io/poll` .
113+ @since (version = 0.2.0 )
105114 resource output-stream {
106115 /// Check readiness for writing. This function never blocks.
107116 ///
@@ -112,6 +121,7 @@ interface streams {
112121 /// When this function returns 0 bytes, the `subscribe` pollable will
113122 /// become ready when this function will report at least 1 byte, or an
114123 /// error.
124+ @since (version = 0.2.0 )
115125 check-write : func () -> result <u64 , stream-error >;
116126
117127 /// Perform a write. This function never blocks.
@@ -127,6 +137,7 @@ interface streams {
127137 ///
128138 /// returns Err(closed) without writing if the stream has closed since
129139 /// the last call to check-write provided a permit.
140+ @since (version = 0.2.0 )
130141 write : func (
131142 contents : list <u8 >
132143 ) -> result <_ , stream-error >;
@@ -155,6 +166,7 @@ interface streams {
155166 /// // Check for any errors that arose during `flush`
156167 /// let _ = this.check-write(); // eliding error handling
157168 /// `` `
169+ @since (version = 0.2.0 )
158170 blocking-write-and-flush : func (
159171 contents : list <u8 >
160172 ) -> result <_ , stream-error >;
@@ -169,10 +181,12 @@ interface streams {
169181 /// writes (`check-write` will return `ok(0)` ) until the flush has
170182 /// completed. The `subscribe` pollable will become ready when the
171183 /// flush has completed and the stream can accept more writes.
184+ @since (version = 0.2.0 )
172185 flush : func () -> result <_ , stream-error >;
173186
174187 /// Request to flush buffered output, and block until flush completes
175188 /// and stream is ready for writing again.
189+ @since (version = 0.2.0 )
176190 blocking-flush : func () -> result <_ , stream-error >;
177191
178192 /// Create a `pollable` which will resolve once the output-stream
@@ -193,6 +207,7 @@ interface streams {
193207 /// preconditions (must use check-write first), but instead of
194208 /// passing a list of bytes, you simply pass the number of zero-bytes
195209 /// that should be written.
210+ @since (version = 0.2.0 )
196211 write-zeroes : func (
197212 /// The number of zero-bytes to write
198213 len : u64
@@ -222,6 +237,7 @@ interface streams {
222237 /// // Check for any errors that arose during `flush`
223238 /// let _ = this.check-write(); // eliding error handling
224239 /// `` `
240+ @since (version = 0.2.0 )
225241 blocking-write-zeroes-and-flush : func (
226242 /// The number of zero-bytes to write
227243 len : u64
@@ -240,6 +256,7 @@ interface streams {
240256 ///
241257 /// This function returns the number of bytes transferred; it may be less
242258 /// than `len` .
259+ @since (version = 0.2.0 )
243260 splice : func (
244261 /// The stream to read from
245262 src : borrow <input-stream >,
@@ -252,6 +269,7 @@ interface streams {
252269 /// This is similar to `splice` , except that it blocks until the
253270 /// `output-stream` is ready for writing, and the `input-stream`
254271 /// is ready for reading, before performing the `splice` .
272+ @since (version = 0.2.0 )
255273 blocking-splice : func (
256274 /// The stream to read from
257275 src : borrow <input-stream >,
0 commit comments