1
- package wasi : io
1
+ package wasi : io ;
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
8
interface streams {
9
- use poll . {pollable }
9
+ use poll . {pollable };
10
10
11
11
/// Streams provide a sequence of data and then end; once they end, they
12
12
/// no longer provide any further data.
@@ -58,14 +58,14 @@ interface streams {
58
58
read : func (
59
59
/// The maximum number of bytes to read
60
60
len : u64
61
- ) -> result <tuple <list <u8 >, stream-status >>
61
+ ) -> result <tuple <list <u8 >, stream-status >>;
62
62
63
63
/// Read bytes from a stream, after blocking until at least one byte can
64
64
/// be read. Except for blocking, identical to `read` .
65
65
blocking-read : func (
66
66
/// The maximum number of bytes to read
67
67
len : u64
68
- ) -> result <tuple <list <u8 >, stream-status >>
68
+ ) -> result <tuple <list <u8 >, stream-status >>;
69
69
70
70
/// Skip bytes from a stream.
71
71
///
@@ -82,22 +82,22 @@ interface streams {
82
82
skip : func (
83
83
/// The maximum number of bytes to skip.
84
84
len : u64 ,
85
- ) -> result <tuple <u64 , stream-status >>
85
+ ) -> result <tuple <u64 , stream-status >>;
86
86
87
87
/// Skip bytes from a stream, after blocking until at least one byte
88
88
/// can be skipped. Except for blocking behavior, identical to `skip` .
89
89
blocking-skip : func (
90
90
/// The maximum number of bytes to skip.
91
91
len : u64 ,
92
- ) -> result <tuple <u64 , stream-status >>
92
+ ) -> result <tuple <u64 , stream-status >>;
93
93
94
94
/// Create a `pollable` which will resolve once either the specified stream
95
95
/// has bytes available to read or the other end of the stream has been
96
96
/// closed.
97
97
/// The created `pollable` is a child resource of the `input-stream` .
98
98
/// Implementations may trap if the `input-stream` is dropped before
99
99
/// all derived `pollable` s created with this function are dropped.
100
- subscribe : func () -> pollable
100
+ subscribe : func () -> pollable ;
101
101
}
102
102
103
103
/// An error for output-stream operations.
@@ -131,7 +131,7 @@ interface streams {
131
131
/// When this function returns 0 bytes, the `subscribe` pollable will
132
132
/// become ready when this function will report at least 1 byte, or an
133
133
/// error.
134
- check-write : func () -> result <u64 , write-error >
134
+ check-write : func () -> result <u64 , write-error >;
135
135
136
136
/// Perform a write. This function never blocks.
137
137
///
@@ -142,7 +142,7 @@ interface streams {
142
142
/// the last call to check-write provided a permit.
143
143
write : func (
144
144
contents : list <u8 >
145
- ) -> result <_ , write-error >
145
+ ) -> result <_ , write-error >;
146
146
147
147
/// Perform a write of up to 4096 bytes, and then flush the stream. Block
148
148
/// until all of these operations are complete, or an error occurs.
@@ -170,7 +170,7 @@ interface streams {
170
170
/// `` `
171
171
blocking-write-and-flush : func (
172
172
contents : list <u8 >
173
- ) -> result <_ , write-error >
173
+ ) -> result <_ , write-error >;
174
174
175
175
/// Request to flush buffered output. This function never blocks.
176
176
///
@@ -182,11 +182,11 @@ interface streams {
182
182
/// writes (`check-write` will return `ok(0)` ) until the flush has
183
183
/// completed. The `subscribe` pollable will become ready when the
184
184
/// flush has completed and the stream can accept more writes.
185
- flush : func () -> result <_ , write-error >
185
+ flush : func () -> result <_ , write-error >;
186
186
187
187
/// Request to flush buffered output, and block until flush completes
188
188
/// and stream is ready for writing again.
189
- blocking-flush : func () -> result <_ , write-error >
189
+ blocking-flush : func () -> result <_ , write-error >;
190
190
191
191
/// Create a `pollable` which will resolve once the output-stream
192
192
/// is ready for more writing, or an error has occured. When this
@@ -198,7 +198,7 @@ interface streams {
198
198
/// The created `pollable` is a child resource of the `output-stream` .
199
199
/// Implementations may trap if the `output-stream` is dropped before
200
200
/// all derived `pollable` s created with this function are dropped.
201
- subscribe : func () -> pollable
201
+ subscribe : func () -> pollable ;
202
202
203
203
/// Write zeroes to a stream.
204
204
///
@@ -209,7 +209,7 @@ interface streams {
209
209
write-zeroes : func (
210
210
/// The number of zero-bytes to write
211
211
len : u64
212
- ) -> result <_ , write-error >
212
+ ) -> result <_ , write-error >;
213
213
214
214
/// Perform a write of up to 4096 zeroes, and then flush the stream.
215
215
/// Block until all of these operations are complete, or an error
@@ -238,7 +238,7 @@ interface streams {
238
238
blocking-write-zeroes-and-flush : func (
239
239
/// The number of zero-bytes to write
240
240
len : u64
241
- ) -> result <_ , write-error >
241
+ ) -> result <_ , write-error >;
242
242
243
243
/// Read from one stream and write to another.
244
244
///
@@ -252,7 +252,7 @@ interface streams {
252
252
src : input-stream ,
253
253
/// The number of bytes to splice
254
254
len : u64 ,
255
- ) -> result <tuple <u64 , stream-status >>
255
+ ) -> result <tuple <u64 , stream-status >>;
256
256
257
257
/// Read from one stream and write to another, with blocking.
258
258
///
@@ -263,7 +263,7 @@ interface streams {
263
263
src : input-stream ,
264
264
/// The number of bytes to splice
265
265
len : u64 ,
266
- ) -> result <tuple <u64 , stream-status >>
266
+ ) -> result <tuple <u64 , stream-status >>;
267
267
268
268
/// Forward the entire contents of an input stream to an output stream.
269
269
///
@@ -280,6 +280,6 @@ interface streams {
280
280
forward : func (
281
281
/// The stream to read from
282
282
src : input-stream
283
- ) -> result <tuple <u64 , stream-status >>
283
+ ) -> result <tuple <u64 , stream-status >>;
284
284
}
285
285
}
0 commit comments