pub struct RustBindingConfig<'a> {Show 23 fields
pub struct_attrs: &'a [&'a str],
pub field_attrs: &'a [&'a str],
pub struct_derives: &'a [&'a str],
pub method_block_attr: Option<&'a str>,
pub constructor_attr: &'a str,
pub static_attr: Option<&'a str>,
pub function_attr: &'a str,
pub enum_attrs: &'a [&'a str],
pub enum_derives: &'a [&'a str],
pub needs_signature: bool,
pub signature_prefix: &'a str,
pub signature_suffix: &'a str,
pub core_import: &'a str,
pub async_pattern: AsyncPattern,
pub has_serde: bool,
pub type_name_prefix: &'a str,
pub option_duration_on_defaults: bool,
pub opaque_type_names: &'a [String],
pub skip_impl_constructor: bool,
pub cast_uints_to_i32: bool,
pub cast_large_ints_to_f64: bool,
pub named_non_opaque_params_by_ref: bool,
pub lossy_skip_types: &'a [String],
}Expand description
Configuration for Rust binding code generation.
Fields§
§struct_attrs: &'a [&'a str]Attrs applied to generated structs, e.g. ["pyclass(frozen)"].
field_attrs: &'a [&'a str]Attrs applied to each field, e.g. ["pyo3(get)"].
struct_derives: &'a [&'a str]Derives applied to generated structs, e.g. ["Clone"].
method_block_attr: Option<&'a str>Attr wrapping the impl block, e.g. Some("pymethods").
constructor_attr: &'a strAttr placed on the constructor, e.g. "#[new]".
static_attr: Option<&'a str>Attr placed on static methods, e.g. Some("staticmethod").
function_attr: &'a strAttr placed on free functions, e.g. "#[pyfunction]".
enum_attrs: &'a [&'a str]Attrs applied to generated enums, e.g. ["pyclass(eq, eq_int)"].
enum_derives: &'a [&'a str]Derives applied to generated enums, e.g. ["Clone", "PartialEq"].
needs_signature: boolWhether the backend requires #[pyo3(signature = (...))]-style annotations.
signature_prefix: &'a strPrefix for the signature annotation, e.g. "#[pyo3(signature = (".
signature_suffix: &'a strSuffix for the signature annotation, e.g. "))]".
core_import: &'a strCore crate import path, e.g. "liter_llm". Used to generate calls into core.
async_pattern: AsyncPatternAsync pattern supported by this backend.
has_serde: boolWhether serde/serde_json are available in the output crate’s dependencies.
When true, the generator can use serde-based param conversion and add serde::Serialize derives.
When false, non-convertible Named params fall back to gen_unimplemented_body.
type_name_prefix: &'a strPrefix for binding type names (e.g. “Js” for NAPI/WASM, “” for PyO3/PHP).
Used in impl block targets: impl {prefix}{TypeName}.
option_duration_on_defaults: boolWhen true, non-optional Duration fields on has_default types are emitted as
Option<u64> in the binding struct so that unset fields fall back to the core
type’s Default implementation rather than Duration::ZERO.
Used by PyO3 to prevent validation failures when request_timeout is unset.
opaque_type_names: &'a [String]Opaque type names. Structs with non-optional fields of these types
skip Default/Serialize/Deserialize derives since opaque wrappers don’t impl them.
skip_impl_constructor: boolWhen true, the impl block constructor (fn new(...)) is suppressed regardless of
whether the type has fields. Useful for backends (e.g. extendr) that generate a
separate kwargs-style free-function constructor instead of an in-class new().
cast_uints_to_i32: boolWhen true, small unsigned/signed ints (u8, u16, u32, i8, i16) are cast from i32 in
gen_lossy_binding_to_core_fields. Used by the extendr backend where R maps small
ints to i32.
cast_large_ints_to_f64: boolWhen true, large int/size types (u64, usize, isize) are cast from f64 in
gen_lossy_binding_to_core_fields. Used by the extendr backend where R maps large
ints to f64.
named_non_opaque_params_by_ref: boolWhen true, Named non-opaque struct parameters in free function signatures are emitted
as &T (reference) instead of T (owned). Required for the extendr backend because
#[extendr] only generates TryFrom<&Robj> for &T, not for T, so owned struct
params cannot be passed through the FFI layer.
lossy_skip_types: &'a [String]Types that have no From<BindingType> impl (e.g. output-only flat data enums).
When gen_lossy_binding_to_core_fields encounters a field whose TypeRef::Named type
is in this slice, it emits Default::default() instead of .clone().into().