Skip to main content

host_function_path

Function host_function_path 

Source
pub fn host_function_path(spec: &TraitBridgeSpec<'_>, fn_name: &str) -> String
Expand description

Resolve the FQN of a host-crate plugin function (e.g. kreuzberg::plugins::ocr::unregister_ocr_backend) given the bridge’s registry_getter path. The convention used by host crates is:

  • registry_getter = "kreuzberg::plugins::registry::get_ocr_backend_registry"
  • top-level fn = kreuzberg::plugins::ocr::unregister_ocr_backend

We rewrite ::registry::get_*_registry to ::<sub>::<fn_name> where <sub> is the trait submodule name (extracted from _*_registry). When the heuristic fails (no registry_getter, unexpected shape), we fall back to {core_import}::plugins::{fn_name} so the user can rely on a re-export.

Shared by every backend that opts in to unregister_*/clear_* codegen (pyo3, napi, magnus, php, rustler, gleam, extendr, dart, swift, kotlin, wasm). Replaces the duplicated <lang>_host_function_path helpers that each backend used to define.