Skip to main content

ZigTraitBridgeGenerator

Struct ZigTraitBridgeGenerator 

Source
pub struct ZigTraitBridgeGenerator {
    pub prefix: String,
}
Expand description

Zig-specific TraitBridgeGenerator implementation.

Carries the FFI symbol prefix (e.g., "kreuzberg") used when deriving the C symbol for unregister_* and clear_* wrappers.

The required trait methods that produce Rust source (gen_sync_method_body, gen_async_method_body, gen_constructor, gen_registration_fn) return empty strings because Zig bridge code is produced by the standalone [emit_trait_bridge] free function, not the shared driver.

Fields§

§prefix: String

FFI symbol prefix (e.g., "kreuzberg").

Implementations§

Source§

impl ZigTraitBridgeGenerator

Source

pub fn new(prefix: impl Into<String>) -> Self

Construct a new generator for the given FFI symbol prefix.

Trait Implementations§

Source§

impl TraitBridgeGenerator for ZigTraitBridgeGenerator

Source§

fn gen_unregistration_fn(&self, spec: &TraitBridgeSpec<'_>) -> String

Emit a Zig wrapper that calls c.{prefix}_{unregister_fn}(name, out_error).

Returns an empty string when spec.bridge_config.unregister_fn is None.

Source§

fn gen_clear_fn(&self, spec: &TraitBridgeSpec<'_>) -> String

Emit a Zig wrapper that calls c.{prefix}_{clear_fn}(out_error).

Returns an empty string when spec.bridge_config.clear_fn is None.

Source§

fn foreign_object_type(&self) -> &str

The type of the wrapped foreign object (e.g., "Py<PyAny>", "ThreadsafeFunction").
Source§

fn bridge_imports(&self) -> Vec<String>

Additional use imports needed for the bridge code.
Source§

fn gen_sync_method_body( &self, _method: &MethodDef, _spec: &TraitBridgeSpec<'_>, ) -> String

Generate the body of a synchronous method bridge. Read more
Source§

fn gen_async_method_body( &self, _method: &MethodDef, _spec: &TraitBridgeSpec<'_>, ) -> String

Generate the body of an async method bridge. Read more
Source§

fn gen_constructor(&self, _spec: &TraitBridgeSpec<'_>) -> String

Generate the constructor body that validates and wraps the foreign object. Read more
Source§

fn gen_registration_fn(&self, _spec: &TraitBridgeSpec<'_>) -> String

Generate the complete registration function including attributes, signature, and body. Read more
Source§

fn async_trait_is_send(&self) -> bool

Whether the #[async_trait] macro should require Send on its futures. Read more

Auto Trait Implementations§

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.