# FFI Bridge Documentation ## Overview The APT Wrapper provides a C++ Foreign Function Interface (FFI) bridge for integration with C++ applications, particularly designed for apt-ostree. ## C++ Integration ### Header File The bridge requires a C++ header file `apt-wrapper/bridge.h` that defines the C++ side of the interface. ### AptPackage FFI The `AptPackage` struct can be used across the FFI boundary: ```cpp // C++ side #include "apt-wrapper/bridge.h" // Create package from Rust AptPackage package = new_ffi("vim", "2:8.1.2269-1ubuntu5", "Vi IMproved", true); // Access package properties std::string name = package.name(); std::string version = package.version(); std::string description = package.description(); bool installed = package.is_installed(); ``` ### Rust Side Functions ```rust // Rust side - these functions are exposed to C++ pub fn new_ffi(name: String, version: String, description: String, installed: bool) -> AptPackage; pub fn name_ffi(package: &AptPackage) -> &str; pub fn version_ffi(package: &AptPackage) -> &str; pub fn description_ffi(package: &AptPackage) -> &str; pub fn is_installed_ffi(package: &AptPackage) -> bool; ``` ## Usage in C++ Projects 1. Include the generated header file 2. Link against the Rust library 3. Use the FFI functions to interact with APT packages ## Dependencies - `cxx` crate for FFI generation - C++ compiler with C++17 support