Skip to content

Commit 903a9bc

Browse files
committed
feat: use wasm32-wasip2
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent f7288f1 commit 903a9bc

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ There are 2 different kinds of examples:
7070

7171
### Requirements
7272

73-
- For Rust components and wRPC applications: `rust` >= 1.78
74-
75-
`wasm32-wasip1` target will be used in examples, because it is currently available in stable Rust and also conveniently configured in [`rust-toolchain.toml`](./rust-toolchain.toml) in the root of this repository. `wrpc-wasmtime` will automatically componentize a Wasm module on instantiation.
76-
77-
[`wasm32-wasip2`](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip2.html) can be used instead, if desired.
73+
- For Rust components and wRPC applications: `rust` >= 1.82
7874

7975
- For [NATS.io] transport: `nats-server` >= 2.10.20 or [`docker`](https://www.docker.com/) >= 24.0.6 (or any other OCI runtime)
8076

@@ -95,18 +91,18 @@ We will have to build these components first:
9591
- Build Wasm `hello` client:
9692

9793
```sh
98-
cargo build --release -p hello-component-client --target wasm32-wasip1
94+
cargo build --release -p hello-component-client --target wasm32-wasip2
9995
```
10096

101-
> Output is in target/wasm32-wasip1/release/hello-component-client.wasm
97+
> Output is in target/wasm32-wasip2/release/hello-component-client.wasm
10298

10399
- Build Wasm `hello` server:
104100

105101
```sh
106-
cargo build --release -p hello-component-server --target wasm32-wasip1
102+
cargo build --release -p hello-component-server --target wasm32-wasip2
107103
```
108104

109-
> Output is in target/wasm32-wasip1/release/hello_component_server.wasm
105+
> Output is in target/wasm32-wasip2/release/hello_component_server.wasm
110106

111107
> NB: Rust uses `_` separators in the filename, because a component is built as a reactor-style library
112108

@@ -121,7 +117,7 @@ We will use the following two Rust wRPC applications using TCP transport:
121117
1. Serve Wasm `hello` server via TCP
122118

123119
```sh
124-
wrpc-wasmtime tcp serve ./target/wasm32-wasip1/release/hello_component_server.wasm
120+
wrpc-wasmtime tcp serve ./target/wasm32-wasip2/release/hello_component_server.wasm
125121
```
126122

127123
- Sample output:
@@ -130,7 +126,7 @@ We will use the following two Rust wRPC applications using TCP transport:
130126
3. Call Wasm `hello` server using a Wasm `hello` client via TCP:
131127

132128
```sh
133-
wrpc-wasmtime tcp run ./target/wasm32-wasip1/release/hello-component-client.wasm
129+
wrpc-wasmtime tcp run ./target/wasm32-wasip2/release/hello-component-client.wasm
134130
```
135131

136132
- Sample output in the client:
@@ -162,7 +158,7 @@ We will use the following two Rust wRPC applications using TCP transport:
162158
7. Call native wRPC `hello` server using Wasm `hello` client via TCP:
163159

164160
```sh
165-
wrpc-wasmtime tcp run --import [::1]:7762 ./target/wasm32-wasip1/release/hello-component-client.wasm
161+
wrpc-wasmtime tcp run --import [::1]:7762 ./target/wasm32-wasip2/release/hello-component-client.wasm
166162
```
167163

168164
#### Using [NATS.io] transport
@@ -186,7 +182,7 @@ We will use the following two Rust wRPC applications using [NATS.io] transport:
186182
2. Serve Wasm `hello` server via [NATS.io]
187183

188184
```sh
189-
wrpc-wasmtime nats serve --export rust ./target/wasm32-wasip1/release/hello_component_server.wasm
185+
wrpc-wasmtime nats serve --export rust ./target/wasm32-wasip2/release/hello_component_server.wasm
190186
```
191187

192188
- Sample output:
@@ -197,7 +193,7 @@ We will use the following two Rust wRPC applications using [NATS.io] transport:
197193
3. Call Wasm `hello` server using a Wasm `hello` client via [NATS.io]:
198194

199195
```sh
200-
wrpc-wasmtime nats run --import rust ./target/wasm32-wasip1/release/hello-component-client.wasm
196+
wrpc-wasmtime nats run --import rust ./target/wasm32-wasip2/release/hello-component-client.wasm
201197
```
202198

203199
- Sample output in the client:
@@ -231,7 +227,7 @@ We will use the following two Rust wRPC applications using [NATS.io] transport:
231227
7. Call native wRPC `hello` server using Wasm `hello` client via [NATS.io]:
232228

233229
```sh
234-
wrpc-wasmtime nats run --import native ./target/wasm32-wasip1/release/hello-component-client.wasm
230+
wrpc-wasmtime nats run --import native ./target/wasm32-wasip2/release/hello-component-client.wasm
235231
```
236232

237233
## Repository structure

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
targets.s390x-unknown-linux-gnu = false;
8181
targets.wasm32-unknown-unknown = false;
8282
targets.wasm32-wasip1 = false;
83+
targets.wasm32-wasip2 = false;
8384

8485
clippy.deny = ["warnings"];
8586
clippy.workspace = true;

rust-toolchain.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
channel = "stable"
33
components = ["clippy", "rust-src", "rustfmt"]
44
targets = [
5-
"wasm32-unknown-unknown",
6-
"wasm32-wasip1"
5+
"wasm32-wasip2"
76
]

0 commit comments

Comments
 (0)