Skip to main content

generate_impl_vtable

Function generate_impl_vtable 

Source
pub(super) fn generate_impl_vtable(
    abi: &TraitAbiMetadata,
    concrete_type: &Type,
    trait_path: &Path,
    methods: &[TraitMethod],
    declaration: &[TraitItemFn],
) -> Result<TokenStream>
Expand description

Reproduce the declaration’s repr(C) layout locally, with its exact field order and callback types. The versioned declaration tag guards the cast to the consumer’s nominal vtable type. The exported static’s name and byte representation stay the same for native and wasm registration.

Non-generic callbacks belong to the trait, keeping default methods and declaration-local argument types in their original scope. Generic traits retain the existing concrete-shim path to avoid recursive conversion bounds.