Expand description
equilibrium-ffi — Automatic C FFI generation
This crate auto-detects C-compiling languages (V, Zig, C++, C#, etc.), compiles them to C intermediate representation, and generates Rust bindings so you can call foreign code like native modules.
§Quick Start
ⓘ
use equilibrium_ffi::load;
let lib = load("native/math.c")?;
println!("{}", lib.output_path.display());§Supported Languages
| Language | Compiler | C Backend |
|---|---|---|
| V (Vlang) | v | v -o output.c -backend c |
| Zig | zig | zig build-obj -femit-asm or C export |
| C/C++ | clang/gcc | Native |
| C# | csc/mono | P/Invoke + Native AOT |
| Rust | rustc | cbindgen |
Structs§
- Auto
Binding Options - Options for automatic binding generation.
- Binding
Options - Options for binding generation.
- Compile
Result - Result of a successful compilation.
- Export
Discovery - Export
Options - Generated
Binding - A generated Rust binding.
- Generated
Import - Generation
Result - Result of generating bindings for multiple libraries.
- Import
Options - Language
Info - Information about a detected language.
- Library
Binding Result - Result of generating bindings for a single library.
- Library
Discovery - A discovered C library with its headers.
- Library
Scanner - Scanner for discovering C libraries in a directory tree.
- Load
Options - Options for loading a foreign module.
- Loaded
Module - Result of loading a foreign module.
Enums§
- Compile
Error - Error during compilation.
- Export
Error - Export
Source - Language
- Supported languages that can be compiled to C.
- Load
Error - Errors that can occur when loading a module.
Functions§
- compile_
batch - Compile multiple files to C.
- compile_
to_ c - Compile a source file to C intermediate representation.
- detect_
language - Detect the language of a source file based on extension.
- discover_
exports - discover_
exports_ with_ options - find_
compiler - Check if a compiler is available on the system.
- generate_
bindings - Generate Rust bindings from a C header file.
- generate_
imports - load
- Load a foreign source file — compiles, generates bindings, returns ready-to-use module.
- load_
with_ options - Load with custom options.
- scan_
c_ libraries - Scan a directory for C libraries and generate bindings.
- scan_
directory - Scan a directory and detect all source files with their languages.