11 Foreign Function Interfaces
Not all code is written in Rust. It’s shocking, I know. Every so often, you’ll need to interact with code written in other languages, either by calling into such code from Rust or by allowing that code to call your Rust code. You can achieve this through foreign function interfaces (FFI).
In this chapter we’ll first look at the primary mechanism Rust provides for FFI: the extern
keyword. We’ll see how to use extern
both to expose Rust functions and statics to other languages and to give Rust access to functions and static variables provided from outside the Rust bubble. Then, we’ll walk through how to align ...
Get Rust for Rustaceans now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.