# pyo3_bindgen
Automatic generation of Rust FFI bindings to Python modules via [PyO3](https://pyo3.rs). Python modules are analyzed recursively to generate Rust bindings with an identical structure for all public classes, functions, properties, and constants. Any available docstrings and type annotations are also preserved in their Rust equivalents. An example of a generated Rust function signature and its intended usage is shown below. Of course, manually wrapping parts of the generated bindings in a more idiomatic Rust API might be beneficial in most cases.Source code (Python) | Generated code (Rust) |
---|---|
```py def answer_to(question: str) -> int: """Returns answer to a question.""" return 42 ``` ______________________________________________________________________ ```py def main(): assert answer_to("life") == 42 if __name__ == "__main__": main() ``` |
```rs
/// Returns answer to a question.
pub fn answer_to<'py>(
py: ::pyo3::Python<'py>,
question: &str,
) -> ::pyo3::PyResult |