NewsCrawler.org

FFI Arena compares six Rust FFI frameworks on type support and C bindings

FFI Arena compares six FFI[1] frameworks for Rust: UniFFI, BoltFFI, Diplomat, CO3, safer_ffi and Interoptopus. The main test is type support: types with a stable representation, such as [u32; 4], need no conversion, while types like Vec<u32> must first be lowered into a stable form. When a &[u8] parameter is changed to a type alias named Buffer, only CO3 keeps its behavior: BoltFFI fails to compile, UniFFI changes the ABI[2] and copies bytes instead of borrowing them, and Diplomat exposes the Rust slice directly, which the author says silently introduces undefined behavior[3].

The author says CO3 resolves types using the Rust compiler, while the other frameworks rely on the type's name, and that fixing this would require a complete restructuring of each framework. Only CO3 can bind functions from an existing C library, through the same conversion API it uses for exports, but it does not yet support async functions or trait objects. Other frameworks offer immediate integration with other languages, while CO3 offers a stable intermediate representation that foreign-language plugins can be built against.

The author, who maintains CO3, says its foundations are stronger on several fronts but admits the view may be biased, and notes that CO3 cannot yet generate bindings for other languages. The author calls the page a starting point and leaves the verdict to the reader.

Read the original mversic.github.ioDiscussion

Sources

Published: First seen: Читать по-русски

Open as a page