Skip to main content

Module shared

Module shared 

Source

Functions§

binding_fields
Fields that should be emitted in generated binding structs.
can_auto_delegate
Check if all params and return type are delegatable. For opaque types, skip methods with RefMut receiver (cannot borrow Arc mutably).
can_auto_delegate_function
Check if a free function can be auto-delegated to the core crate. Opaque Named params are allowed (unwrapped via Arc). Non-opaque Named params are not (require From impls that may not exist for types with sanitized fields).
can_auto_delegate_with_named_let_bindings
Like can_auto_delegate but permits non-opaque Named &T params (and &[T] / &[&str] slices), because the caller emits owned _core let-bindings and passes a borrow of them.
config_constructor_parts
config_constructor_parts_with_options
Generate constructor parameter and assignment lists for types with has_default. All fields become Option<T> with None defaults for optional fields, or unwrap_or_else with actual defaults for required fields.
config_constructor_parts_with_options_cfg
config_constructor_parts_with_renames
Like config_constructor_parts_with_options but with field renames for keyword escaping.
config_constructor_parts_with_renames_and_cfg_restore
Like config_constructor_parts_with_renames but includes assignments for cfg-gated fields force-restored via never_skip_cfg_field_names (emitted as field: Default::default()).
constructor_parts
Build a constructor parameter list string. Returns (param_list, signature_with_defaults, field_assignments). If param_list exceeds 100 chars, uses multiline format with trailing commas.
constructor_parts_with_renames
Like constructor_parts but with optional field renames for keyword escaping. field_renames maps original field name → binding field name (e.g. “class” → “class_”). Parameters keep the original name (valid in Rust), struct literal uses the renamed field.
constructor_parts_with_renames_and_cfg_restore
Like constructor_parts_with_renames but also includes assignments for cfg-gated fields that have been force-restored via trait-bridge bind_via = "options_field". Such fields are absent from the constructor parameter list but must be present in the Self { ... } struct literal — emitted as field: Default::default() so the binding struct compiles.
float_literal_digits
The digits of a DefaultValue::FloatLiteral as a floating-point literal, or None when the value has no literal form at all.
format_crate_attributes
Format per-crate crate_attributes config entries for splicing into a generated crate’s lib.rs, one inner attribute per entry, in configured order.
format_default_value
format_extra_clippy_allows
Format extra clippy allows for insertion into generated Rust binding files.
function_params
Build a function parameter list.
function_params_vec
Per-parameter name: type strings, before joining. Callers that render the signature across multiple lines (long-signature wrapping) must reuse this exact list rather than recomputing types — a separate recomputation diverges from the backend-aware mapping used for the single-line form (e.g. extendr’s Nullable<&T>), producing a signature whose types disagree with the generated body and fail to compile.
function_sig_defaults
Build a function signature defaults string (for pyo3 signature etc.).
is_delegatable_param
A param type is delegatable if it’s simple, or a Named type (opaque → Arc unwrap, non-opaque → .into()).
is_delegatable_return
Return types are more permissive — Named types work via .into() (core→binding From exists).
is_delegatable_type
A type is delegatable if it can cross the binding boundary without From impls. Named types are NOT delegatable as function params (may lack From impls). For opaque methods, Named types are handled separately via Arc wrap/unwrap.
is_named_ref_param_pub
A Named param with is_ref=true needs a let-binding (can’t inline .into() + borrow). A Vec<String> param with is_ref=true needs conversion to Vec<&str>. A Vec<NonOpaqueNamed> param with is_ref=true needs a let-binding (gen_php_call_args emits &{name}_core[..] which is only valid when a let binding for {name}_core exists). Public alias for use by backend-specific codegen (e.g. napi types.rs opaque delegate check).
is_opaque_delegatable_type
Check if a type is delegatable in the opaque method context. Opaque methods can handle Named params via Arc unwrap and Named returns via Arc wrap.
is_promoted_optional
Returns true if this parameter is required but must be promoted to optional because it follows an optional parameter in the list. PyO3 requires that required params come before all optional params.
is_simple_type
Check if a type is “simple” — can be passed without any conversion.
maps_to_js_value
True when a backend’s type mapper rendered this binding-side type as wasm-bindgen’s opaque JsValue.
partition_methods
Partition methods into (instance, static).
substitute_excluded_types
Recursively replace Named(n) references where n is excluded from the binding’s public surface (e.g. InternalDocument) with TypeRef::Json. An excluded type is never emitted as a binding declaration, so a trait-bridge interface/stub method referencing it would be an undefined name; the runtime bridge marshals such values as JSON, so Json is the faithful stand-in. Shared by the go/pyo3/napi/magnus excluded-type handling so the substitution stays identical across them.
substitute_trait_interfaces
Recursively replace Named(n) references where n is a trait exposed via a host-implementable RBS/language interface (e.g. DocumentExtractor) with TypeRef::Named("_{n}"). Traits are never emitted as a class/struct declaration themselves — the trait-bridge backend surfaces them as an interface _TraitName (or the target language’s equivalent) that host code implements, so a signature referencing the bare trait name would be an undeclared type. Shared so the substitution stays identical across generators that need it (currently Ruby/Magnus RBS stubs).