Skip to main content

ConversionConfig

Struct ConversionConfig 

Source
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,
    pub exclude_types: &'a [String],
}
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 str

Prefix for binding type names (“Js” for NAPI/WASM, “” for others).

§cast_large_ints_to_i64: bool

U64/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: bool

Map 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: bool

When true, f32 is mapped to f64 (NAPI only — JS has no f32).

§optionalize_defaults: bool

When true, non-optional fields on defaultable types are wrapped in Option in the binding struct and need .unwrap_or_default() in binding→core From. Used by NAPI to make JS-facing structs fully optional.

§json_to_string: bool

When 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: bool

When true, add synthetic metadata field conversion for ConversionResult. Only NAPI backend sets this (it adds metadata field to the struct).

§option_duration_on_defaults: bool

When 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: bool

When true, binding enums include data variant fields (Magnus). When false (default), binding enums are unit-only and data is lost in conversion.

§exclude_types: &'a [String]

Type names excluded from the binding layer. Fields referencing these types are skipped in the binding struct and defaulted in From conversions. Used by WASM to handle types excluded due to native dependency requirements.

Trait Implementations§

Source§

impl<'a> Clone for ConversionConfig<'a>

Source§

fn clone(&self) -> ConversionConfig<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Default for ConversionConfig<'a>

Source§

fn default() -> ConversionConfig<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ConversionConfig<'a>

§

impl<'a> RefUnwindSafe for ConversionConfig<'a>

§

impl<'a> Send for ConversionConfig<'a>

§

impl<'a> Sync for ConversionConfig<'a>

§

impl<'a> Unpin for ConversionConfig<'a>

§

impl<'a> UnsafeUnpin for ConversionConfig<'a>

§

impl<'a> UnwindSafe for ConversionConfig<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.