-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo-component cannot find exported function in a world #360
Comments
Worlds aren't things you can select individual things from to import/export, because world items already have committed to being import or export. You can include the entire contents of one world into another though, like this: world host {
include component:adder/adder;
} Or, you can put the function in an interface, as you figured out. What WIT doesn't have right now is the ability to have a bare top-level function, which might look like this: package component:adder;
add: func(a: s32, b: s32) -> s32; that you could then import or export from a world. |
Thanks! Are there any ongoing proposals for top-level functions?
I wanted to compose two components, plug an |
I'm not aware of any currently.
Could you describe this in more detail? Including a WIT world is as you say, but this is often what one wants, when combining two worlds. |
And were you able to make this work? This should work with the wit you provided that uses the |
I am following https://component-model.bytecodealliance.org/language-support/rust.html#importing-an-interface-into-a-command-component to create a command component with
cargo-component
.My adder WIT was:
And my WIT for the host is
I also added this to
Cargo.toml
But when I ran
cargo component build
, I gotThis took me a while to debug, but in the end, I had to write my adder WIT like:
So it has
add
interface exported, which has anadd
function.I don't think the behavior of
cargo-component
is expected, as in a WIT file, a world can just simply export a function.The text was updated successfully, but these errors were encountered: