Skip to main content

gen_async_body

Function gen_async_body 

Source
pub fn gen_async_body(
    core_call: &str,
    cfg: &RustBindingConfig<'_>,
    has_error: bool,
    return_wrap: &str,
    is_opaque: bool,
    inner_clone_line: &str,
    is_unit_return: bool,
) -> String
Expand description

Generate the body for an async call, unified across methods, static methods, and free functions.

  • core_call: the expression to await, e.g. inner.method(args) or CoreType::fn(args). For Pyo3FutureIntoPy opaque methods this should reference inner (the Arc clone); for all other patterns it may reference self.inner or a static call expression.

  • cfg: binding configuration (determines which async pattern to emit)

  • has_error: whether the core call returns a Result

  • return_wrap: expression to produce the binding return value from result, e.g. "result" or "TypeName::from(result)"

  • is_opaque: whether the binding type is Arc-wrapped (affects TokioBlockOn wrapping)

  • inner_clone_line: optional statement emitted before the pattern-specific body, e.g. "let inner = self.inner.clone();\n " for opaque instance methods, or "". Required when core_call references inner (Pyo3FutureIntoPy opaque case).