Skip to main content

Module trait_bridge

Module trait_bridge 

Source
Expand description

Shared trait bridge code generation.

Generates wrapper structs that allow foreign language objects (Python, JS, etc.) to implement Rust traits via FFI. Each backend implements TraitBridgeGenerator to provide language-specific dispatch logic; the shared functions in this module handle the structural boilerplate.

Structs§

TraitBridgeSpec
Everything needed to generate a trait bridge for one trait.

Traits§

TraitBridgeGenerator
Backend-specific trait bridge generation.

Functions§

gen_bridge_all
Generate the complete trait bridge code block: imports, struct, impls, and optionally a registration function.
gen_bridge_plugin_impl
Generate impl Plugin for Wrapper when the trait has Plugin as a super-trait.
gen_bridge_registration_fn
Generate the register_xxx() function that wraps a foreign object and inserts it into the plugin registry.
gen_bridge_trait_impl
Generate impl Trait for Wrapper dispatching each method through the generator.
gen_bridge_wrapper_struct
Generate the wrapper struct holding the foreign object and cached fields.