mod inbound_externs;
mod method_impls;
mod options_fields;
mod wrappers;
use crate::backends::swift::gen_rust_crate::type_bridge::{needs_json_bridge, swift_bridge_rust_type};
use crate::core::config::TraitBridgeConfig;
use crate::core::ir::TypeRef;
pub(crate) use inbound_externs::{emit_extern_block_for_inbound, emit_extern_block_for_inbound_registration};
pub(crate) use options_fields::{
emit_options_field_factory, emit_options_field_from_impls, emit_options_field_options_helper,
};
pub(crate) use wrappers::{emit_inbound_wrapper, emit_plugin_error_helper};
pub(super) fn inbound_bridge_type(ty: &TypeRef) -> String {
if needs_inbound_json_bridge(ty) {
return "String".to_string();
}
match ty {
TypeRef::Vec(inner) => format!("Vec<{}>", inbound_bridge_type(inner)),
_ => swift_bridge_rust_type(ty),
}
}
pub(super) fn needs_inbound_json_bridge(ty: &TypeRef) -> bool {
if needs_json_bridge(ty) {
return true;
}
matches!(ty, TypeRef::Named(_))
}
pub(super) fn has_plugin_super(bridge_config: &TraitBridgeConfig) -> bool {
bridge_config
.super_trait
.as_deref()
.map(|s| s == "Plugin" || s.ends_with("::Plugin"))
.unwrap_or(false)
}