pub struct PhpBridgeGenerator {
pub core_import: String,
pub type_paths: HashMap<String, String>,
pub error_type: String,
pub struct_param_types: HashSet<String>,
pub struct_return_types: HashSet<String>,
pub forwardable_defaulted: HashSet<String>,
}Expand description
PHP-specific trait bridge generator. Implements code generation for bridging PHP objects to Rust traits.
Fields§
§core_import: StringCore crate import path (e.g., "sample_core").
type_paths: HashMap<String, String>Map of type name → fully-qualified Rust path for type references.
error_type: StringError type name (e.g., "SampleCrateError").
struct_param_types: HashSet<String>Callback-param type names that get NATIVE-object marshalling — known serde structs per
the shared crate::codegen::generators::trait_bridge::is_native_marshalled_struct rule.
For such a param the bridge constructs the binding’s native PHP object (the #[php_class]
wrapper, via the same From<core::T> conversion used for return values) and hands THAT to
the PHP method as a Zval, instead of serializing the param to a JSON string. Enums,
opaque/handle types, and excluded/unknown Named params are absent and keep their prior
JSON-string representation.
struct_return_types: HashSet<String>Callback-RETURN type names that get NATIVE-object marshalling — known serde structs returned
directly by a method, gated to those with a generated From<Binding> for core conversion.
For such a return the bridge first extracts the host’s native #[php_class] object via
FromZval and converts via From<Binding>, falling back to the val.string() + serde path.
forwardable_defaulted: HashSet<String>Rust-defaulted trait methods the bridge forwards to the host when the PHP
object’s class defines them (per the shared forwardable_defaulted_method_names
rule). Methods absent here keep the trait’s Rust default unconditionally.
Trait Implementations§
Source§impl TraitBridgeGenerator for PhpBridgeGenerator
impl TraitBridgeGenerator for PhpBridgeGenerator
Source§fn gen_lifecycle_presence_check(
&self,
method: &MethodDef,
_spec: &TraitBridgeSpec<'_>,
) -> Option<String>
fn gen_lifecycle_presence_check( &self, method: &MethodDef, _spec: &TraitBridgeSpec<'_>, ) -> Option<String>
Plugin lifecycle method (initialize,
shutdown) synthesized by the super-trait impl. Read moreSource§fn gen_method_presence_check(
&self,
method: &MethodDef,
_spec: &TraitBridgeSpec<'_>,
) -> Option<String>
fn gen_method_presence_check( &self, method: &MethodDef, _spec: &TraitBridgeSpec<'_>, ) -> Option<String>
Source§fn foreign_object_type(&self) -> &str
fn foreign_object_type(&self) -> &str
"Py<PyAny>", "ThreadsafeFunction").Source§fn bridge_imports(&self) -> Vec<String>
fn bridge_imports(&self) -> Vec<String>
use imports needed for the bridge code.Source§fn gen_sync_method_body(
&self,
method: &MethodDef,
spec: &TraitBridgeSpec<'_>,
) -> String
fn gen_sync_method_body( &self, method: &MethodDef, spec: &TraitBridgeSpec<'_>, ) -> String
Source§fn gen_async_method_body(
&self,
method: &MethodDef,
spec: &TraitBridgeSpec<'_>,
) -> String
fn gen_async_method_body( &self, method: &MethodDef, spec: &TraitBridgeSpec<'_>, ) -> String
Source§fn gen_constructor(&self, spec: &TraitBridgeSpec<'_>) -> String
fn gen_constructor(&self, spec: &TraitBridgeSpec<'_>) -> String
Source§fn gen_unregistration_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
fn gen_unregistration_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
Source§fn gen_clear_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
fn gen_clear_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
Source§fn gen_registration_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
fn gen_registration_fn(&self, spec: &TraitBridgeSpec<'_>) -> String
Source§fn async_trait_is_send(&self) -> bool
fn async_trait_is_send(&self) -> bool
Source§fn extra_bridge_fields(
&self,
_spec: &TraitBridgeSpec<'_>,
) -> Vec<(String, String)>
fn extra_bridge_fields( &self, _spec: &TraitBridgeSpec<'_>, ) -> Vec<(String, String)>
(name, rust_type) pairs. Read moreAuto Trait Implementations§
impl Freeze for PhpBridgeGenerator
impl RefUnwindSafe for PhpBridgeGenerator
impl Send for PhpBridgeGenerator
impl Sync for PhpBridgeGenerator
impl Unpin for PhpBridgeGenerator
impl UnsafeUnpin for PhpBridgeGenerator
impl UnwindSafe for PhpBridgeGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more