Expand description
C ABI for WombatKV’s KV store. Companion to
include/wombatkv.h.
Build: cargo build -p wombatkv-cabi --release produces
target/release/libwombatkv.dylib (macOS) or .so (Linux).
All extern “C” functions are wrapped in catch_unwind so a Rust
panic on the puffer side never propagates into the C caller.
All pointer-handling unsafe blocks are isolated to the ffi
submodule with audit comments. The rest of this crate is safe code.
Re-exports§
pub use config::CabiConfig;
Modules§
- config
- Centralized cabi (embedded + remote-client) configuration.
Structs§
- Handle
- Public Rust handle. The cdylib hands an opaque
wmbt_kv_handle_t*to C; we cast it back to&Handleon every call. - wmbt_
kv_ borrow - Opaque borrow handle returned by the zero-copy
*_borrowedgetter functions. The C caller treats it as an opaque cookie and passes it back towmbt_kv_release_borrowwhen done reading the payload. - wmbt_
kv_ handle - Opaque handle (named
wmbt_kv_handlein the C header).
Constants§
- ABI_
MAJOR - ABI major version. Bump on backwards-incompatible C ABI changes.
- ABI_
MINOR - ABI minor version. Bump on backwards-compatible C ABI extensions.
Functions§
- wmbt_
kv_ abi_ version - Pack ABI version as
(major << 16) | minor. - wmbt_
kv_ blake3_ 64hex - Compute a 64-hex-char (32-byte) blake3 digest of the input. Output buffer MUST be at least 65 bytes (64 hex chars + NUL terminator).
- wmbt_
kv_ crc32c - One-shot CRC32C (Castagnoli polynomial) over
in_lenbytes atin_ptr. Equivalent towmbt_kv_crc32c_append(0, in_ptr, in_len). - wmbt_
kv_ crc32c_ append - Append
in_lenbytes atin_ptrto a running CRC32C accumulator and return the new accumulator value. Use to chain multiple buffers into a single CRC32C without forcing the caller to materialise them contiguously.crcis the accumulator from the previous call (or 0 to start fresh). - wmbt_
kv_ free - Release a handle constructed by
wmbt_kv_init_from_env. Safe to pass NULL. - wmbt_
kv_ get_ kv_ blocks_ borrowed - Parallel GET for a batch of content-addressed blocks.
- wmbt_
kv_ get_ raw_ tail_ borrowed - GET a raw-tail sidecar payload with borrow semantics. Mirrors
wmbt_kv_get_kv_borrowedshape. - wmbt_
kv_ init_ from_ env - Construct a handle from environment variables. Returns NULL on
error; inspect
wmbt_kv_last_error()for the message. - wmbt_
kv_ last_ error - Returns the most recent thread-local error message, or NULL.
- wmbt_
kv_ lookup_ block_ prefix - Walk a chain of block hashes and report how many leading hashes are present in the in-memory metadata index.
- wmbt_
kv_ open_ http - Construct an HTTP-backed handle for the given
addr(“host:port”, NUL-terminated). Daemon side must be runningwombatkv-daemon --http <addr>. Equivalent to settingWMBT_KV_HTTP_ADDR=<addr>in the env and callingwmbt_kv_init_from_envbut lets engines pick HTTP without mutating env vars. - wmbt_
kv_ open_ tcp - Construct a handle that talks to a remote
wombatkv-daemonover TCP.addris a NUL-terminated “host:port” string (e.g."203.0.113.5:7878"). The daemon must be running withwombatkv-daemon --tcp <addr>. - wmbt_
kv_ put_ kv_ blocks - Parallel PUT for a batch of content-addressed blocks.
- wmbt_
kv_ put_ raw_ tail - PUT a raw-tail sidecar payload keyed by
chain_tip_hash_hex(64-char lower-hex blake3 digest of the LAST block in the saved chain). - wmbt_
kv_ release_ borrow - Release a borrow obtained from any of the
*_borrowedfunctions (wmbt_kv_get_kv_blocks_borrowed,wmbt_kv_get_raw_tail_borrowed). Safe to pass NULL.