@@ -5,11 +5,13 @@ package wasi:io@0.2.0;
5
5
///
6
6
/// In the future, the component model is expected to add built-in stream types;
7
7
/// when it does, they are expected to subsume this API.
8
+ @since (version = 0.2.0 )
8
9
interface streams {
9
10
use error . {error };
10
11
use poll . {pollable };
11
12
12
13
/// An error for input-stream and output-stream operations.
14
+ @since (version = 0.2.0 )
13
15
variant stream-error {
14
16
/// The last operation (a write or flush) failed before completion.
15
17
///
@@ -29,6 +31,7 @@ interface streams {
29
31
/// available, which could even be zero. To wait for data to be available,
30
32
/// use the `subscribe` function to obtain a `pollable` which can be polled
31
33
/// for using `wasi:io/poll` .
34
+ @since (version = 0.2.0 )
32
35
resource input-stream {
33
36
/// Perform a non-blocking read from the stream.
34
37
///
@@ -56,13 +59,15 @@ interface streams {
56
59
/// is not possible to allocate in wasm32, or not desirable to allocate as
57
60
/// as a return value by the callee. The callee may return a list of bytes
58
61
/// less than `len` in size while more bytes are available for reading.
62
+ @since (version = 0.2.0 )
59
63
read : func (
60
64
/// The maximum number of bytes to read
61
65
len : u64
62
66
) -> result <list <u8 >, stream-error >;
63
67
64
68
/// Read bytes from a stream, after blocking until at least one byte can
65
69
/// be read. Except for blocking, behavior is identical to `read` .
70
+ @since (version = 0.2.0 )
66
71
blocking-read : func (
67
72
/// The maximum number of bytes to read
68
73
len : u64
@@ -72,13 +77,15 @@ interface streams {
72
77
///
73
78
/// Behaves identical to `read` , except instead of returning a list
74
79
/// of bytes, returns the number of bytes consumed from the stream.
80
+ @since (version = 0.2.0 )
75
81
skip : func (
76
82
/// The maximum number of bytes to skip.
77
83
len : u64 ,
78
84
) -> result <u64 , stream-error >;
79
85
80
86
/// Skip bytes from a stream, after blocking until at least one byte
81
87
/// can be skipped. Except for blocking behavior, identical to `skip` .
88
+ @since (version = 0.2.0 )
82
89
blocking-skip : func (
83
90
/// The maximum number of bytes to skip.
84
91
len : u64 ,
@@ -90,6 +97,7 @@ interface streams {
90
97
/// The created `pollable` is a child resource of the `input-stream` .
91
98
/// Implementations may trap if the `input-stream` is dropped before
92
99
/// all derived `pollable` s created with this function are dropped.
100
+ @since (version = 0.2.0 )
93
101
subscribe : func () -> pollable ;
94
102
}
95
103
@@ -102,6 +110,7 @@ interface streams {
102
110
/// promptly, which could even be zero. To wait for the stream to be ready to
103
111
/// accept data, the `subscribe` function to obtain a `pollable` which can be
104
112
/// polled for using `wasi:io/poll` .
113
+ @since (version = 0.2.0 )
105
114
resource output-stream {
106
115
/// Check readiness for writing. This function never blocks.
107
116
///
@@ -112,6 +121,7 @@ interface streams {
112
121
/// When this function returns 0 bytes, the `subscribe` pollable will
113
122
/// become ready when this function will report at least 1 byte, or an
114
123
/// error.
124
+ @since (version = 0.2.0 )
115
125
check-write : func () -> result <u64 , stream-error >;
116
126
117
127
/// Perform a write. This function never blocks.
@@ -127,6 +137,7 @@ interface streams {
127
137
///
128
138
/// returns Err(closed) without writing if the stream has closed since
129
139
/// the last call to check-write provided a permit.
140
+ @since (version = 0.2.0 )
130
141
write : func (
131
142
contents : list <u8 >
132
143
) -> result <_ , stream-error >;
@@ -155,6 +166,7 @@ interface streams {
155
166
/// // Check for any errors that arose during `flush`
156
167
/// let _ = this.check-write(); // eliding error handling
157
168
/// `` `
169
+ @since (version = 0.2.0 )
158
170
blocking-write-and-flush : func (
159
171
contents : list <u8 >
160
172
) -> result <_ , stream-error >;
@@ -169,10 +181,12 @@ interface streams {
169
181
/// writes (`check-write` will return `ok(0)` ) until the flush has
170
182
/// completed. The `subscribe` pollable will become ready when the
171
183
/// flush has completed and the stream can accept more writes.
184
+ @since (version = 0.2.0 )
172
185
flush : func () -> result <_ , stream-error >;
173
186
174
187
/// Request to flush buffered output, and block until flush completes
175
188
/// and stream is ready for writing again.
189
+ @since (version = 0.2.0 )
176
190
blocking-flush : func () -> result <_ , stream-error >;
177
191
178
192
/// Create a `pollable` which will resolve once the output-stream
@@ -193,6 +207,7 @@ interface streams {
193
207
/// preconditions (must use check-write first), but instead of
194
208
/// passing a list of bytes, you simply pass the number of zero-bytes
195
209
/// that should be written.
210
+ @since (version = 0.2.0 )
196
211
write-zeroes : func (
197
212
/// The number of zero-bytes to write
198
213
len : u64
@@ -222,6 +237,7 @@ interface streams {
222
237
/// // Check for any errors that arose during `flush`
223
238
/// let _ = this.check-write(); // eliding error handling
224
239
/// `` `
240
+ @since (version = 0.2.0 )
225
241
blocking-write-zeroes-and-flush : func (
226
242
/// The number of zero-bytes to write
227
243
len : u64
@@ -240,6 +256,7 @@ interface streams {
240
256
///
241
257
/// This function returns the number of bytes transferred; it may be less
242
258
/// than `len` .
259
+ @since (version = 0.2.0 )
243
260
splice : func (
244
261
/// The stream to read from
245
262
src : borrow <input-stream >,
@@ -252,6 +269,7 @@ interface streams {
252
269
/// This is similar to `splice` , except that it blocks until the
253
270
/// `output-stream` is ready for writing, and the `input-stream`
254
271
/// is ready for reading, before performing the `splice` .
272
+ @since (version = 0.2.0 )
255
273
blocking-splice : func (
256
274
/// The stream to read from
257
275
src : borrow <input-stream >,
0 commit comments