- Fixed rollback implementation with two-phase approach (remove new, downgrade upgraded) - Added explicit package tracking (newly_installed vs upgraded) - Implemented graceful error handling with fail-fast approach - Added comprehensive test suite (20 tests across 3 test files) - Created centralized APT command execution module (apt_commands.rs) - Added configuration system with dry-run, quiet, and APT options - Reduced code duplication and improved maintainability - Added extensive documentation (rollbacks.md, rollbacks-not-featured.md, ffi-bridge.md) - Created configuration usage example - Updated README with crate usage instructions - All tests passing, clean compilation, production-ready
1.4 KiB
1.4 KiB
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:
// 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 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
- Include the generated header file
- Link against the Rust library
- Use the FFI functions to interact with APT packages
Dependencies
cxxcrate for FFI generation- C++ compiler with C++17 support