Skip to content

Commit f9a4a57

Browse files
yoshuawuytsricochet
authored andcommitted
Update to v0.2.1
1 parent 289bc58 commit f9a4a57

File tree

12 files changed

+94
-51
lines changed

12 files changed

+94
-51
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- name: ensure `./wit/deps` are in sync
1515
run: |
16-
curl -Lo 'wit-deps' https://github.com/bytecodealliance/wit-deps/releases/download/v0.3.3/wit-deps-x86_64-unknown-linux-musl
16+
curl -Lo 'wit-deps' https://github.com/bytecodealliance/wit-deps/releases/download/v0.3.5/wit-deps-x86_64-unknown-linux-musl
1717
chmod +x wit-deps
1818
./wit-deps lock
1919
git add -N wit/deps
2020
git diff --exit-code
2121
- uses: WebAssembly/wit-abi-up-to-date@v21
2222
with:
2323
features: clocks-timezone
24+
wit-bindgen: '0.28.0'

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,26 @@ WASI clocks must have at least two complete independent implementations.
2121

2222
## Table of Contents
2323

24-
- [Introduction](#introduction)
25-
- [Goals](#goals)
26-
- [Non-goals](#non-goals)
27-
- [API walk-through](#api-walk-through)
28-
- [Use case 1](#use-case-1)
29-
- [Use case 2](#use-case-2)
30-
- [Detailed design discussion](#detailed-design-discussion)
31-
- [[Tricky design choice 1]](#tricky-design-choice-1)
32-
- [[Tricky design choice 2]](#tricky-design-choice-2)
33-
- [Considered alternatives](#considered-alternatives)
34-
- [[Alternative 1]](#alternative-1)
35-
- [[Alternative 2]](#alternative-2)
36-
- [Stakeholder Interest & Feedback](#stakeholder-interest--feedback)
37-
- [References & acknowledgements](#references--acknowledgements)
38-
- [Development](#development)
24+
- [WASI Clocks](#wasi-clocks)
25+
- [Current Phase](#current-phase)
26+
- [Champions](#champions)
27+
- [Portability Criteria](#portability-criteria)
28+
- [Table of Contents](#table-of-contents)
29+
- [Introduction](#introduction)
30+
- [Goals](#goals)
31+
- [Non-goals](#non-goals)
32+
- [API walk-through](#api-walk-through)
33+
- [Measuring elapsed time](#measuring-elapsed-time)
34+
- [Telling the current human time:](#telling-the-current-human-time)
35+
- [Retrieving the timezone:](#retrieving-the-timezone)
36+
- [Detailed design discussion](#detailed-design-discussion)
37+
- [What should the type of a timestamp be?](#what-should-the-type-of-a-timestamp-be)
38+
- [Considered alternatives](#considered-alternatives)
39+
- [Per-process and per-thread clocks](#per-process-and-per-thread-clocks)
40+
- [Stakeholder Interest \& Feedback](#stakeholder-interest--feedback)
41+
- [References \& acknowledgements](#references--acknowledgements)
42+
- [Development](#development)
43+
- [Generating imports.md](#generating-importsmd)
3944

4045
### Introduction
4146

imports.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<ul>
33
<li>Imports:
44
<ul>
5-
<li>interface <a href="#wasi_io_poll_0_2_0"><code>wasi:io/[email protected].0</code></a></li>
6-
<li>interface <a href="#wasi_clocks_monotonic_clock_0_2_0"><code>wasi:clocks/[email protected].0</code></a></li>
7-
<li>interface <a href="#wasi_clocks_wall_clock_0_2_0"><code>wasi:clocks/[email protected].0</code></a></li>
8-
<li>interface <a href="#wasi_clocks_timezone_0_2_0"><code>wasi:clocks/[email protected].0</code></a></li>
5+
<li>interface <a href="#wasi_io_poll_0_2_1"><code>wasi:io/[email protected].1</code></a></li>
6+
<li>interface <a href="#wasi_clocks_monotonic_clock_0_2_1"><code>wasi:clocks/[email protected].1</code></a></li>
7+
<li>interface <a href="#wasi_clocks_wall_clock_0_2_1"><code>wasi:clocks/[email protected].1</code></a></li>
8+
<li>interface <a href="#wasi_clocks_timezone_0_2_1"><code>wasi:clocks/[email protected].1</code></a></li>
99
</ul>
1010
</li>
1111
</ul>
12-
<h2><a name="wasi_io_poll_0_2_0"></a>Import interface wasi:io/[email protected].0</h2>
12+
<h2><a name="wasi_io_poll_0_2_1"></a>Import interface wasi:io/[email protected].1</h2>
1313
<p>A poll API intended to let users wait for I/O events on multiple handles
1414
at once.</p>
1515
<hr />
@@ -43,14 +43,17 @@ containing only this pollable.</p>
4343
interest, and waits until one or more of the events is ready for I/O.</p>
4444
<p>The result <code>list&lt;u32&gt;</code> contains one or more indices of handles in the
4545
argument list that is ready for I/O.</p>
46-
<p>If the list contains more elements than can be indexed with a <code>u32</code>
47-
value, this function traps.</p>
46+
<p>This function traps if either:</p>
47+
<ul>
48+
<li>the list is empty, or:</li>
49+
<li>the list contains more elements than can be indexed with a <code>u32</code> value.</li>
50+
</ul>
4851
<p>A timeout can be implemented by adding a pollable from the
4952
wasi-clocks API to the list.</p>
5053
<p>This function does not return a <code>result</code>; polling in itself does not
5154
do any I/O so it doesn't fail. If any of the I/O sources identified by
5255
the pollables has an error, it is indicated by marking the source as
53-
being reaedy for I/O.</p>
56+
being ready for I/O.</p>
5457
<h5>Params</h5>
5558
<ul>
5659
<li><a name="poll.in"></a><code>in</code>: list&lt;borrow&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;&gt;</li>
@@ -59,7 +62,7 @@ being reaedy for I/O.</p>
5962
<ul>
6063
<li><a name="poll.0"></a> list&lt;<code>u32</code>&gt;</li>
6164
</ul>
62-
<h2><a name="wasi_clocks_monotonic_clock_0_2_0"></a>Import interface wasi:clocks/[email protected].0</h2>
65+
<h2><a name="wasi_clocks_monotonic_clock_0_2_1"></a>Import interface wasi:clocks/[email protected].1</h2>
6366
<p>WASI Monotonic Clock is a clock API intended to let users measure elapsed
6467
time.</p>
6568
<p>It is intended to be portable at least between Unix-family platforms and
@@ -118,7 +121,7 @@ elapsed from the time this function is invoked.</p>
118121
<ul>
119122
<li><a name="subscribe_duration.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
120123
</ul>
121-
<h2><a name="wasi_clocks_wall_clock_0_2_0"></a>Import interface wasi:clocks/[email protected].0</h2>
124+
<h2><a name="wasi_clocks_wall_clock_0_2_1"></a>Import interface wasi:clocks/[email protected].1</h2>
122125
<p>WASI Wall Clock is a clock API intended to let users query the current
123126
time. The name &quot;wall&quot; makes an analogy to a &quot;clock on the wall&quot;, which
124127
is not necessarily monotonic as it may be reset.</p>
@@ -159,7 +162,7 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
159162
<ul>
160163
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
161164
</ul>
162-
<h2><a name="wasi_clocks_timezone_0_2_0"></a>Import interface wasi:clocks/[email protected].0</h2>
165+
<h2><a name="wasi_clocks_timezone_0_2_1"></a>Import interface wasi:clocks/[email protected].1</h2>
163166
<hr />
164167
<h3>Types</h3>
165168
<h4><a name="datetime"></a><code>type datetime</code></h4>

wit/deps.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[io]
22
url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
3-
sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
4-
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"
3+
sha256 = "2a74bd811adc46b5a0f19827ddbde89870e52b17615f4d0873f06fd977250caf"
4+
sha512 = "94624f00c66e66203592cee820f80b1ba91ecdb71f682c154f25eaf71f8d8954197dcb64503bc21e72ed5e812af7eae876df47b7eb727b02db3a74a7ce0aefca"

wit/deps/io/error.wit

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package wasi:io@0.2.0;
2-
1+
package wasi:io@0.2.1;
32

3+
@since(version = 0.2.0)
44
interface error {
55
/// A resource which represents some error information.
66
///
@@ -11,16 +11,15 @@ interface error {
1111
/// `wasi:io/streams/stream-error` type.
1212
///
1313
/// To provide more specific error information, other interfaces may
14-
/// provide functions to further "downcast" this error into more specific
15-
/// error information. For example, `error`s returned in streams derived
16-
/// from filesystem types to be described using the filesystem's own
17-
/// error-code type, using the function
18-
/// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
19-
/// `borrow<error>` and returns
20-
/// `option<wasi:filesystem/types/error-code>`.
14+
/// offer functions to "downcast" this error into more specific types. For example,
15+
/// errors returned from streams derived from filesystem types can be described using
16+
/// the filesystem's own error-code type. This is done using the function
17+
/// `wasi:filesystem/types/filesystem-error-code`, which takes a `borrow<error>`
18+
/// parameter and returns an `option<wasi:filesystem/types/error-code>`.
2119
///
2220
/// The set of functions which can "downcast" an `error` into a more
2321
/// concrete type is open.
22+
@since(version = 0.2.0)
2423
resource error {
2524
/// Returns a string that is suitable to assist humans in debugging
2625
/// this error.
@@ -29,6 +28,7 @@ interface error {
2928
/// It may change across platforms, hosts, or other implementation
3029
/// details. Parsing this string is a major platform-compatibility
3130
/// hazard.
31+
@since(version = 0.2.0)
3232
to-debug-string: func() -> string;
3333
}
3434
}

wit/deps/io/poll.wit

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
package wasi:io@0.2.0;
1+
package wasi:io@0.2.1;
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

@@ -27,15 +31,17 @@ interface poll {
2731
/// The result `list<u32>` contains one or more indices of handles in the
2832
/// argument list that is ready for I/O.
2933
///
30-
/// If the list contains more elements than can be indexed with a `u32`
31-
/// value, this function traps.
34+
/// This function traps if either:
35+
/// - the list is empty, or:
36+
/// - the list contains more elements than can be indexed with a `u32` value.
3237
///
3338
/// A timeout can be implemented by adding a pollable from the
3439
/// wasi-clocks API to the list.
3540
///
3641
/// This function does not return a `result`; polling in itself does not
3742
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
3843
/// the pollables has an error, it is indicated by marking the source as
39-
/// being reaedy for I/O.
44+
/// being ready for I/O.
45+
@since(version = 0.2.0)
4046
poll: func(in: list<borrow<pollable>>) -> list<u32>;
4147
}

wit/deps/io/streams.wit

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
package wasi:io@0.2.0;
1+
package wasi:io@0.2.1;
22

33
/// WASI I/O is an I/O abstraction API which is currently focused on providing
44
/// stream types.
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 {
10+
@since(version = 0.2.0)
911
use error.{error};
12+
@since(version = 0.2.0)
1013
use poll.{pollable};
1114

1215
/// An error for input-stream and output-stream operations.
16+
@since(version = 0.2.0)
1317
variant stream-error {
1418
/// The last operation (a write or flush) failed before completion.
1519
///
@@ -29,6 +33,7 @@ interface streams {
2933
/// available, which could even be zero. To wait for data to be available,
3034
/// use the `subscribe` function to obtain a `pollable` which can be polled
3135
/// for using `wasi:io/poll`.
36+
@since(version = 0.2.0)
3237
resource input-stream {
3338
/// Perform a non-blocking read from the stream.
3439
///
@@ -56,13 +61,15 @@ interface streams {
5661
/// is not possible to allocate in wasm32, or not desirable to allocate as
5762
/// as a return value by the callee. The callee may return a list of bytes
5863
/// less than `len` in size while more bytes are available for reading.
64+
@since(version = 0.2.0)
5965
read: func(
6066
/// The maximum number of bytes to read
6167
len: u64
6268
) -> result<list<u8>, stream-error>;
6369

6470
/// Read bytes from a stream, after blocking until at least one byte can
6571
/// be read. Except for blocking, behavior is identical to `read`.
72+
@since(version = 0.2.0)
6673
blocking-read: func(
6774
/// The maximum number of bytes to read
6875
len: u64
@@ -72,13 +79,15 @@ interface streams {
7279
///
7380
/// Behaves identical to `read`, except instead of returning a list
7481
/// of bytes, returns the number of bytes consumed from the stream.
82+
@since(version = 0.2.0)
7583
skip: func(
7684
/// The maximum number of bytes to skip.
7785
len: u64,
7886
) -> result<u64, stream-error>;
7987

8088
/// Skip bytes from a stream, after blocking until at least one byte
8189
/// can be skipped. Except for blocking behavior, identical to `skip`.
90+
@since(version = 0.2.0)
8291
blocking-skip: func(
8392
/// The maximum number of bytes to skip.
8493
len: u64,
@@ -90,6 +99,7 @@ interface streams {
9099
/// The created `pollable` is a child resource of the `input-stream`.
91100
/// Implementations may trap if the `input-stream` is dropped before
92101
/// all derived `pollable`s created with this function are dropped.
102+
@since(version = 0.2.0)
93103
subscribe: func() -> pollable;
94104
}
95105

@@ -102,6 +112,11 @@ interface streams {
102112
/// promptly, which could even be zero. To wait for the stream to be ready to
103113
/// accept data, the `subscribe` function to obtain a `pollable` which can be
104114
/// 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)
105120
resource output-stream {
106121
/// Check readiness for writing. This function never blocks.
107122
///
@@ -112,6 +127,7 @@ interface streams {
112127
/// When this function returns 0 bytes, the `subscribe` pollable will
113128
/// become ready when this function will report at least 1 byte, or an
114129
/// error.
130+
@since(version = 0.2.0)
115131
check-write: func() -> result<u64, stream-error>;
116132

117133
/// Perform a write. This function never blocks.
@@ -127,6 +143,7 @@ interface streams {
127143
///
128144
/// returns Err(closed) without writing if the stream has closed since
129145
/// the last call to check-write provided a permit.
146+
@since(version = 0.2.0)
130147
write: func(
131148
contents: list<u8>
132149
) -> result<_, stream-error>;
@@ -155,6 +172,7 @@ interface streams {
155172
/// // Check for any errors that arose during `flush`
156173
/// let _ = this.check-write(); // eliding error handling
157174
/// ```
175+
@since(version = 0.2.0)
158176
blocking-write-and-flush: func(
159177
contents: list<u8>
160178
) -> result<_, stream-error>;
@@ -169,14 +187,16 @@ interface streams {
169187
/// writes (`check-write` will return `ok(0)`) until the flush has
170188
/// completed. The `subscribe` pollable will become ready when the
171189
/// flush has completed and the stream can accept more writes.
190+
@since(version = 0.2.0)
172191
flush: func() -> result<_, stream-error>;
173192

174193
/// Request to flush buffered output, and block until flush completes
175194
/// and stream is ready for writing again.
195+
@since(version = 0.2.0)
176196
blocking-flush: func() -> result<_, stream-error>;
177197

178198
/// 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
180200
/// pollable is ready, `check-write` will return `ok(n)` with n>0, or an
181201
/// error.
182202
///
@@ -193,6 +213,7 @@ interface streams {
193213
/// preconditions (must use check-write first), but instead of
194214
/// passing a list of bytes, you simply pass the number of zero-bytes
195215
/// that should be written.
216+
@since(version = 0.2.0)
196217
write-zeroes: func(
197218
/// The number of zero-bytes to write
198219
len: u64
@@ -222,14 +243,15 @@ interface streams {
222243
/// // Check for any errors that arose during `flush`
223244
/// let _ = this.check-write(); // eliding error handling
224245
/// ```
246+
@since(version = 0.2.0)
225247
blocking-write-zeroes-and-flush: func(
226248
/// The number of zero-bytes to write
227249
len: u64
228250
) -> result<_, stream-error>;
229251

230252
/// Read from one stream and write to another.
231253
///
232-
/// The behavior of splice is equivelant to:
254+
/// The behavior of splice is equivalent to:
233255
/// 1. calling `check-write` on the `output-stream`
234256
/// 2. calling `read` on the `input-stream` with the smaller of the
235257
/// `check-write` permitted length and the `len` provided to `splice`
@@ -240,6 +262,7 @@ interface streams {
240262
///
241263
/// This function returns the number of bytes transferred; it may be less
242264
/// than `len`.
265+
@since(version = 0.2.0)
243266
splice: func(
244267
/// The stream to read from
245268
src: borrow<input-stream>,
@@ -252,6 +275,7 @@ interface streams {
252275
/// This is similar to `splice`, except that it blocks until the
253276
/// `output-stream` is ready for writing, and the `input-stream`
254277
/// is ready for reading, before performing the `splice`.
278+
@since(version = 0.2.0)
255279
blocking-splice: func(
256280
/// The stream to read from
257281
src: borrow<input-stream>,

wit/deps/io/world.wit

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
package wasi:io@0.2.0;
1+
package wasi:io@0.2.1;
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)