Skip to main content

TraitBridgeSpec

Struct TraitBridgeSpec 

Source
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 TypeDef

The trait definition from the IR.

§bridge_config: &'a TraitBridgeConfig

Bridge configuration from alef.toml.

§core_import: &'a str

Core crate import path (e.g., "kreuzberg").

§wrapper_prefix: &'a str

Language-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: String

The crate’s error type name (e.g., "KreuzbergError"). Defaults to "Error".

§error_constructor: String

Error constructor pattern. {msg} is replaced with the message expression.

Implementations§

Source§

impl<'a> TraitBridgeSpec<'a>

Source

pub fn error_path(&self) -> String

Fully qualified error type path (e.g., "kreuzberg::KreuzbergError").

Source

pub fn make_error(&self, msg_expr: &str) -> String

Generate an error construction expression from a message expression.

Source

pub fn wrapper_name(&self) -> String

Wrapper struct name: {prefix}{TraitName}Bridge (e.g., PythonOcrBackendBridge).

Source

pub fn trait_snake(&self) -> String

Snake-case version of the trait name (e.g., "ocr_backend").

Source

pub fn trait_path(&self) -> String

Full Rust path to the trait (e.g., kreuzberg::OcrBackend).

Source

pub fn required_methods(&self) -> Vec<&'a MethodDef>

Methods that are required (no default impl) — must be provided by the foreign object.

Source

pub fn optional_methods(&self) -> Vec<&'a MethodDef>

Methods that have a default impl — optional on the foreign object.

Auto Trait Implementations§

§

impl<'a> Freeze for TraitBridgeSpec<'a>

§

impl<'a> RefUnwindSafe for TraitBridgeSpec<'a>

§

impl<'a> Send for TraitBridgeSpec<'a>

§

impl<'a> Sync for TraitBridgeSpec<'a>

§

impl<'a> Unpin for TraitBridgeSpec<'a>

§

impl<'a> UnsafeUnpin for TraitBridgeSpec<'a>

§

impl<'a> UnwindSafe for TraitBridgeSpec<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.