Skip to content

Commit e79b058

Browse files
author
Pat Hickey
authored
Merge pull request #144 from WebAssembly/pch/preview2
Release Preview 2: set package version to 0.2.0
2 parents 555cb48 + 437cd0f commit e79b058

File tree

13 files changed

+95
-45
lines changed

13 files changed

+95
-45
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
./wit-deps lock
1919
git add -N wit/deps
2020
git diff --exit-code
21-
- uses: WebAssembly/wit-abi-up-to-date@v16
21+
- uses: WebAssembly/wit-abi-up-to-date@v17

imports.md

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@
22
<ul>
33
<li>Imports:
44
<ul>
5-
<li>interface <a href="#wasi:io_error_0.2.0_rc_2023_11_10"><code>wasi:io/error@0.2.0-rc-2023-11-10</code></a></li>
6-
<li>interface <a href="#wasi:io_poll_0.2.0_rc_2023_11_10"><code>wasi:io/poll@0.2.0-rc-2023-11-10</code></a></li>
7-
<li>interface <a href="#wasi:io_streams_0.2.0_rc_2023_11_10"><code>wasi:io/streams@0.2.0-rc-2023-11-10</code></a></li>
8-
<li>interface <a href="#wasi:clocks_wall_clock_0.2.0_rc_2023_11_10"><code>wasi:clocks/wall-clock@0.2.0-rc-2023-11-10</code></a></li>
9-
<li>interface <a href="#wasi:filesystem_types_0.2.0_rc_2023_11_10"><code>wasi:filesystem/types@0.2.0-rc-2023-11-10</code></a></li>
10-
<li>interface <a href="#wasi:filesystem_preopens_0.2.0_rc_2023_11_10"><code>wasi:filesystem/preopens@0.2.0-rc-2023-11-10</code></a></li>
5+
<li>interface <a href="#wasi:io_error_0.2.0"><code>wasi:io/error@0.2.0</code></a></li>
6+
<li>interface <a href="#wasi:io_poll_0.2.0"><code>wasi:io/poll@0.2.0</code></a></li>
7+
<li>interface <a href="#wasi:io_streams_0.2.0"><code>wasi:io/streams@0.2.0</code></a></li>
8+
<li>interface <a href="#wasi:clocks_wall_clock_0.2.0"><code>wasi:clocks/wall-clock@0.2.0</code></a></li>
9+
<li>interface <a href="#wasi:filesystem_types_0.2.0"><code>wasi:filesystem/types@0.2.0</code></a></li>
10+
<li>interface <a href="#wasi:filesystem_preopens_0.2.0"><code>wasi:filesystem/preopens@0.2.0</code></a></li>
1111
</ul>
1212
</li>
1313
</ul>
14-
<h2><a name="wasi:io_error_0.2.0_rc_2023_11_10">Import interface wasi:io/error@0.2.0-rc-2023-11-10</a></h2>
14+
<h2><a name="wasi:io_error_0.2.0">Import interface wasi:io/error@0.2.0</a></h2>
1515
<hr />
1616
<h3>Types</h3>
1717
<h4><a name="error"><code>resource error</code></a></h4>
18-
<hr />
18+
<p>A resource which represents some error information.</p>
19+
<p>The only method provided by this resource is <code>to-debug-string</code>,
20+
which provides some human-readable information about the error.</p>
21+
<p>In the <code>wasi:io</code> package, this resource is returned through the
22+
<code>wasi:io/streams/stream-error</code> type.</p>
23+
<p>To provide more specific error information, other interfaces may
24+
provide functions to further &quot;downcast&quot; this error into more specific
25+
error information. For example, <a href="#error"><code>error</code></a>s returned in streams derived
26+
from filesystem types to be described using the filesystem's own
27+
error-code type, using the function
28+
<code>wasi:filesystem/types/filesystem-error-code</code>, which takes a parameter
29+
<code>borrow&lt;error&gt;</code> and returns
30+
<code>option&lt;wasi:filesystem/types/error-code&gt;</code>.</p>
31+
<h2>The set of functions which can &quot;downcast&quot; an <a href="#error"><code>error</code></a> into a more
32+
concrete type is open.</h2>
1933
<h3>Functions</h3>
2034
<h4><a name="method_error.to_debug_string"><code>[method]error.to-debug-string: func</code></a></h4>
2135
<p>Returns a string that is suitable to assist humans in debugging
@@ -32,13 +46,13 @@ hazard.</p>
3246
<ul>
3347
<li><a name="method_error.to_debug_string.0"></a> <code>string</code></li>
3448
</ul>
35-
<h2><a name="wasi:io_poll_0.2.0_rc_2023_11_10">Import interface wasi:io/poll@0.2.0-rc-2023-11-10</a></h2>
49+
<h2><a name="wasi:io_poll_0.2.0">Import interface wasi:io/poll@0.2.0</a></h2>
3650
<p>A poll API intended to let users wait for I/O events on multiple handles
3751
at once.</p>
3852
<hr />
3953
<h3>Types</h3>
4054
<h4><a name="pollable"><code>resource pollable</code></a></h4>
41-
<hr />
55+
<h2><a href="#pollable"><code>pollable</code></a> represents a single I/O event which may be ready, or not.</h2>
4256
<h3>Functions</h3>
4357
<h4><a name="method_pollable.ready"><code>[method]pollable.ready: func</code></a></h4>
4458
<p>Return the readiness of a pollable. This function never blocks.</p>
@@ -82,7 +96,7 @@ being reaedy for I/O.</p>
8296
<ul>
8397
<li><a name="poll.0"></a> list&lt;<code>u32</code>&gt;</li>
8498
</ul>
85-
<h2><a name="wasi:io_streams_0.2.0_rc_2023_11_10">Import interface wasi:io/streams@0.2.0-rc-2023-11-10</a></h2>
99+
<h2><a name="wasi:io_streams_0.2.0">Import interface wasi:io/streams@0.2.0</a></h2>
86100
<p>WASI I/O is an I/O abstraction API which is currently focused on providing
87101
stream types.</p>
88102
<p>In the future, the component model is expected to add built-in stream types;
@@ -112,11 +126,28 @@ future operations.
112126
</li>
113127
</ul>
114128
<h4><a name="input_stream"><code>resource input-stream</code></a></h4>
129+
<p>An input bytestream.</p>
130+
<p><a href="#input_stream"><code>input-stream</code></a>s are <em>non-blocking</em> to the extent practical on underlying
131+
platforms. I/O operations always return promptly; if fewer bytes are
132+
promptly available than requested, they return the number of bytes promptly
133+
available, which could even be zero. To wait for data to be available,
134+
use the <code>subscribe</code> function to obtain a <a href="#pollable"><code>pollable</code></a> which can be polled
135+
for using <code>wasi:io/poll</code>.</p>
115136
<h4><a name="output_stream"><code>resource output-stream</code></a></h4>
116-
<hr />
137+
<p>An output bytestream.</p>
138+
<h2><a href="#output_stream"><code>output-stream</code></a>s are <em>non-blocking</em> to the extent practical on
139+
underlying platforms. Except where specified otherwise, I/O operations also
140+
always return promptly, after the number of bytes that can be written
141+
promptly, which could even be zero. To wait for the stream to be ready to
142+
accept data, the <code>subscribe</code> function to obtain a <a href="#pollable"><code>pollable</code></a> which can be
143+
polled for using <code>wasi:io/poll</code>.</h2>
117144
<h3>Functions</h3>
118145
<h4><a name="method_input_stream.read"><code>[method]input-stream.read: func</code></a></h4>
119146
<p>Perform a non-blocking read from the stream.</p>
147+
<p>When the source of a <code>read</code> is binary data, the bytes from the source
148+
are returned verbatim. When the source of a <code>read</code> is known to the
149+
implementation to be text, bytes containing the UTF-8 encoding of the
150+
text are returned.</p>
120151
<p>This function returns a list of bytes containing the read data,
121152
when successful. The returned list will contain up to <code>len</code> bytes;
122153
it may return fewer than requested, but not more. The list is
@@ -212,6 +243,11 @@ error.</p>
212243
</ul>
213244
<h4><a name="method_output_stream.write"><code>[method]output-stream.write: func</code></a></h4>
214245
<p>Perform a write. This function never blocks.</p>
246+
<p>When the destination of a <code>write</code> is binary data, the bytes from
247+
<code>contents</code> are written verbatim. When the destination of a <code>write</code> is
248+
known to the implementation to be text, the bytes of <code>contents</code> are
249+
transcoded from UTF-8 into the encoding of the destination and then
250+
written.</p>
215251
<p>Precondition: check-write gave permit of Ok(n) and contents has a
216252
length of less than or equal to n. Otherwise, this function will trap.</p>
217253
<p>returns Err(closed) without writing if the stream has closed since
@@ -234,7 +270,7 @@ following pseudo-code:</p>
234270
<pre><code class="language-text">let pollable = this.subscribe();
235271
while !contents.is_empty() {
236272
// Wait for the stream to become writable
237-
poll-one(pollable);
273+
pollable.block();
238274
let Ok(n) = this.check-write(); // eliding error handling
239275
let len = min(n, contents.len());
240276
let (chunk, rest) = contents.split_at(len);
@@ -243,7 +279,7 @@ while !contents.is_empty() {
243279
}
244280
this.flush();
245281
// Wait for completion of `flush`
246-
poll-one(pollable);
282+
pollable.block();
247283
// Check for any errors that arose during `flush`
248284
let _ = this.check-write(); // eliding error handling
249285
</code></pre>
@@ -303,7 +339,7 @@ all derived <a href="#pollable"><code>pollable</code></a>s created with this fun
303339
</ul>
304340
<h4><a name="method_output_stream.write_zeroes"><code>[method]output-stream.write-zeroes: func</code></a></h4>
305341
<p>Write zeroes to a stream.</p>
306-
<p>this should be used precisely like <code>write</code> with the exact same
342+
<p>This should be used precisely like <code>write</code> with the exact same
307343
preconditions (must use check-write first), but instead of
308344
passing a list of bytes, you simply pass the number of zero-bytes
309345
that should be written.</p>
@@ -326,15 +362,15 @@ the following pseudo-code:</p>
326362
<pre><code class="language-text">let pollable = this.subscribe();
327363
while num_zeroes != 0 {
328364
// Wait for the stream to become writable
329-
poll-one(pollable);
365+
pollable.block();
330366
let Ok(n) = this.check-write(); // eliding error handling
331367
let len = min(n, num_zeroes);
332368
this.write-zeroes(len); // eliding error handling
333369
num_zeroes -= len;
334370
}
335371
this.flush();
336372
// Wait for completion of `flush`
337-
poll-one(pollable);
373+
pollable.block();
338374
// Check for any errors that arose during `flush`
339375
let _ = this.check-write(); // eliding error handling
340376
</code></pre>
@@ -385,7 +421,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
385421
<ul>
386422
<li><a name="method_output_stream.blocking_splice.0"></a> result&lt;<code>u64</code>, <a href="#stream_error"><a href="#stream_error"><code>stream-error</code></a></a>&gt;</li>
387423
</ul>
388-
<h2><a name="wasi:clocks_wall_clock_0.2.0_rc_2023_11_10">Import interface wasi:clocks/wall-clock@0.2.0-rc-2023-11-10</a></h2>
424+
<h2><a name="wasi:clocks_wall_clock_0.2.0">Import interface wasi:clocks/wall-clock@0.2.0</a></h2>
389425
<p>WASI Wall Clock is a clock API intended to let users query the current
390426
time. The name &quot;wall&quot; makes an analogy to a &quot;clock on the wall&quot;, which
391427
is not necessarily monotonic as it may be reset.</p>
@@ -426,7 +462,7 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
426462
<ul>
427463
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
428464
</ul>
429-
<h2><a name="wasi:filesystem_types_0.2.0_rc_2023_11_10">Import interface wasi:filesystem/types@0.2.0-rc-2023-11-10</a></h2>
465+
<h2><a name="wasi:filesystem_types_0.2.0">Import interface wasi:filesystem/types@0.2.0</a></h2>
430466
<p>WASI filesystem is a filesystem API primarily intended to let users run WASI
431467
programs that access their files on their existing filesystems, without
432468
significant overhead.</p>
@@ -856,8 +892,11 @@ not reuse it thereafter.
856892
</li>
857893
</ul>
858894
<h4><a name="descriptor"><code>resource descriptor</code></a></h4>
895+
<p>A descriptor is a reference to a filesystem object, which may be a file,
896+
directory, named pipe, special file, or other object on which filesystem
897+
calls may be made.</p>
859898
<h4><a name="directory_entry_stream"><code>resource directory-entry-stream</code></a></h4>
860-
<hr />
899+
<h2>A stream of directory entries.</h2>
861900
<h3>Functions</h3>
862901
<h4><a name="method_descriptor.read_via_stream"><code>[method]descriptor.read-via-stream: func</code></a></h4>
863902
<p>Return a stream for reading from a file, if available.</p>
@@ -1303,7 +1342,7 @@ errors are filesystem-related errors.</p>
13031342
<ul>
13041343
<li><a name="filesystem_error_code.0"></a> option&lt;<a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
13051344
</ul>
1306-
<h2><a name="wasi:filesystem_preopens_0.2.0_rc_2023_11_10">Import interface wasi:filesystem/preopens@0.2.0-rc-2023-11-10</a></h2>
1345+
<h2><a name="wasi:filesystem_preopens_0.2.0">Import interface wasi:filesystem/preopens@0.2.0</a></h2>
13071346
<hr />
13081347
<h3>Types</h3>
13091348
<h4><a name="descriptor"><code>type descriptor</code></a></h4>

wit/deps.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[clocks]
22
url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
3-
sha256 = "89da8eca4cd195516574c89c5b3c24a7b5af3ff2565c16753d20d3bdbc5fc60f"
4-
sha512 = "244079b3f592d58478a97adbd0bee8d49ae9dd1a3e435651ee40997b50da9fe62cfaba7e3ec7f7406d7d0288d278a43a3a0bc5150226ba40ce0f8ac6d33f7ddb"
3+
sha256 = "468b4d12892fe926b8eb5d398dbf579d566c93231fa44f415440572c695b7613"
4+
sha512 = "e6b53a07221f1413953c9797c68f08b815fdaebf66419bbc1ea3e8b7dece73731062693634731f311a03957b268cf9cc509c518bd15e513c318aa04a8459b93a"
55

66
[io]
77
url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
8-
sha256 = "f2e6127b235c37c06be675a904d6acf08db953ea688d78c42892c6ad3bd194e4"
9-
sha512 = "32feefbc115c34bf6968cb6e9dc15e755698ee90648e5a5d84448917c36a318bd61b401195eb64330e2475e1d098bfb8dee1440d594a68e0797748762bd84ae5"
8+
sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c"
9+
sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb"

wit/deps/clocks/monotonic-clock.wit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:clocks@0.2.0-rc-2023-11-10;
1+
package wasi:clocks@0.2.0;
22
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
33
/// time.
44
///
@@ -10,7 +10,7 @@ package wasi:clocks@0.2.0-rc-2023-11-10;
1010
///
1111
/// It is intended for measuring elapsed time.
1212
interface monotonic-clock {
13-
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};
13+
use wasi:io/poll@0.2.0.{pollable};
1414

1515
/// An instant in time, in nanoseconds. An instant is relative to an
1616
/// unspecified initial value, and can only be compared to instances from

wit/deps/clocks/wall-clock.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:clocks@0.2.0-rc-2023-11-10;
1+
package wasi:clocks@0.2.0;
22
/// WASI Wall Clock is a clock API intended to let users query the current
33
/// time. The name "wall" makes an analogy to a "clock on the wall", which
44
/// is not necessarily monotonic as it may be reset.

wit/deps/clocks/world.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:clocks@0.2.0-rc-2023-11-10;
1+
package wasi:clocks@0.2.0;
22

33
world imports {
44
import monotonic-clock;

wit/deps/io/error.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:io@0.2.0-rc-2023-11-10;
1+
package wasi:io@0.2.0;
22

33

44
interface error {

wit/deps/io/poll.wit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package wasi:io@0.2.0-rc-2023-11-10;
1+
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.
55
interface poll {
6-
/// `pollable` epresents a single I/O event which may be ready, or not.
6+
/// `pollable` represents a single I/O event which may be ready, or not.
77
resource pollable {
88

99
/// Return the readiness of a pollable. This function never blocks.

wit/deps/io/streams.wit

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

33
/// WASI I/O is an I/O abstraction API which is currently focused on providing
44
/// stream types.
@@ -32,6 +32,11 @@ interface streams {
3232
resource input-stream {
3333
/// Perform a non-blocking read from the stream.
3434
///
35+
/// When the source of a `read` is binary data, the bytes from the source
36+
/// are returned verbatim. When the source of a `read` is known to the
37+
/// implementation to be text, bytes containing the UTF-8 encoding of the
38+
/// text are returned.
39+
///
3540
/// This function returns a list of bytes containing the read data,
3641
/// when successful. The returned list will contain up to `len` bytes;
3742
/// it may return fewer than requested, but not more. The list is
@@ -111,6 +116,12 @@ interface streams {
111116

112117
/// Perform a write. This function never blocks.
113118
///
119+
/// When the destination of a `write` is binary data, the bytes from
120+
/// `contents` are written verbatim. When the destination of a `write` is
121+
/// known to the implementation to be text, the bytes of `contents` are
122+
/// transcoded from UTF-8 into the encoding of the destination and then
123+
/// written.
124+
///
114125
/// Precondition: check-write gave permit of Ok(n) and contents has a
115126
/// length of less than or equal to n. Otherwise, this function will trap.
116127
///
@@ -131,7 +142,7 @@ interface streams {
131142
/// let pollable = this.subscribe();
132143
/// while !contents.is_empty() {
133144
/// // Wait for the stream to become writable
134-
/// poll-one(pollable);
145+
/// pollable.block();
135146
/// let Ok(n) = this.check-write(); // eliding error handling
136147
/// let len = min(n, contents.len());
137148
/// let (chunk, rest) = contents.split_at(len);
@@ -140,7 +151,7 @@ interface streams {
140151
/// }
141152
/// this.flush();
142153
/// // Wait for completion of `flush`
143-
/// poll-one(pollable);
154+
/// pollable.block();
144155
/// // Check for any errors that arose during `flush`
145156
/// let _ = this.check-write(); // eliding error handling
146157
/// ```
@@ -178,7 +189,7 @@ interface streams {
178189

179190
/// Write zeroes to a stream.
180191
///
181-
/// this should be used precisely like `write` with the exact same
192+
/// This should be used precisely like `write` with the exact same
182193
/// preconditions (must use check-write first), but instead of
183194
/// passing a list of bytes, you simply pass the number of zero-bytes
184195
/// that should be written.
@@ -199,15 +210,15 @@ interface streams {
199210
/// let pollable = this.subscribe();
200211
/// while num_zeroes != 0 {
201212
/// // Wait for the stream to become writable
202-
/// poll-one(pollable);
213+
/// pollable.block();
203214
/// let Ok(n) = this.check-write(); // eliding error handling
204215
/// let len = min(n, num_zeroes);
205216
/// this.write-zeroes(len); // eliding error handling
206217
/// num_zeroes -= len;
207218
/// }
208219
/// this.flush();
209220
/// // Wait for completion of `flush`
210-
/// poll-one(pollable);
221+
/// pollable.block();
211222
/// // Check for any errors that arose during `flush`
212223
/// let _ = this.check-write(); // eliding error handling
213224
/// ```

wit/deps/io/world.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:io@0.2.0-rc-2023-11-10;
1+
package wasi:io@0.2.0;
22

33
world imports {
44
import streams;

0 commit comments

Comments
 (0)