Skip to content

Commit af271b4

Browse files
yoshuawuytsricochet
authored andcommitted
Document per-item versions using @since gates
1 parent 69d85eb commit af271b4

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

wit/error.wit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package wasi:io@0.2.0;
22

3-
3+
@since(version = 0.2.0)
44
interface error {
55
/// A resource which represents some error information.
66
///
@@ -19,6 +19,7 @@ interface error {
1919
///
2020
/// The set of functions which can "downcast" an `error` into a more
2121
/// concrete type is open.
22+
@since(version = 0.2.0)
2223
resource error {
2324
/// Returns a string that is suitable to assist humans in debugging
2425
/// this error.
@@ -27,6 +28,7 @@ interface error {
2728
/// It may change across platforms, hosts, or other implementation
2829
/// details. Parsing this string is a major platform-compatibility
2930
/// hazard.
31+
@since(version = 0.2.0)
3032
to-debug-string: func() -> string;
3133
}
3234
}

wit/poll.wit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@ package wasi:io@0.2.0;
22

33
/// A poll API intended to let users wait for I/O events on multiple handles
44
/// at once.
5+
@since(version = 0.2.0)
56
interface poll {
67
/// `pollable` represents a single I/O event which may be ready, or not.
8+
@since(version = 0.2.0)
79
resource pollable {
810

911
/// Return the readiness of a pollable. This function never blocks.
1012
///
1113
/// Returns `true` when the pollable is ready, and `false` otherwise.
14+
@since(version = 0.2.0)
1215
ready: func() -> bool;
1316

1417
/// `block` returns immediately if the pollable is ready, and otherwise
1518
/// blocks until ready.
1619
///
1720
/// This function is equivalent to calling `poll.poll` on a list
1821
/// containing only this pollable.
22+
@since(version = 0.2.0)
1923
block: func();
2024
}
2125

@@ -38,5 +42,6 @@ interface poll {
3842
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
3943
/// the pollables has an error, it is indicated by marking the source as
4044
/// being ready for I/O.
45+
@since(version = 0.2.0)
4146
poll: func(in: list<borrow<pollable>>) -> list<u32>;
4247
}

wit/streams.wit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ package wasi:io@0.2.0;
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)
89
interface 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>,

wit/world.wit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package wasi:io@0.2.0;
22

3+
@since(version = 0.2.0)
34
world imports {
5+
@since(version = 0.2.0)
46
import streams;
7+
8+
@since(version = 0.2.0)
59
import poll;
610
}

0 commit comments

Comments
 (0)