When I add interfaces to a wit definition, the export name includes a hashtag. For example:
interface erc20 {
record state {
name: option<string>,
symbol: option<string>,
balances: list<tuple<string, u64>>
}
construct: func(state: state, name: string, symbol: string)
mint: func(account: string, amount: u64)
transfer: func(to: string, amount: u64)
}
default world contract {
export exports: self.erc20
}
...generates a #[export_name = "exports#construct"]
. This compiles fine, but wasmtime cannot recognize the function name:
let function = instance .get_func(&mut store, "exports#construct");
...returns a None
. If I pull all the names of all exports out of the module, the function name "exports#construct" is in there. I know this is still very much in development, but am I doing anything obviously wrong?
Note that the hash there is a core wasm name mangling detail not present in the component itself. With a component you'd extract the instanced named "exports"
followed by the function called "construct"
from that instance
Thanks for the insight @Alex Crichton :pray:
For anyone following, I changed:
let function = instance.get_func(&mut store, "exports#construct")?;
to
let function = instance.exports(&mut store).instance("exports")?.func("construct")?;
Last updated: Nov 22 2024 at 16:03 UTC