lann opened issue #13190:
There are cases where it would be helpful to have access to the component type associated with
bindgen!ed code, like allowing component type checking without separate WIT bookkeeping or the creation of an engine/component/linker/store to test instantiation.Guest
wit-bindgenembeds this information in thecomponent-typecustom section for use bywasm-component-ld; I'd like to do something similar for wasmtime bindgen, roughly:let encoded = wit_component::metadata::encode( resolve, world_id, wit_component::StringEncoding::UTF8, None, )?; uwriteln!(self.src, "pub const COMPONENT_TYPE: &[u8] = &{encoded:?};");If there is a compelling reason for it this could be gated by a bindgen opt but the
constwill disappear if it doesn't get used so I'm not sure if that is necessary.
lann edited issue #13190:
There are cases where it would be helpful to have access to the component type associated with
bindgen!ed code, like allowing component type checking without separate WIT bookkeeping or the creation of an engine/component/linker/store to test instantiation.Guest
wit-bindgenembeds this information in thecomponent-typecustom section for use bywasm-component-ld; I'd like to do something similar for wasmtime bindgen, roughly:let encoded = wit_component::metadata::encode( resolve, world_id, wit_component::StringEncoding::UTF8, None, )?; uwriteln!(self.src, "pub const COMPONENT_TYPE: &[u8] = &{encoded:?};");which would allow the host to reconstruct the component type:
let wit_component::metadata::Bindgen { resolve, world, .. } = wit_component::metadata::decode(generated::bindings::COMPONENT_TYPE)?;If there is a compelling reason for it this could be gated by a bindgen opt but the
constwill disappear if it doesn't get used so I'm not sure if that is necessary.
pchickey commented on issue #13190:
That seems harmless enough, I guess?
Is there a straightforward way to get a
wasmtime::component::types::Componentout of the bindgen at the moment?
lann commented on issue #13190:
Is there a straightforward way to get a
wasmtime::component::types::Componentout of the bindgen at the moment?I don't think so. IIRC the underlying data for that is constructed during validation.
alexcrichton added the wasm-proposal:component-model label to Issue #13190.
Last updated: May 03 2026 at 22:13 UTC