pub struct ConversionConfig<'a> {
pub type_name_prefix: &'a str,
pub cast_large_ints_to_i64: bool,
pub enum_string_names: Option<&'a AHashSet<String>>,
pub map_uses_jsvalue: bool,
pub cast_f32_to_f64: bool,
pub optionalize_defaults: bool,
pub json_to_string: bool,
pub include_cfg_metadata: bool,
pub option_duration_on_defaults: bool,
pub binding_enums_have_data: bool,
}Expand description
Backend-specific configuration for From/field conversion generation. Enables shared code to handle all backend differences via parameters.
Fields§
§type_name_prefix: &'a strPrefix for binding type names (“Js” for NAPI/WASM, “” for others).
cast_large_ints_to_i64: boolU64/Usize/Isize need as i64 casts (NAPI, PHP — JS/PHP lack native u64).
enum_string_names: Option<&'a AHashSet<String>>Enum names mapped to String in the binding layer (PHP only).
Named fields referencing these use format!("{:?}") in core→binding.
map_uses_jsvalue: boolMap types use JsValue in the binding layer (WASM only).
When true, Map fields use serde_wasm_bindgen for conversion instead of
iterator-based collect patterns (JsValue is not iterable).
cast_f32_to_f64: boolWhen true, f32 is mapped to f64 (NAPI only — JS has no f32).
optionalize_defaults: boolWhen true, non-optional fields on defaultable types are wrapped in Option.unwrap_or_default() in binding→core From.
Used by NAPI to make JS-facing structs fully optional.
json_to_string: boolWhen true, Json (serde_json::Value) fields are mapped to String in the binding layer.
Core→binding uses .to_string(), binding→core uses Default::default() (lossy).
Used by PHP where serde_json::Value can’t cross the extension boundary.
include_cfg_metadata: boolWhen true, add synthetic metadata field conversion for ConversionResult. Only NAPI backend sets this (it adds metadata field to the struct).
option_duration_on_defaults: boolWhen true, non-optional Duration fields on has_default types are stored as
Option<u64> in the binding struct. The From conversion uses the builder
pattern so that None falls back to the core type’s Default implementation
(giving the real default, e.g. Duration::from_secs(30)) instead of Duration::ZERO.
Used by PyO3 to prevent validation failures when request_timeout is unset.
binding_enums_have_data: boolWhen true, binding enums include data variant fields (Magnus). When false (default), binding enums are unit-only and data is lost in conversion.
Trait Implementations§
Source§impl<'a> Clone for ConversionConfig<'a>
impl<'a> Clone for ConversionConfig<'a>
Source§fn clone(&self) -> ConversionConfig<'a>
fn clone(&self) -> ConversionConfig<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more