I noticed when executing a component that has an import function, that the bindings use anyhow::Result
which the user might not have as a dependency. I was wondering if a fix for this would be welcome or if the bindgen!
macro is under so much development that I'd just be getting in the way.
ah yeah any anyhow
paths should be referenced through wasmtime::component::__internal::anyhow
, but it's likely one was missed! PRs more than welcome to fix that of course
@Alex Crichton unfortunately I think the issue is a bit more complex. The MyComponentImports
trait that bindgen!
creates needs to be referenced directly by the user. This means the user has to name the return type which is hardcoded to be anyhow::Result<T>
where T
is the return type of the import function. So I don't think there's really any easy fix - this is sort of by design...
oh true, did you have a particular fix in mind?
The only one that comes to mind is having those functions return Result<T, Box<dyn std::error::Error>>
and have the bindgen!
macro able to be configured to take some other error type... But that doesn't seem so nice
heh yeah anyhow
is intentional since it threads all the way into Wasmtime -- do you think we should perhaps publicly reexport anyhow
from wasmtime for consumption?
It seems you're comfortable with having anyhow be a part of the public API, so that would make sense I think
Perhaps a wasmtime::component::Result
?
yeah I think that'd be fine
we're tied at the hip to anyhow
now matter what
I think doing wasmtime::Result
is also fine
I can make a PR for that.
PR is up. https://github.com/bytecodealliance/wasmtime/pull/5853
I added a question on whether this is the right approach or we should be relying on the trappable_error_type
option.
Last updated: Dec 23 2024 at 14:03 UTC