pub struct TraitBridgeSpec<'a> {
pub trait_def: &'a TypeDef,
pub bridge_config: &'a TraitBridgeConfig,
pub core_import: &'a str,
pub wrapper_prefix: &'a str,
pub type_paths: HashMap<String, String>,
pub error_type: String,
pub error_constructor: String,
}Expand description
Everything needed to generate a trait bridge for one trait.
Fields§
§trait_def: &'a TypeDefThe trait definition from the IR.
bridge_config: &'a TraitBridgeConfigBridge configuration from alef.toml.
core_import: &'a strCore crate import path (e.g., "kreuzberg").
wrapper_prefix: &'a strLanguage-specific prefix for the wrapper type (e.g., "Python", "Js", "Wasm").
type_paths: HashMap<String, String>Map of type name → fully-qualified Rust path for qualifying Named types.
error_type: StringThe crate’s error type name (e.g., "KreuzbergError"). Defaults to "Error".
error_constructor: StringError constructor pattern. {msg} is replaced with the message expression.
Implementations§
Source§impl<'a> TraitBridgeSpec<'a>
impl<'a> TraitBridgeSpec<'a>
Sourcepub fn error_path(&self) -> String
pub fn error_path(&self) -> String
Fully qualified error type path (e.g., "kreuzberg::KreuzbergError").
Sourcepub fn make_error(&self, msg_expr: &str) -> String
pub fn make_error(&self, msg_expr: &str) -> String
Generate an error construction expression from a message expression.
Sourcepub fn wrapper_name(&self) -> String
pub fn wrapper_name(&self) -> String
Wrapper struct name: {prefix}{TraitName}Bridge (e.g., PythonOcrBackendBridge).
Sourcepub fn trait_snake(&self) -> String
pub fn trait_snake(&self) -> String
Snake-case version of the trait name (e.g., "ocr_backend").
Sourcepub fn trait_path(&self) -> String
pub fn trait_path(&self) -> String
Full Rust path to the trait (e.g., kreuzberg::OcrBackend).
Sourcepub fn required_methods(&self) -> Vec<&'a MethodDef>
pub fn required_methods(&self) -> Vec<&'a MethodDef>
Methods that are required (no default impl) — must be provided by the foreign object.
Sourcepub fn optional_methods(&self) -> Vec<&'a MethodDef>
pub fn optional_methods(&self) -> Vec<&'a MethodDef>
Methods that have a default impl — optional on the foreign object.