#interop #c #quantities

qtty-ffi

C-compatible FFI bindings for qtty physical quantities and conversions

12 releases (6 breaking)

new 0.8.1 May 14, 2026
0.6.1 Apr 25, 2026
0.5.0 Mar 31, 2026
0.2.1 Dec 22, 2025

#426 in FFI

Download history 22/week @ 2026-02-24 26/week @ 2026-03-03 10/week @ 2026-03-24 6/week @ 2026-03-31 10/week @ 2026-04-21 15/week @ 2026-04-28 135/week @ 2026-05-05

160 downloads per month
Used in 2 crates (via tempoch-ffi)

BSD-3-Clause

175KB
2.5K SLoC

qtty-ffi

C-compatible ABI bridge for qtty.

qtty-ffi exposes stable carrier structs, unit identifiers, status codes, and conversion/formatting functions so C and C++ consumers can use qtty's unit registry without reimplementing conversion logic.

Highlights

  • QttyQuantity and QttyDerivedQuantity POD carriers
  • stable UnitId and DimensionId discriminants
  • extern "C" entry points for construction, conversion, inspection, and formatting
  • generated header at include/qtty_ffi.h
  • optional Rust-side qtty_serde and pyo3 helpers

Install

[dependencies]
qtty-ffi = "0.8.0"

C example

#include "qtty_ffi.h"

qtty_quantity_t meters;
qtty_quantity_make(1000.0, UNIT_ID_METER, &meters);

qtty_quantity_t kilometers;
if (qtty_quantity_convert(meters, UNIT_ID_KILOMETER, &kilometers) == QTTY_OK) {
    /* kilometers.value == 1.0 */
}

Rust example

use qtty::Meter;
use qtty_ffi::{QttyQuantity, UnitId};

let qty: QttyQuantity = Meter::new(12.5).into();
assert_eq!(qty.unit, UnitId::Meter as u32);
  • qtty: user-facing Rust facade
  • qtty-core: low-level unit type system
  • qtty-derive: proc-macro for custom unit markers

Dependencies

~1.7–4.5MB
~91K SLoC