Skip to content

Commit 7b74a93

Browse files
authored
Merge pull request #50 from WebAssembly/simplify-with-include
refactor: use include syntax for wasi:clocks
2 parents d25b294 + 791ac77 commit 7b74a93

File tree

2 files changed

+148
-149
lines changed

2 files changed

+148
-149
lines changed

proxy.md

Lines changed: 147 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ outgoing HTTP requests.</p>
66
<ul>
77
<li>Imports:
88
<ul>
9-
<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>
10-
<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>
11-
<li>interface <a href="#wasi:clocks_monotonic_clock_0.2.0_rc_2023_11_10"><code>wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10</code></a></li>
129
<li>interface <a href="#wasi:random_random_0.2.0_rc_2023_11_10"><code>wasi:random/random@0.2.0-rc-2023-11-10</code></a></li>
1310
<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>
11+
<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>
1412
<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>
1513
<li>interface <a href="#wasi:cli_stdout_0.2.0_rc_2023_11_10"><code>wasi:cli/stdout@0.2.0-rc-2023-11-10</code></a></li>
1614
<li>interface <a href="#wasi:cli_stderr_0.2.0_rc_2023_11_10"><code>wasi:cli/stderr@0.2.0-rc-2023-11-10</code></a></li>
1715
<li>interface <a href="#wasi:cli_stdin_0.2.0_rc_2023_11_10"><code>wasi:cli/stdin@0.2.0-rc-2023-11-10</code></a></li>
16+
<li>interface <a href="#wasi:clocks_monotonic_clock_0.2.0_rc_2023_11_10"><code>wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10</code></a></li>
1817
<li>interface <a href="#wasi:http_types_0.2.0_rc_2023_11_10"><code>wasi:http/types@0.2.0-rc-2023-11-10</code></a></li>
1918
<li>interface <a href="#wasi:http_outgoing_handler_0.2.0_rc_2023_11_10"><code>wasi:http/outgoing-handler@0.2.0-rc-2023-11-10</code></a></li>
19+
<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>
2020
</ul>
2121
</li>
2222
<li>Exports:
@@ -25,46 +25,59 @@ outgoing HTTP requests.</p>
2525
</ul>
2626
</li>
2727
</ul>
28-
<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>
29-
<p>WASI Wall Clock is a clock API intended to let users query the current
30-
time. The name &quot;wall&quot; makes an analogy to a &quot;clock on the wall&quot;, which
31-
is not necessarily monotonic as it may be reset.</p>
28+
<h2><a name="wasi:random_random_0.2.0_rc_2023_11_10">Import interface wasi:random/random@0.2.0-rc-2023-11-10</a></h2>
29+
<p>WASI Random is a random data API.</p>
3230
<p>It is intended to be portable at least between Unix-family platforms and
3331
Windows.</p>
34-
<p>A wall clock is a clock which measures the date and time according to
35-
some external reference.</p>
36-
<p>External references may be reset, so this clock is not necessarily
37-
monotonic, making it unsuitable for measuring elapsed time.</p>
38-
<p>It is intended for reporting the current date and time for humans.</p>
3932
<hr />
40-
<h3>Types</h3>
41-
<h4><a name="datetime"><code>record datetime</code></a></h4>
42-
<p>A time and date in seconds plus nanoseconds.</p>
43-
<h5>Record Fields</h5>
33+
<h3>Functions</h3>
34+
<h4><a name="get_random_bytes"><code>get-random-bytes: func</code></a></h4>
35+
<p>Return <code>len</code> cryptographically-secure random or pseudo-random bytes.</p>
36+
<p>This function must produce data at least as cryptographically secure and
37+
fast as an adequately seeded cryptographically-secure pseudo-random
38+
number generator (CSPRNG). It must not block, from the perspective of
39+
the calling program, under any circumstances, including on the first
40+
request and on requests for numbers of bytes. The returned data must
41+
always be unpredictable.</p>
42+
<p>This function must always return fresh data. Deterministic environments
43+
must omit this function, rather than implementing it with deterministic
44+
data.</p>
45+
<h5>Params</h5>
4446
<ul>
45-
<li><a name="datetime.seconds"><code>seconds</code></a>: <code>u64</code></li>
46-
<li><a name="datetime.nanoseconds"><code>nanoseconds</code></a>: <code>u32</code></li>
47+
<li><a name="get_random_bytes.len"><code>len</code></a>: <code>u64</code></li>
4748
</ul>
49+
<h5>Return values</h5>
50+
<ul>
51+
<li><a name="get_random_bytes.0"></a> list&lt;<code>u8</code>&gt;</li>
52+
</ul>
53+
<h4><a name="get_random_u64"><code>get-random-u64: func</code></a></h4>
54+
<p>Return a cryptographically-secure random or pseudo-random <code>u64</code> value.</p>
55+
<p>This function returns the same type of data as <a href="#get_random_bytes"><code>get-random-bytes</code></a>,
56+
represented as a <code>u64</code>.</p>
57+
<h5>Return values</h5>
58+
<ul>
59+
<li><a name="get_random_u64.0"></a> <code>u64</code></li>
60+
</ul>
61+
<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>
62+
<hr />
63+
<h3>Types</h3>
64+
<h4><a name="error"><code>resource error</code></a></h4>
4865
<hr />
4966
<h3>Functions</h3>
50-
<h4><a name="now"><code>now: func</code></a></h4>
51-
<p>Read the current value of the clock.</p>
52-
<p>This clock is not monotonic, therefore calling this function repeatedly
53-
will not necessarily produce a sequence of non-decreasing values.</p>
54-
<p>The returned timestamps represent the number of seconds since
55-
1970-01-01T00:00:00Z, also known as <a href="https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16">POSIX's Seconds Since the Epoch</a>,
56-
also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</p>
57-
<p>The nanoseconds field of the output is always less than 1000000000.</p>
58-
<h5>Return values</h5>
67+
<h4><a name="method_error.to_debug_string"><code>[method]error.to-debug-string: func</code></a></h4>
68+
<p>Returns a string that is suitable to assist humans in debugging
69+
this error.</p>
70+
<p>WARNING: The returned string should not be consumed mechanically!
71+
It may change across platforms, hosts, or other implementation
72+
details. Parsing this string is a major platform-compatibility
73+
hazard.</p>
74+
<h5>Params</h5>
5975
<ul>
60-
<li><a name="now.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
76+
<li><a name="method_error.to_debug_string.self"><code>self</code></a>: borrow&lt;<a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
6177
</ul>
62-
<h4><a name="resolution"><code>resolution: func</code></a></h4>
63-
<p>Query the resolution of the clock.</p>
64-
<p>The nanoseconds field of the output is always less than 1000000000.</p>
6578
<h5>Return values</h5>
6679
<ul>
67-
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
80+
<li><a name="method_error.to_debug_string.0"></a> <code>string</code></li>
6881
</ul>
6982
<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>
7083
<p>A poll API intended to let users wait for I/O events on multiple handles
@@ -116,121 +129,6 @@ being reaedy for I/O.</p>
116129
<ul>
117130
<li><a name="poll.0"></a> list&lt;<code>u32</code>&gt;</li>
118131
</ul>
119-
<h2><a name="wasi:clocks_monotonic_clock_0.2.0_rc_2023_11_10">Import interface wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10</a></h2>
120-
<p>WASI Monotonic Clock is a clock API intended to let users measure elapsed
121-
time.</p>
122-
<p>It is intended to be portable at least between Unix-family platforms and
123-
Windows.</p>
124-
<p>A monotonic clock is a clock which has an unspecified initial value, and
125-
successive reads of the clock will produce non-decreasing values.</p>
126-
<p>It is intended for measuring elapsed time.</p>
127-
<hr />
128-
<h3>Types</h3>
129-
<h4><a name="pollable"><code>type pollable</code></a></h4>
130-
<p><a href="#pollable"><a href="#pollable"><code>pollable</code></a></a></p>
131-
<p>
132-
#### <a name="instant">`type instant`</a>
133-
`u64`
134-
<p>An instant in time, in nanoseconds. An instant is relative to an
135-
unspecified initial value, and can only be compared to instances from
136-
the same monotonic-clock.
137-
<h4><a name="duration"><code>type duration</code></a></h4>
138-
<p><code>u64</code></p>
139-
<p>A duration of time, in nanoseconds.
140-
<hr />
141-
<h3>Functions</h3>
142-
<h4><a name="now"><code>now: func</code></a></h4>
143-
<p>Read the current value of the clock.</p>
144-
<p>The clock is monotonic, therefore calling this function repeatedly will
145-
produce a sequence of non-decreasing values.</p>
146-
<h5>Return values</h5>
147-
<ul>
148-
<li><a name="now.0"></a> <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
149-
</ul>
150-
<h4><a name="resolution"><code>resolution: func</code></a></h4>
151-
<p>Query the resolution of the clock. Returns the duration of time
152-
corresponding to a clock tick.</p>
153-
<h5>Return values</h5>
154-
<ul>
155-
<li><a name="resolution.0"></a> <a href="#duration"><a href="#duration"><code>duration</code></a></a></li>
156-
</ul>
157-
<h4><a name="subscribe_instant"><code>subscribe-instant: func</code></a></h4>
158-
<p>Create a <a href="#pollable"><code>pollable</code></a> which will resolve once the specified instant
159-
occured.</p>
160-
<h5>Params</h5>
161-
<ul>
162-
<li><a name="subscribe_instant.when"><code>when</code></a>: <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
163-
</ul>
164-
<h5>Return values</h5>
165-
<ul>
166-
<li><a name="subscribe_instant.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
167-
</ul>
168-
<h4><a name="subscribe_duration"><code>subscribe-duration: func</code></a></h4>
169-
<p>Create a <a href="#pollable"><code>pollable</code></a> which will resolve once the given duration has
170-
elapsed, starting at the time at which this function was called.
171-
occured.</p>
172-
<h5>Params</h5>
173-
<ul>
174-
<li><a name="subscribe_duration.when"><code>when</code></a>: <a href="#duration"><a href="#duration"><code>duration</code></a></a></li>
175-
</ul>
176-
<h5>Return values</h5>
177-
<ul>
178-
<li><a name="subscribe_duration.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
179-
</ul>
180-
<h2><a name="wasi:random_random_0.2.0_rc_2023_11_10">Import interface wasi:random/random@0.2.0-rc-2023-11-10</a></h2>
181-
<p>WASI Random is a random data API.</p>
182-
<p>It is intended to be portable at least between Unix-family platforms and
183-
Windows.</p>
184-
<hr />
185-
<h3>Functions</h3>
186-
<h4><a name="get_random_bytes"><code>get-random-bytes: func</code></a></h4>
187-
<p>Return <code>len</code> cryptographically-secure random or pseudo-random bytes.</p>
188-
<p>This function must produce data at least as cryptographically secure and
189-
fast as an adequately seeded cryptographically-secure pseudo-random
190-
number generator (CSPRNG). It must not block, from the perspective of
191-
the calling program, under any circumstances, including on the first
192-
request and on requests for numbers of bytes. The returned data must
193-
always be unpredictable.</p>
194-
<p>This function must always return fresh data. Deterministic environments
195-
must omit this function, rather than implementing it with deterministic
196-
data.</p>
197-
<h5>Params</h5>
198-
<ul>
199-
<li><a name="get_random_bytes.len"><code>len</code></a>: <code>u64</code></li>
200-
</ul>
201-
<h5>Return values</h5>
202-
<ul>
203-
<li><a name="get_random_bytes.0"></a> list&lt;<code>u8</code>&gt;</li>
204-
</ul>
205-
<h4><a name="get_random_u64"><code>get-random-u64: func</code></a></h4>
206-
<p>Return a cryptographically-secure random or pseudo-random <code>u64</code> value.</p>
207-
<p>This function returns the same type of data as <a href="#get_random_bytes"><code>get-random-bytes</code></a>,
208-
represented as a <code>u64</code>.</p>
209-
<h5>Return values</h5>
210-
<ul>
211-
<li><a name="get_random_u64.0"></a> <code>u64</code></li>
212-
</ul>
213-
<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>
214-
<hr />
215-
<h3>Types</h3>
216-
<h4><a name="error"><code>resource error</code></a></h4>
217-
<hr />
218-
<h3>Functions</h3>
219-
<h4><a name="method_error.to_debug_string"><code>[method]error.to-debug-string: func</code></a></h4>
220-
<p>Returns a string that is suitable to assist humans in debugging
221-
this error.</p>
222-
<p>WARNING: The returned string should not be consumed mechanically!
223-
It may change across platforms, hosts, or other implementation
224-
details. Parsing this string is a major platform-compatibility
225-
hazard.</p>
226-
<h5>Params</h5>
227-
<ul>
228-
<li><a name="method_error.to_debug_string.self"><code>self</code></a>: borrow&lt;<a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
229-
</ul>
230-
<h5>Return values</h5>
231-
<ul>
232-
<li><a name="method_error.to_debug_string.0"></a> <code>string</code></li>
233-
</ul>
234132
<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>
235133
<p>WASI I/O is an I/O abstraction API which is currently focused on providing
236134
stream types.</p>
@@ -573,6 +471,67 @@ is ready for reading, before performing the <code>splice</code>.</p>
573471
<ul>
574472
<li><a name="get_stdin.0"></a> own&lt;<a href="#input_stream"><a href="#input_stream"><code>input-stream</code></a></a>&gt;</li>
575473
</ul>
474+
<h2><a name="wasi:clocks_monotonic_clock_0.2.0_rc_2023_11_10">Import interface wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10</a></h2>
475+
<p>WASI Monotonic Clock is a clock API intended to let users measure elapsed
476+
time.</p>
477+
<p>It is intended to be portable at least between Unix-family platforms and
478+
Windows.</p>
479+
<p>A monotonic clock is a clock which has an unspecified initial value, and
480+
successive reads of the clock will produce non-decreasing values.</p>
481+
<p>It is intended for measuring elapsed time.</p>
482+
<hr />
483+
<h3>Types</h3>
484+
<h4><a name="pollable"><code>type pollable</code></a></h4>
485+
<p><a href="#pollable"><a href="#pollable"><code>pollable</code></a></a></p>
486+
<p>
487+
#### <a name="instant">`type instant`</a>
488+
`u64`
489+
<p>An instant in time, in nanoseconds. An instant is relative to an
490+
unspecified initial value, and can only be compared to instances from
491+
the same monotonic-clock.
492+
<h4><a name="duration"><code>type duration</code></a></h4>
493+
<p><code>u64</code></p>
494+
<p>A duration of time, in nanoseconds.
495+
<hr />
496+
<h3>Functions</h3>
497+
<h4><a name="now"><code>now: func</code></a></h4>
498+
<p>Read the current value of the clock.</p>
499+
<p>The clock is monotonic, therefore calling this function repeatedly will
500+
produce a sequence of non-decreasing values.</p>
501+
<h5>Return values</h5>
502+
<ul>
503+
<li><a name="now.0"></a> <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
504+
</ul>
505+
<h4><a name="resolution"><code>resolution: func</code></a></h4>
506+
<p>Query the resolution of the clock. Returns the duration of time
507+
corresponding to a clock tick.</p>
508+
<h5>Return values</h5>
509+
<ul>
510+
<li><a name="resolution.0"></a> <a href="#duration"><a href="#duration"><code>duration</code></a></a></li>
511+
</ul>
512+
<h4><a name="subscribe_instant"><code>subscribe-instant: func</code></a></h4>
513+
<p>Create a <a href="#pollable"><code>pollable</code></a> which will resolve once the specified instant
514+
occured.</p>
515+
<h5>Params</h5>
516+
<ul>
517+
<li><a name="subscribe_instant.when"><code>when</code></a>: <a href="#instant"><a href="#instant"><code>instant</code></a></a></li>
518+
</ul>
519+
<h5>Return values</h5>
520+
<ul>
521+
<li><a name="subscribe_instant.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
522+
</ul>
523+
<h4><a name="subscribe_duration"><code>subscribe-duration: func</code></a></h4>
524+
<p>Create a <a href="#pollable"><code>pollable</code></a> which will resolve once the given duration has
525+
elapsed, starting at the time at which this function was called.
526+
occured.</p>
527+
<h5>Params</h5>
528+
<ul>
529+
<li><a name="subscribe_duration.when"><code>when</code></a>: <a href="#duration"><a href="#duration"><code>duration</code></a></a></li>
530+
</ul>
531+
<h5>Return values</h5>
532+
<ul>
533+
<li><a name="subscribe_duration.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
534+
</ul>
576535
<h2><a name="wasi:http_types_0.2.0_rc_2023_11_10">Import interface wasi:http/types@0.2.0-rc-2023-11-10</a></h2>
577536
<p>This interface defines all of the types and methods for implementing
578537
HTTP Requests and Responses, both incoming and outgoing, as well as
@@ -1431,6 +1390,47 @@ through the <a href="#future_incoming_response"><code>future-incoming-response</
14311390
<ul>
14321391
<li><a name="handle.0"></a> result&lt;own&lt;<a href="#future_incoming_response"><a href="#future_incoming_response"><code>future-incoming-response</code></a></a>&gt;, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
14331392
</ul>
1393+
<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>
1394+
<p>WASI Wall Clock is a clock API intended to let users query the current
1395+
time. The name &quot;wall&quot; makes an analogy to a &quot;clock on the wall&quot;, which
1396+
is not necessarily monotonic as it may be reset.</p>
1397+
<p>It is intended to be portable at least between Unix-family platforms and
1398+
Windows.</p>
1399+
<p>A wall clock is a clock which measures the date and time according to
1400+
some external reference.</p>
1401+
<p>External references may be reset, so this clock is not necessarily
1402+
monotonic, making it unsuitable for measuring elapsed time.</p>
1403+
<p>It is intended for reporting the current date and time for humans.</p>
1404+
<hr />
1405+
<h3>Types</h3>
1406+
<h4><a name="datetime"><code>record datetime</code></a></h4>
1407+
<p>A time and date in seconds plus nanoseconds.</p>
1408+
<h5>Record Fields</h5>
1409+
<ul>
1410+
<li><a name="datetime.seconds"><code>seconds</code></a>: <code>u64</code></li>
1411+
<li><a name="datetime.nanoseconds"><code>nanoseconds</code></a>: <code>u32</code></li>
1412+
</ul>
1413+
<hr />
1414+
<h3>Functions</h3>
1415+
<h4><a name="now"><code>now: func</code></a></h4>
1416+
<p>Read the current value of the clock.</p>
1417+
<p>This clock is not monotonic, therefore calling this function repeatedly
1418+
will not necessarily produce a sequence of non-decreasing values.</p>
1419+
<p>The returned timestamps represent the number of seconds since
1420+
1970-01-01T00:00:00Z, also known as <a href="https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16">POSIX's Seconds Since the Epoch</a>,
1421+
also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</p>
1422+
<p>The nanoseconds field of the output is always less than 1000000000.</p>
1423+
<h5>Return values</h5>
1424+
<ul>
1425+
<li><a name="now.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
1426+
</ul>
1427+
<h4><a name="resolution"><code>resolution: func</code></a></h4>
1428+
<p>Query the resolution of the clock.</p>
1429+
<p>The nanoseconds field of the output is always less than 1000000000.</p>
1430+
<h5>Return values</h5>
1431+
<ul>
1432+
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
1433+
</ul>
14341434
<h2><a name="wasi:http_incoming_handler_0.2.0_rc_2023_11_10">Export interface wasi:http/incoming-handler@0.2.0-rc-2023-11-10</a></h2>
14351435
<hr />
14361436
<h3>Types</h3>

wit/proxy.wit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ package wasi:http@0.2.0-rc-2023-11-10;
66
/// outgoing HTTP requests.
77
world proxy {
88
/// HTTP proxies have access to time and randomness.
9-
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
10-
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
9+
include wasi:clocks/imports@0.2.0-rc-2023-11-10;
1110
import wasi:random/random@0.2.0-rc-2023-11-10;
1211

1312
/// Proxies have standard output and error streams which are expected to

0 commit comments

Comments
 (0)