Skip to content

Commit 7b5a971

Browse files
authored
Update wasi interfaces to 0.2.6 (#14)
Signed-off-by: Scott Andrews <scott@andrews.me>
1 parent 2d19374 commit 7b5a971

14 files changed

Lines changed: 141 additions & 72 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v6
1616
- uses: actions-rust-lang/setup-rust-toolchain@v1
17-
with:
18-
toolchain: 1.84.1
19-
components: rustfmt
20-
target: wasm32-unknown-unknown,wasm32-wasip2
2117
- name: Install cargo binstall
2218
uses: cargo-bins/cargo-binstall@main
2319
- name: Install cargo component
@@ -61,10 +57,6 @@ jobs:
6157
steps:
6258
- uses: actions/checkout@v6
6359
- uses: actions-rust-lang/setup-rust-toolchain@v1
64-
with:
65-
toolchain: 1.84.1
66-
components: rustfmt
67-
target: wasm32-unknown-unknown
6860
- name: Install cargo binstall
6961
uses: cargo-bins/cargo-binstall@main
7062
- name: Install wkg

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ components: $(foreach component,$(COMPONENTS),lib/$(component).wasm $(foreach co
2020
define BUILD_COMPONENT
2121

2222
lib/$1.wasm: Cargo.toml Cargo.lock wit/deps $(shell find components/$1 -type f)
23-
@$(eval TARGET := $(if $(findstring $1,keyvalue-to-filesystem),wasm32-wasip2,wasm32-unknown-unknown))
24-
cargo component build -p $1 --target $(TARGET) --release
25-
cp target/$(TARGET)/release/$(subst -,_,$1).wasm lib/$1.wasm
23+
cargo component build -p $1 --target wasm32-unknown-unknown --release
24+
cp target/wasm32-unknown-unknown/release/$(subst -,_,$1).wasm lib/$1.wasm
2625
cp components/$1/README.md lib/$1.wasm.md
2726

2827
lib/$1.debug.wasm: Cargo.toml Cargo.lock wit/deps $(shell find components/$1 -type f)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A collection of utility components that remix wasi:logging types and interfaces.
2020
## Build
2121

2222
Prereqs:
23-
- a rust toolchain with a recent nightly (`rustup toolchain install nightly`)
23+
- a rust toolchain
2424
- [`cargo component`](https://github.com/bytecodealliance/cargo-component)
2525
- [`wkg`](https://github.com/bytecodealliance/wasm-pkg-tools)
2626

components/levels/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ fn level_map(level: Level) -> logging::Level {
111111
wit_bindgen::generate!({
112112
path: "../../wit",
113113
world: "levels",
114+
features: ["clocks-timezone"],
114115
generate_all
115116
});
116117

components/to-stdout/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl Guest for LoggingToStdout {
4343
wit_bindgen::generate!({
4444
path: "../../wit",
4545
world: "to-stdout",
46+
features: ["clocks-timezone"],
4647
generate_all
4748
});
4849

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.91"
3+
targets = [ "wasm32-unknown-unknown", "wasm32-wasip2" ]
Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:cli@0.2.3;
1+
package wasi:cli@0.2.6;
22

33
@since(version = 0.2.0)
44
interface environment {
@@ -28,6 +28,17 @@ interface exit {
2828
/// Exit the current instance and any linked instances.
2929
@since(version = 0.2.0)
3030
exit: func(status: result);
31+
32+
/// Exit the current instance and any linked instances, reporting the
33+
/// specified status code to the host.
34+
///
35+
/// The meaning of the code depends on the context, with 0 usually meaning
36+
/// "success", and other values indicating various types of failure.
37+
///
38+
/// This function does not return; the effect is analogous to a trap, but
39+
/// without the connotation that something bad has happened.
40+
@unstable(feature = cli-exit-with-code)
41+
exit-with-code: func(status-code: u8);
3142
}
3243

3344
@since(version = 0.2.0)
@@ -40,7 +51,7 @@ interface run {
4051
@since(version = 0.2.0)
4152
interface stdin {
4253
@since(version = 0.2.0)
43-
use wasi:io/streams@0.2.3.{input-stream};
54+
use wasi:io/streams@0.2.6.{input-stream};
4455

4556
@since(version = 0.2.0)
4657
get-stdin: func() -> input-stream;
@@ -49,7 +60,7 @@ interface stdin {
4960
@since(version = 0.2.0)
5061
interface stdout {
5162
@since(version = 0.2.0)
52-
use wasi:io/streams@0.2.3.{output-stream};
63+
use wasi:io/streams@0.2.6.{output-stream};
5364

5465
@since(version = 0.2.0)
5566
get-stdout: func() -> output-stream;
@@ -58,7 +69,7 @@ interface stdout {
5869
@since(version = 0.2.0)
5970
interface stderr {
6071
@since(version = 0.2.0)
61-
use wasi:io/streams@0.2.3.{output-stream};
72+
use wasi:io/streams@0.2.6.{output-stream};
6273

6374
@since(version = 0.2.0)
6475
get-stderr: func() -> output-stream;
@@ -134,11 +145,11 @@ world imports {
134145
@since(version = 0.2.0)
135146
import exit;
136147
@since(version = 0.2.0)
137-
import wasi:io/error@0.2.3;
148+
import wasi:io/error@0.2.6;
138149
@since(version = 0.2.0)
139-
import wasi:io/poll@0.2.3;
150+
import wasi:io/poll@0.2.6;
140151
@since(version = 0.2.0)
141-
import wasi:io/streams@0.2.3;
152+
import wasi:io/streams@0.2.6;
142153
@since(version = 0.2.0)
143154
import stdin;
144155
@since(version = 0.2.0)
@@ -156,33 +167,35 @@ world imports {
156167
@since(version = 0.2.0)
157168
import terminal-stderr;
158169
@since(version = 0.2.0)
159-
import wasi:clocks/monotonic-clock@0.2.3;
170+
import wasi:clocks/monotonic-clock@0.2.6;
160171
@since(version = 0.2.0)
161-
import wasi:clocks/wall-clock@0.2.3;
172+
import wasi:clocks/wall-clock@0.2.6;
173+
@unstable(feature = clocks-timezone)
174+
import wasi:clocks/timezone@0.2.6;
162175
@since(version = 0.2.0)
163-
import wasi:filesystem/types@0.2.3;
176+
import wasi:filesystem/types@0.2.6;
164177
@since(version = 0.2.0)
165-
import wasi:filesystem/preopens@0.2.3;
178+
import wasi:filesystem/preopens@0.2.6;
166179
@since(version = 0.2.0)
167-
import wasi:sockets/network@0.2.3;
180+
import wasi:sockets/network@0.2.6;
168181
@since(version = 0.2.0)
169-
import wasi:sockets/instance-network@0.2.3;
182+
import wasi:sockets/instance-network@0.2.6;
170183
@since(version = 0.2.0)
171-
import wasi:sockets/udp@0.2.3;
184+
import wasi:sockets/udp@0.2.6;
172185
@since(version = 0.2.0)
173-
import wasi:sockets/udp-create-socket@0.2.3;
186+
import wasi:sockets/udp-create-socket@0.2.6;
174187
@since(version = 0.2.0)
175-
import wasi:sockets/tcp@0.2.3;
188+
import wasi:sockets/tcp@0.2.6;
176189
@since(version = 0.2.0)
177-
import wasi:sockets/tcp-create-socket@0.2.3;
190+
import wasi:sockets/tcp-create-socket@0.2.6;
178191
@since(version = 0.2.0)
179-
import wasi:sockets/ip-name-lookup@0.2.3;
192+
import wasi:sockets/ip-name-lookup@0.2.6;
180193
@since(version = 0.2.0)
181-
import wasi:random/random@0.2.3;
194+
import wasi:random/random@0.2.6;
182195
@since(version = 0.2.0)
183-
import wasi:random/insecure@0.2.3;
196+
import wasi:random/insecure@0.2.6;
184197
@since(version = 0.2.0)
185-
import wasi:random/insecure-seed@0.2.3;
198+
import wasi:random/insecure-seed@0.2.6;
186199
}
187200
@since(version = 0.2.0)
188201
world command {
@@ -191,11 +204,11 @@ world command {
191204
@since(version = 0.2.0)
192205
import exit;
193206
@since(version = 0.2.0)
194-
import wasi:io/error@0.2.3;
207+
import wasi:io/error@0.2.6;
195208
@since(version = 0.2.0)
196-
import wasi:io/poll@0.2.3;
209+
import wasi:io/poll@0.2.6;
197210
@since(version = 0.2.0)
198-
import wasi:io/streams@0.2.3;
211+
import wasi:io/streams@0.2.6;
199212
@since(version = 0.2.0)
200213
import stdin;
201214
@since(version = 0.2.0)
@@ -213,33 +226,35 @@ world command {
213226
@since(version = 0.2.0)
214227
import terminal-stderr;
215228
@since(version = 0.2.0)
216-
import wasi:clocks/monotonic-clock@0.2.3;
229+
import wasi:clocks/monotonic-clock@0.2.6;
217230
@since(version = 0.2.0)
218-
import wasi:clocks/wall-clock@0.2.3;
231+
import wasi:clocks/wall-clock@0.2.6;
232+
@unstable(feature = clocks-timezone)
233+
import wasi:clocks/timezone@0.2.6;
219234
@since(version = 0.2.0)
220-
import wasi:filesystem/types@0.2.3;
235+
import wasi:filesystem/types@0.2.6;
221236
@since(version = 0.2.0)
222-
import wasi:filesystem/preopens@0.2.3;
237+
import wasi:filesystem/preopens@0.2.6;
223238
@since(version = 0.2.0)
224-
import wasi:sockets/network@0.2.3;
239+
import wasi:sockets/network@0.2.6;
225240
@since(version = 0.2.0)
226-
import wasi:sockets/instance-network@0.2.3;
241+
import wasi:sockets/instance-network@0.2.6;
227242
@since(version = 0.2.0)
228-
import wasi:sockets/udp@0.2.3;
243+
import wasi:sockets/udp@0.2.6;
229244
@since(version = 0.2.0)
230-
import wasi:sockets/udp-create-socket@0.2.3;
245+
import wasi:sockets/udp-create-socket@0.2.6;
231246
@since(version = 0.2.0)
232-
import wasi:sockets/tcp@0.2.3;
247+
import wasi:sockets/tcp@0.2.6;
233248
@since(version = 0.2.0)
234-
import wasi:sockets/tcp-create-socket@0.2.3;
249+
import wasi:sockets/tcp-create-socket@0.2.6;
235250
@since(version = 0.2.0)
236-
import wasi:sockets/ip-name-lookup@0.2.3;
251+
import wasi:sockets/ip-name-lookup@0.2.6;
237252
@since(version = 0.2.0)
238-
import wasi:random/random@0.2.3;
253+
import wasi:random/random@0.2.6;
239254
@since(version = 0.2.0)
240-
import wasi:random/insecure@0.2.3;
255+
import wasi:random/insecure@0.2.6;
241256
@since(version = 0.2.0)
242-
import wasi:random/insecure-seed@0.2.3;
257+
import wasi:random/insecure-seed@0.2.6;
243258

244259
@since(version = 0.2.0)
245260
export run;
Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:clocks@0.2.3;
1+
package wasi:clocks@0.2.6;
22

33
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
44
/// time.
@@ -11,7 +11,7 @@ package wasi:clocks@0.2.3;
1111
@since(version = 0.2.0)
1212
interface monotonic-clock {
1313
@since(version = 0.2.0)
14-
use wasi:io/poll@0.2.3.{pollable};
14+
use wasi:io/poll@0.2.6.{pollable};
1515

1616
/// An instant in time, in nanoseconds. An instant is relative to an
1717
/// unspecified initial value, and can only be compared to instances from
@@ -92,12 +92,66 @@ interface wall-clock {
9292
resolution: func() -> datetime;
9393
}
9494

95+
@unstable(feature = clocks-timezone)
96+
interface timezone {
97+
@unstable(feature = clocks-timezone)
98+
use wall-clock.{datetime};
99+
100+
/// Information useful for displaying the timezone of a specific `datetime`.
101+
///
102+
/// This information may vary within a single `timezone` to reflect daylight
103+
/// saving time adjustments.
104+
@unstable(feature = clocks-timezone)
105+
record timezone-display {
106+
/// The number of seconds difference between UTC time and the local
107+
/// time of the timezone.
108+
///
109+
/// The returned value will always be less than 86400 which is the
110+
/// number of seconds in a day (24*60*60).
111+
///
112+
/// In implementations that do not expose an actual time zone, this
113+
/// should return 0.
114+
utc-offset: s32,
115+
/// The abbreviated name of the timezone to display to a user. The name
116+
/// `UTC` indicates Coordinated Universal Time. Otherwise, this should
117+
/// reference local standards for the name of the time zone.
118+
///
119+
/// In implementations that do not expose an actual time zone, this
120+
/// should be the string `UTC`.
121+
///
122+
/// In time zones that do not have an applicable name, a formatted
123+
/// representation of the UTC offset may be returned, such as `-04:00`.
124+
name: string,
125+
/// Whether daylight saving time is active.
126+
///
127+
/// In implementations that do not expose an actual time zone, this
128+
/// should return false.
129+
in-daylight-saving-time: bool,
130+
}
131+
132+
/// Return information needed to display the given `datetime`. This includes
133+
/// the UTC offset, the time zone name, and a flag indicating whether
134+
/// daylight saving time is active.
135+
///
136+
/// If the timezone cannot be determined for the given `datetime`, return a
137+
/// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
138+
/// saving time.
139+
@unstable(feature = clocks-timezone)
140+
display: func(when: datetime) -> timezone-display;
141+
142+
/// The same as `display`, but only return the UTC offset.
143+
@unstable(feature = clocks-timezone)
144+
utc-offset: func(when: datetime) -> s32;
145+
}
146+
95147
@since(version = 0.2.0)
96148
world imports {
97149
@since(version = 0.2.0)
98-
import wasi:io/poll@0.2.3;
150+
import wasi:io/poll@0.2.6;
99151
@since(version = 0.2.0)
100152
import monotonic-clock;
101153
@since(version = 0.2.0)
102154
import wall-clock;
155+
@unstable(feature = clocks-timezone)
156+
import timezone;
103157
}

wit/deps/wasi-filesystem-0.2.3/package.wit renamed to wit/deps/wasi-filesystem-0.2.6/package.wit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package wasi:filesystem@0.2.3;
1+
package wasi:filesystem@0.2.6;
22

33
interface types {
4-
use wasi:io/streams@0.2.3.{input-stream, output-stream, error};
5-
use wasi:clocks/wall-clock@0.2.3.{datetime};
4+
use wasi:io/streams@0.2.6.{input-stream, output-stream, error};
5+
use wasi:clocks/wall-clock@0.2.6.{datetime};
66

77
type filesize = u64;
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:io@0.2.3;
1+
package wasi:io@0.2.6;
22

33
interface poll {
44
resource pollable {

0 commit comments

Comments
 (0)