Skip to main content

Module convert

Module convert 

Source
Expand description

Conversions between bindgen-generated WIT types and forge_ir.

Both ir-transformer and code-generator worlds share the types, host-api, and stage interfaces, but wasmtime::component::bindgen! emits separate Rust modules per world (the types are structurally identical, nominally distinct). To avoid duplicating ~600 lines of conversion glue, we expand the conversions once per world via a macro_rules! macro keyed on the bindings root module.

Public API:

  • convert::transformer::* — operates on crate::bindings::transformer::forge::plugin::types::*.
  • convert::generator::* — operates on crate::bindings::generator::forge::plugin::types::*.

Both submodules expose:

  • ir_to_wit(forge_ir::Ir) -> b::types::Ir
  • ir_from_wit(b::types::Ir) -> Result<forge_ir::Ir, BindgenError>
  • diagnostic_from_wit(b::types::Diagnostic) -> Result<forge_ir::Diagnostic, BindgenError>
  • plugin_info_from_wit(b::types::PluginInfo) -> forge_ir::PluginInfo
  • stage_error_from_wit(b::stage::StageError) -> StageErrorRepr

StageErrorRepr is a world-independent representation of the WIT stage-error variant; the host translates it to its own StageError type to avoid a circular dependency.

Modules§

generator
Conversions between forge_ir and the generator world’s WIT types.
transformer
Conversions between forge_ir and the transformer world’s WIT types.

Enums§

ResourceKindRepr
StageErrorRepr
Host-neutral representation of the WIT stage-error variant. Shared between both worlds; the host wraps it into its own StageError.