rvolosatovs opened issue #7714:
Feature
With #7688 implemented it is now possible to take
Resource<T>toResourceAny, however it does not work for resources provided bywasmtime_wasicrate, since theResourceImportIndexis not exposed to the developer of those resources.
This is particularly important for dynamically-defined functions defined viaLinker::func_new, which operates onwasmtime::Valdirectly. For example, it is currently not possible to return awasi:io/poll/pollableresource from such a function without defining a customwasi:io/poll/pollableimplementation in the linker to acquire the import index to pass totry_into_resource_anyin order to convert it toResourceAnyBenefit
This allows dymanically-typed function definitions to operate on resources provided by WASI, i.e. it removes the need for developers using dynamically-typed functions utilizing WASI resources from reimplementing (parts of) WASI
Implementation
Since lookups by string import paths were considered too slow for #7688, it appears that the only alternative would be adapting
wit-bindgen(e.g https://github.com/bytecodealliance/wasmtime/blob/61e1cdff5a90461ab8de471e100de5b824e079d1/crates/wit-bindgen/src/lib.rs#L810) to capture the indexes returned byLinkerInstance::resourcecalls in a table of some sorts returned byadd_to_linker, if we still want to avoid the string lookups, that could be a nestedstructtype, where an index lookup could look something like this:let idx = resource_definitions.wasi.io.poll.pollableAlternatives
Allow string lookups for the
RuntimeImportIndexas an alternative to theResourceImportIndexcomputed atLinkerInstance::resource
rvolosatovs edited issue #7714:
Feature
With #7688 implemented it is now possible to take
Resource<T>toResourceAny, however the conversion does not work for resources provided bywasmtime_wasicrate, since theResourceImportIndexis not exposed to the developer of those resources.This is particularly important for dynamically-defined functions defined via
Linker::func_new, which operates onwasmtime::Valdirectly. For example, it is currently not possible to return awasi:io/poll/pollableresource from such a function without defining a customwasi:io/poll/pollableimplementation in the linker to acquire the import index to pass totry_into_resource_anyin order to convert it toResourceAnyBenefit
This allows dymanically-typed function definitions to operate on resources provided by WASI, i.e. it removes the need for developers using dynamically-typed functions utilizing WASI resources from reimplementing (parts of) WASI
Implementation
Since lookups by string import paths were considered too slow for #7688, it appears that the only alternative would be adapting
wit-bindgen(e.g https://github.com/bytecodealliance/wasmtime/blob/61e1cdff5a90461ab8de471e100de5b824e079d1/crates/wit-bindgen/src/lib.rs#L810) to capture the indexes returned byLinkerInstance::resourcecalls in a table of some sorts returned byadd_to_linker, if we still want to avoid the string lookups, that could be a nestedstructtype, where an index lookup could look something like this:let idx = resource_definitions.wasi.io.poll.pollableAlternatives
Allow string lookups for the
RuntimeImportIndexas an alternative to theResourceImportIndexcomputed atLinkerInstance::resource
rvolosatovs edited issue #7714:
Feature
With #7688 implemented it is now possible to take
Resource<T>toResourceAny, however the conversion does not work for resources provided bywasmtime_wasicrate, since theResourceImportIndexis not exposed to the developer of those resources.This is particularly important for dynamically-defined functions defined via
Linker::func_new, which operate onwasmtime::Valdirectly. For example, it is currently not possible to return awasi:io/poll/pollableresource from such a function without defining a customwasi:io/poll/pollableimplementation in the linker to acquire the import index to pass totry_into_resource_anyin order to convert it toResourceAnyBenefit
This allows dymanically-typed function definitions to operate on resources provided by WASI, i.e. it removes the need for developers using dynamically-typed functions utilizing WASI resources from reimplementing (parts of) WASI
Implementation
Since lookups by string import paths were considered too slow for #7688, it appears that the only alternative would be adapting
wit-bindgen(e.g https://github.com/bytecodealliance/wasmtime/blob/61e1cdff5a90461ab8de471e100de5b824e079d1/crates/wit-bindgen/src/lib.rs#L810) to capture the indexes returned byLinkerInstance::resourcecalls in a table of some sorts returned byadd_to_linker, if we still want to avoid the string lookups, that could be a nestedstructtype, where an index lookup could look something like this:let idx = resource_definitions.wasi.io.poll.pollableAlternatives
Allow string lookups for the
RuntimeImportIndexas an alternative to theResourceImportIndexcomputed atLinkerInstance::resource
rvolosatovs edited issue #7714:
Feature
With #7688 implemented it is now possible to take
Resource<T>toResourceAny, however the conversion does not work for resources provided bywasmtime_wasicrate, since theResourceImportIndexis not exposed to the developer for those resources.This is particularly important for dynamically-defined functions defined via
Linker::func_new, which operate onwasmtime::Valdirectly. For example, it is currently not possible to return awasi:io/poll/pollableresource from such a function without defining a customwasi:io/poll/pollableimplementation in the linker to acquire the import index to pass totry_into_resource_anyin order to convert it toResourceAnyBenefit
This allows dymanically-typed function definitions to operate on resources provided by WASI, i.e. it removes the need for developers using dynamically-typed functions utilizing WASI resources from reimplementing (parts of) WASI
Implementation
Since lookups by string import paths were considered too slow for #7688, it appears that the only alternative would be adapting
wit-bindgen(e.g https://github.com/bytecodealliance/wasmtime/blob/61e1cdff5a90461ab8de471e100de5b824e079d1/crates/wit-bindgen/src/lib.rs#L810) to capture the indexes returned byLinkerInstance::resourcecalls in a table of some sorts returned byadd_to_linker, if we still want to avoid the string lookups, that could be a nestedstructtype, where an index lookup could look something like this:let idx = resource_definitions.wasi.io.poll.pollableAlternatives
Allow string lookups for the
RuntimeImportIndexas an alternative to theResourceImportIndexcomputed atLinkerInstance::resource
alexcrichton commented on issue #7714:
I like the idea of the generated
add_to_linkerfunction returning a typed structure with*Indexitems inside of it myself. That seems like a nicely declarative route of communicating the result of all theadd_to_linkercalls.
alexcrichton closed issue #7714:
Feature
With #7688 implemented it is now possible to take
Resource<T>toResourceAny, however the conversion does not work for resources provided bywasmtime_wasicrate, since theResourceImportIndexis not exposed to the developer for those resources.This is particularly important for dynamically-defined functions defined via
Linker::func_new, which operate onwasmtime::Valdirectly. For example, it is currently not possible to return awasi:io/poll/pollableresource from such a function without defining a customwasi:io/poll/pollableimplementation in the linker to acquire the import index to pass totry_into_resource_anyin order to convert it toResourceAnyBenefit
This allows dymanically-typed function definitions to operate on resources provided by WASI, i.e. it removes the need for developers using dynamically-typed functions utilizing WASI resources from reimplementing (parts of) WASI
Implementation
Since lookups by string import paths were considered too slow for #7688, it appears that the only alternative would be adapting
wit-bindgen(e.g https://github.com/bytecodealliance/wasmtime/blob/61e1cdff5a90461ab8de471e100de5b824e079d1/crates/wit-bindgen/src/lib.rs#L810) to capture the indexes returned byLinkerInstance::resourcecalls in a table of some sorts returned byadd_to_linker, if we still want to avoid the string lookups, that could be a nestedstructtype, where an index lookup could look something like this:let idx = resource_definitions.wasi.io.poll.pollableAlternatives
Allow string lookups for the
RuntimeImportIndexas an alternative to theResourceImportIndexcomputed atLinkerInstance::resource
Last updated: Dec 13 2025 at 19:03 UTC