Skip to content

Extend ffi#3

Merged
VPRamon merged 4 commits intomainfrom
extend-ffi
Feb 24, 2026
Merged

Extend ffi#3
VPRamon merged 4 commits intomainfrom
extend-ffi

Conversation

@VPRamon
Copy link
Member

@VPRamon VPRamon commented Feb 24, 2026

This pull request significantly enhances the FFI (Foreign Function Interface) API of the tempoch-ffi crate by introducing type-safe duration and difference operations using the QttyQuantity type from the new qtty-ffi dependency. It also improves error safety across the API by wrapping FFI functions with a panic-catching macro, and updates FFI bindings and documentation accordingly.

The most important changes are:

Typed Duration and Difference API (QttyQuantity support)

  • Added new FFI functions that compute differences and perform arithmetic on Julian Dates and Modified Julian Dates using QttyQuantity, providing unit-aware, type-safe results (e.g., tempoch_jd_difference_qty, tempoch_jd_add_qty, tempoch_mjd_difference_qty, tempoch_mjd_add_qty, tempoch_jd_julian_centuries_qty, tempoch_period_mjd_duration_qty). [1] [2]
  • Updated Cargo.toml to add qtty-ffi as a dependency and bump qtty to version 0.3.1.

FFI Safety and Error Handling

  • Introduced a catch_panic! macro to catch Rust panics and return error codes instead of unwinding across the FFI boundary, and applied it to all FFI functions that write to out-pointers or perform conversions. [1] [2] [3] [4] [5] [6] [7]

FFI Bindings and Header Updates

  • Updated cbindgen.toml and the generated C header (tempoch_ffi.h) to include qtty_ffi.h for type definitions, exclude duplicate types from auto-generation, and document the new API surface. [1] [2] [3]

Documentation Improvements

  • Improved crate-level documentation to explain the new type-safe duration API and the use of QttyQuantity in FFI.

These changes provide a safer, more expressive, and unit-aware FFI API for time computations, facilitating better integration with C/C++ consumers.

@VPRamon VPRamon self-assigned this Feb 24, 2026
@github-actions
Copy link

Code Coverage

Package Line Rate Complexity Health
tempoch-core.src 99% 0
tempoch-ffi.src 81% 0
Summary 95% (1620 / 1705) 0

@VPRamon VPRamon merged commit e04bb31 into main Feb 24, 2026
5 checks passed
@VPRamon VPRamon deleted the extend-ffi branch February 24, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant