Skip to main content

config_constructor_parts_with_options

Function config_constructor_parts_with_options 

Source
pub fn config_constructor_parts_with_options(
    fields: &[FieldDef],
    type_mapper: &dyn Fn(&TypeRef) -> String,
    option_duration_on_defaults: bool,
) -> (String, String, String)
Expand description

Generate constructor parameter and assignment lists for types with has_default. All fields become Option with None defaults for optional fields, or unwrap_or_else with actual defaults for required fields.

Returns (param_list, signature_defaults, assignments). This is used by PyO3 and similar backends that need signature annotations. Like config_constructor_parts but with extra options. When option_duration_on_defaults is true, non-optional Duration fields are stored as Option<u64> in the binding struct, so the constructor assignment is a passthrough (the From conversion will handle the None → core default mapping).