Skip to content

Native FFI

TaiDB can build a native shared library with a C ABI. This is useful for languages that can call C libraries, but it is a lower-level integration path than the Rust API or CLI.

Terminal window
cargo build --release --features native-ffi

Artifacts:

  • macOS: target/release/libtaidb.dylib
  • Linux: target/release/libtaidb.so
  • Windows: target/release/taidb.dll
  • Header: include/taidb.h

Include:

#include "taidb.h"

The header defines the C ABI functions and structs for opening a database, writing values, reading values, inspecting stats, and releasing allocated resources.

Examples are available in the repository:

  • examples/c/native_ffi.c
  • examples/python/native_ffi.py
  • examples/go/native_ffi.go
  • examples/typescript/native_ffi.ts

Run the native smoke test:

Terminal window
make native-smoke
  • Build the shared library for each target platform.
  • Ship the library next to the application or configure the platform loader.
  • Keep the C header and shared library from the same TaiDB version.
  • Treat FFI as an advanced path until the API is frozen for 1.0.0.