C and C++
crates/bothy-ffi builds
libbothy_ffi (shared or static) with the header include/bothy.h. Documents and reports cross
the boundary as JSON strings.
#include "bothy.h"
BothyDb *db = bothy_open("{\"path\":\"robot.db\",\"app_id\":\"com.example.robot\"," "\"remote\":{\"folder\":\"/mnt/shared\"}}");if (!db) { fprintf(stderr, "%s\n", bothy_last_error()); return 1; }char *id = bothy_init_or_join(db);bothy_put(db, "missions", "m1", "{\"goal\":\"dock\"}");char *report = bothy_sync(db);char *doc = bothy_get(db, "missions", "m1");bothy_string_free(doc); bothy_string_free(report); bothy_string_free(id);bothy_close(db);- Strings: strings returned by
bothy_*belong to the caller; free them withbothy_string_free. - Errors: on failure, a function returns
NULLor-1, andbothy_last_error_kind()andbothy_last_error()(per thread) say why. - Remotes:
remoteis{"folder": dir},{"drive_folder": name}or{"drive_appdata": true}. Drive remotes needbothy_open_with_tokenswith a callback that fills in an access token, so OAuth stays in your program. - Threads: all functions are thread-safe.
cargo build --release -p bothy-ffi # target/release/libbothy_ffi.{so,dylib,a}The C ABI is early (0.x) and not published to a package registry; build it from the repository.