Answer#
The two options are not exclusive, and the right choice differs per module. The deciding questions are: how well tested is the C code, how often does it change, does it handle input from outside your program, and how large is it?
The answers below describe the two approaches as separate, complete options, with the trade-off of each.
Related questions#
Can Rust and C code live in one project?#
Yes. Cargo can compile C files with a build.rs script (the cc crate), and Rust code can export extern "C" functions that C calls. One executable can contain both.
How do I decide module by module?#
Start with the code that reads files, network data or user input, because memory errors there are security problems. Leave pure computation that is well tested for later.
Sources#
- The Rustonomicon, "Foreign Function Interface": https://doc.rust-lang.org/nomicon/ffi.html