Rust FFI Guide
Create safe foreign function interfaces between Rust and other languages like C, C++, and Python.
Usage
Describe the FFI scenario you need and get implementation guidance with safety considerations.
Examples
- "Call a C library from Rust using bindgen"
- "Expose Rust functions as a C shared library"
- "Create a Python extension module with PyO3"
Guidelines
- Always wrap unsafe FFI calls in safe Rust abstractions
- Show proper memory management across FFI boundaries
- Cover string handling between Rust and C
- Explain cbindgen for generating C headers from Rust
- Include error handling strategies across language boundaries