Stream: wasi

Topic: Composing components


view this post on Zulip Timothy McCallum (Mar 29 2025 at 00:37):

Hi,
I am looking for an exemplary example of how to create and compose Wasm components.

WASI

WASIp3
I see that WASIp3 is in progress. I assume that using WASIp3 for the example would be ideal. However, WASIp3 may not be ready to create an example of composing components. Can I get some advice here, please?

WASIp2
When I have tried to write an example of how to create and compose Wasm components using cargo component I have hit an issue. Specifically, the issue that cargo-component doesn't yet work with the WASIp2 target < https://github.com/bytecodealliance/cargo-component/issues/364#issuecomment-2575877508 >

WASIp1
The official Rust Wasm component model documentation < https://component-model.bytecodealliance.org/language-support/rust.html > uses WASIp1 exclusively.

Is there a timeline for when the cargo component crate will support WASIp2?
Is it possible that the cargo component crate will just skip straight to WASIp3 (because of potential double handling)?
Is there any indication of a timeline/timeframe where I could create an example of using Wasm components using the WASIp3 target in production?

Thanks
Tim McCallum

I use .cargo/config.toml to control the compilation of workspace. # .cargo/config.toml [build] target = "wasm32-wasip2" But cargo component build still generates wasm32-wasip1 cargo-component-compo...

view this post on Zulip Timothy McCallum (Mar 30 2025 at 00:48):

I have started a GitHub repo with what I think is currently a suitable example (using wasip1):

https://github.com/tpmccallum/composing-wasm-components/tree/main/geolocation

If I follow the README.md's instructions I get the following error:

error: failed to create a target world for package `dms-converter` (/Users/tpmccallum/composing-wasm-components/geolocation/dms-converter/Cargo.toml)

Caused by:
    0: failed to parse local target from directory `/Users/tpmccallum/composing-wasm-components/geolocation/dms-converter/wit`
    1: expected ')', found ':'
            --> /Users/tpmccallum/composing-wasm-components/geolocation/dms-converter/wit/world.wit:14:42
             |
          14 |     convert-to-dms: func(normalized: docs:normalizer/normalize/normalized-coordinates) -> dms-coordinates;
An example of composing wasm components. Contribute to tpmccallum/composing-wasm-components development by creating an account on GitHub.
An example of composing wasm components. Contribute to tpmccallum/composing-wasm-components development by creating an account on GitHub.

view this post on Zulip Victor Adossi (Mar 31 2025 at 17:12):

Hey @Timothy McCallum sorry I'm a bit late here, but it looks like there is a syntax error in the WIT there

view this post on Zulip Victor Adossi (Mar 31 2025 at 17:15):

This line:

    convert-to-dms: func(normalized: docs:normalizer/normalize/normalized-coordinates) -> dms-coordinates;

Should look like this:

    convert-to-dms: func(normalized: normalized-coordinates) -> dms-coordinates;

And earlier in the interface, you'll need to import that type:

interface convert {
    use docs:normalizer/normalize.{normalized-coordinates};
    // ... rest ...
}
An example of composing wasm components. Contribute to tpmccallum/composing-wasm-components development by creating an account on GitHub.

view this post on Zulip Timothy McCallum (Apr 04 2025 at 00:11):

Hey @Victor Adossi
Thank you so much. Sorry about the late reply. I have been beavering away on the --invoke implementation. I appreciate your response and am back composing components again.
Thanks again
Tim

view this post on Zulip Victor Adossi (Apr 04 2025 at 00:51):

Absolutely no problem Tim!


Last updated: Apr 08 2025 at 18:03 UTC