Skip to content

Add a new method Linker::get_export(module,name). #1454

@aleksmelnikov

Description

@aleksmelnikov

Feature

I would like to change my code from:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = instance1.get_export("funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

to:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = linker.get_export("env","funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

Benefit

Get exports from one source (Linker).

Implementation

Add a new method Linker::get_export(module,name).

Alternatives

Please, see the existing solution above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmtime:apiRelated to the API of the `wasmtime` crate itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions