@@ -321,56 +321,14 @@ The following section requires you to have [a Rust toolchain][rust] installed.
321
321
> (The ` wasmtime ` version is specified in [ the Cargo configuration file] [ cargo-config ]
322
322
> for the example host.)
323
323
324
- This repository contains an [ example WebAssembly host] [ example-host ] written in Rust
325
- that can run components that implement the ` adder ` world.
326
-
327
- 1 . ` git clone https://github.com/bytecodealliance/component-docs.git `
328
- 2 . ` cd component-docs/component-model/examples/example-host `
329
- 3 . ` cargo run --release -- 1 2 <PATH>/adder.wasm `
330
- * The double dashes separate the flags passed to ` cargo ` from
331
- the flags passed in to your code.
332
- * The arguments 1 and 2 are the arguments to the adder.
333
- * In place of ` <PATH> ` , substitute the directory that contains your
334
- generated ` adder.wasm ` file (or ` adder.component.wasm ` if you used
335
- the manual instructions).
336
-
337
- > [ !NOTE]
338
- > When hosts run components that use WASI interfaces, they must * explicitly*
339
- > [ add WASI to the linker] [ add-to-linker ] to run the built component.
324
+ {{#include example-host-part1.md}}
340
325
341
326
A successful run should show the following output
342
327
(of course, the paths to your example host and adder component will vary,
343
328
and you should substitute ` adder.wasm ` with ` adder.component.wasm `
344
329
if you followed the manual instructions above):
345
330
346
- ```
347
- cargo run --release -- 1 2 adder.wasm
348
- Compiling example-host v0.1.0 (/path/to/component-docs/component-model/examples/example-host)
349
- Finished `release` profile [optimized] target(s) in 7.85s
350
- Running `target/debug/example-host 1 2 /path/to/adder.wasm`
351
- 1 + 2 = 3
352
- ```
353
-
354
- If * not* configured correctly, you may see errors like the following:
355
-
356
- ```
357
- cargo run --release -- 1 2 adder.wasm
358
- Compiling example-host v0.1.0 (/path/to/component-docs/component-model/examples/example-host)
359
- Finished `release` profile [optimized] target(s) in 7.85s
360
- Running `target/release/example-host 1 2 /path/to/adder.component.wasm`
361
- Error: Failed to instantiate the example world
362
-
363
- Caused by:
364
- 0: component imports instance `wasi:io/[email protected] `, but a matching implementation was not found in the linker
365
- 1: instance export `error` has the wrong type
366
- 2: resource implementation is missing
367
- ```
368
-
369
- This kind of error normally indicates that the host in question does not satisfy WASI imports.
370
-
371
- [ host ] : https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host
372
- [ add-to-linker ] : https://docs.wasmtime.dev/api/wasmtime_wasi/p2/fn.add_to_linker_sync.html
373
- [ example-host ] : https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host
331
+ {{#include example-host-part2.md}}
374
332
375
333
## 7. Run the component from C/C++ Applications
376
334
0 commit comments