1
- package wasi : io @ 0.2.0 ;
1
+ package wasi : io @ 0.2.1 ;
2
2
3
3
/// WASI I/O is an I/O abstraction API which is currently focused on providing
4
4
/// stream types.
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 {
10
+ @since(version = 0.2.0)
9
11
use error . {error };
12
+ @since(version = 0.2.0)
10
13
use poll . {pollable };
11
14
12
15
/// An error for input-stream and output-stream operations.
16
+ @since(version = 0.2.0)
13
17
variant stream-error {
14
18
/// The last operation (a write or flush) failed before completion.
15
19
///
@@ -29,6 +33,7 @@ interface streams {
29
33
/// available, which could even be zero. To wait for data to be available,
30
34
/// use the `subscribe` function to obtain a `pollable` which can be polled
31
35
/// for using `wasi:io/poll` .
36
+ @since(version = 0.2.0)
32
37
resource input-stream {
33
38
/// Perform a non-blocking read from the stream.
34
39
///
@@ -56,13 +61,15 @@ interface streams {
56
61
/// is not possible to allocate in wasm32, or not desirable to allocate as
57
62
/// as a return value by the callee. The callee may return a list of bytes
58
63
/// less than `len` in size while more bytes are available for reading.
64
+ @since(version = 0.2.0)
59
65
read : func (
60
66
/// The maximum number of bytes to read
61
67
len : u64
62
68
) -> result <list <u8 >, stream-error >;
63
69
64
70
/// Read bytes from a stream, after blocking until at least one byte can
65
71
/// be read. Except for blocking, behavior is identical to `read` .
72
+ @since(version = 0.2.0)
66
73
blocking-read : func (
67
74
/// The maximum number of bytes to read
68
75
len : u64
@@ -72,13 +79,15 @@ interface streams {
72
79
///
73
80
/// Behaves identical to `read` , except instead of returning a list
74
81
/// of bytes, returns the number of bytes consumed from the stream.
82
+ @since(version = 0.2.0)
75
83
skip : func (
76
84
/// The maximum number of bytes to skip.
77
85
len : u64 ,
78
86
) -> result <u64 , stream-error >;
79
87
80
88
/// Skip bytes from a stream, after blocking until at least one byte
81
89
/// can be skipped. Except for blocking behavior, identical to `skip` .
90
+ @since(version = 0.2.0)
82
91
blocking-skip : func (
83
92
/// The maximum number of bytes to skip.
84
93
len : u64 ,
@@ -90,6 +99,7 @@ interface streams {
90
99
/// The created `pollable` is a child resource of the `input-stream` .
91
100
/// Implementations may trap if the `input-stream` is dropped before
92
101
/// all derived `pollable` s created with this function are dropped.
102
+ @since(version = 0.2.0)
93
103
subscribe : func () -> pollable ;
94
104
}
95
105
@@ -102,6 +112,11 @@ interface streams {
102
112
/// promptly, which could even be zero. To wait for the stream to be ready to
103
113
/// accept data, the `subscribe` function to obtain a `pollable` which can be
104
114
/// polled for using `wasi:io/poll` .
115
+ ///
116
+ /// Dropping an `output-stream` while there's still an active write in
117
+ /// progress may result in the data being lost. Before dropping the stream,
118
+ /// be sure to fully flush your writes.
119
+ @since(version = 0.2.0)
105
120
resource output-stream {
106
121
/// Check readiness for writing. This function never blocks.
107
122
///
@@ -112,6 +127,7 @@ interface streams {
112
127
/// When this function returns 0 bytes, the `subscribe` pollable will
113
128
/// become ready when this function will report at least 1 byte, or an
114
129
/// error.
130
+ @since(version = 0.2.0)
115
131
check-write : func () -> result <u64 , stream-error >;
116
132
117
133
/// Perform a write. This function never blocks.
@@ -127,6 +143,7 @@ interface streams {
127
143
///
128
144
/// returns Err(closed) without writing if the stream has closed since
129
145
/// the last call to check-write provided a permit.
146
+ @since(version = 0.2.0)
130
147
write : func (
131
148
contents : list <u8 >
132
149
) -> result <_ , stream-error >;
@@ -155,6 +172,7 @@ interface streams {
155
172
/// // Check for any errors that arose during `flush`
156
173
/// let _ = this.check-write(); // eliding error handling
157
174
/// `` `
175
+ @since(version = 0.2.0)
158
176
blocking-write-and-flush : func (
159
177
contents : list <u8 >
160
178
) -> result <_ , stream-error >;
@@ -169,14 +187,16 @@ interface streams {
169
187
/// writes (`check-write` will return `ok(0)` ) until the flush has
170
188
/// completed. The `subscribe` pollable will become ready when the
171
189
/// flush has completed and the stream can accept more writes.
190
+ @since(version = 0.2.0)
172
191
flush : func () -> result <_ , stream-error >;
173
192
174
193
/// Request to flush buffered output, and block until flush completes
175
194
/// and stream is ready for writing again.
195
+ @since(version = 0.2.0)
176
196
blocking-flush : func () -> result <_ , stream-error >;
177
197
178
198
/// Create a `pollable` which will resolve once the output-stream
179
- /// is ready for more writing, or an error has occured . When this
199
+ /// is ready for more writing, or an error has occurred . When this
180
200
/// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
181
201
/// error.
182
202
///
@@ -193,6 +213,7 @@ interface streams {
193
213
/// preconditions (must use check-write first), but instead of
194
214
/// passing a list of bytes, you simply pass the number of zero-bytes
195
215
/// that should be written.
216
+ @since(version = 0.2.0)
196
217
write-zeroes : func (
197
218
/// The number of zero-bytes to write
198
219
len : u64
@@ -222,14 +243,15 @@ interface streams {
222
243
/// // Check for any errors that arose during `flush`
223
244
/// let _ = this.check-write(); // eliding error handling
224
245
/// `` `
246
+ @since(version = 0.2.0)
225
247
blocking-write-zeroes-and-flush : func (
226
248
/// The number of zero-bytes to write
227
249
len : u64
228
250
) -> result <_ , stream-error >;
229
251
230
252
/// Read from one stream and write to another.
231
253
///
232
- /// The behavior of splice is equivelant to:
254
+ /// The behavior of splice is equivalent to:
233
255
/// 1. calling `check-write` on the `output-stream`
234
256
/// 2. calling `read` on the `input-stream` with the smaller of the
235
257
/// `check-write` permitted length and the `len` provided to `splice`
@@ -240,6 +262,7 @@ interface streams {
240
262
///
241
263
/// This function returns the number of bytes transferred; it may be less
242
264
/// than `len` .
265
+ @since(version = 0.2.0)
243
266
splice : func (
244
267
/// The stream to read from
245
268
src : borrow <input-stream >,
@@ -252,6 +275,7 @@ interface streams {
252
275
/// This is similar to `splice` , except that it blocks until the
253
276
/// `output-stream` is ready for writing, and the `input-stream`
254
277
/// is ready for reading, before performing the `splice` .
278
+ @since(version = 0.2.0)
255
279
blocking-splice : func (
256
280
/// The stream to read from
257
281
src : borrow <input-stream >,
0 commit comments