Stream: wasmtime

Topic: ✔ import has wrong type in component


view this post on Zulip i509VCB (Oct 06 2023 at 17:46):

I get the following error when trying to load a component.

Error: import `aerugo:wm/types` has the wrong type

Caused by:
    0: instance export `toplevel` has the wrong type
    1: expected resource found nothing

However I see there is a pre_instantiate and add_to_linker function. I'm guessing these need to be used given I only call instantiate at hte moment:

        tracing::trace!("Creating component");
        let component = wasmtime::component::Component::new(&engine, bytes)?;
        let linker = Linker::new(&engine);

        // TODO: Tune the fuel amount
        store.add_fuel(10000).unwrap();

        tracing::trace!("Instantiate component");
        let (aerugo_wm, instance) = host::AerugoWm::instantiate(&mut store, &component, &linker)?;

view this post on Zulip Alex Crichton (Oct 06 2023 at 17:47):

You'll need to use generated add_to_linker functions to insert the imports into the Linker you create there

view this post on Zulip i509VCB (Oct 06 2023 at 17:53):

Yep the add_to_linker and pre_instantiate seem to get past there

view this post on Zulip i509VCB (Oct 06 2023 at 17:56):

Hmm new question then: I seem to get errors on exports.instance()?

        let mut export_wm = exports.instance("wm-types").expect("Handle missing wm export");
        let funcs = WmTypes::new(&mut export_wm)?;

view this post on Zulip i509VCB (Oct 06 2023 at 17:57):

The world has this:

world aerugo-wm {
    export wm-types
}

view this post on Zulip i509VCB (Oct 06 2023 at 18:00):

Hmm use .root() I guess

view this post on Zulip Notification Bot (Oct 06 2023 at 18:09):

i509VCB has marked this topic as resolved.


Last updated: Nov 22 2024 at 17:03 UTC