Expand description
Raw, hand-written FFI declarations for libantfly, the embedded Antfly
C ABI.
This mirrors zig/pkg/antfly-embedded/include/antfly.h field-for-field and
function-for-function. There is no bindgen/libclang dependency: the
header is small and stable enough that a hand-written mirror is easier to
audit and does not require a C toolchain to build this crate.
Nothing in this crate is safe to call directly: every function takes raw
pointers and untyped handles exactly as the C ABI defines them. Use the
antfly-embedded crate for a safe API.
Linking against the actual libantfly dylib only happens when the
libantfly Cargo feature is enabled (see build.rs). Without it, this
crate compiles (and its types can be named) but must not be linked into
any binary that references these extern "C" items, or linking will
fail.
Naming (mirrors the header’s own convention): antfly_* functions are
library-level and take no database handle; antfly_db_* functions take
an antfly_db handle of any storage kind; antfly_lite_* functions
operate on the .aflite single-file format itself, plus shortcuts for
opening one.
Structs§
- antfly_
buffer - antfly_
db - An open database. Opaque; see
antfly_db_open_with_options. Every handle-taking function in this crate takes*mut antfly_db/*mut *mut antfly_db, matching the header’s typed opaque pointer (ABI version 2 replaced the untypedvoid *handle with this type). - antfly_
dense_ search_ hit - antfly_
dense_ search_ profile - antfly_
dense_ search_ result - antfly_
dense_ wire_ search_ profile - antfly_
inference - An open embedded inference runtime, with no database. Opaque; see
antfly_inference_open. Models load on first use and stay cached until the handle closes. Handles have the same thread-safety guarantees asantfly_db(seezig/CAPI.md’s “Thread Safety” section): any thread may call concurrently, close waits for in-flight calls, and a closed or foreign handle is rejected withANTFLY_INVALID_ARGUMENT. - antfly_
inference_ options - Options for
antfly_inference_open.reserved/abi_sizelayout must mirror the header exactly –tests/abi_sizes.rscheckssize_of::<antfly_inference_options>()againstantfly_inference_options_size(). - antfly_
inference_ pull_ progress - One report to an
antfly_inference_pull_jsonprogress callback. The slices are valid only during the callback. Checkabi_sizebefore reading fields added in later versions. - antfly_
open_ options - One options struct for every storage kind.
storage_kind(anANTFLY_STORAGE_KIND_*value) picks a.aflitefile or a normal directory; the inference budget fields,busy_timeout_ms, and The reserved tail and models_dir layout must mirror the header exactly –tests/abi_sizes.rscheckssize_of::<antfly_open_options>()againstantfly_open_options_size(). - antfly_
packed_ dense_ search_ hit - antfly_
packed_ dense_ search_ result - antfly_
scan_ hash_ entry - antfly_
scan_ hash_ result - antfly_
slice - antfly_
version_ predicate - antfly_
write_ intent
Constants§
- ANTFLY_
BUSY - ANTFLY_
CANCELLED - The caller cancelled the call by returning
falsefrom its progress or stream callback. - ANTFLY_
GRAPH_ DIRECTION_ BOTH - ANTFLY_
GRAPH_ DIRECTION_ IN - ANTFLY_
GRAPH_ DIRECTION_ OUT directionvalues forantfly_db_get_edges_jsonandantfly_db_get_neighbors_json.- ANTFLY_
INFERENCE_ MODE_ CALLER_ SUPPLIED_ ARTIFACTS - ANTFLY_
INFERENCE_ MODE_ CALLER_ SUPPLIED_ OR_ DISABLED inference.modevalues reported byantfly_db_status_json.- ANTFLY_
INFERENCE_ MODE_ DISABLED_ DEFERRED - ANTFLY_
INFERENCE_ MODE_ LOCAL_ EMBEDDED - ANTFLY_
INFERENCE_ MODE_ MANUAL_ MAINTENANCE - ANTFLY_
INFERENCE_ MODE_ REMOTE_ PROVIDER - ANTFLY_
INTENT_ CONFLICT - ANTFLY_
INTERNAL - ANTFLY_
INVALID_ ARGUMENT - ANTFLY_
MIN_ THREAD_ STACK_ SIZE - Minimum native stack, in bytes, for any thread that calls into libantfly.
See
ANTFLY_MIN_THREAD_STACK_SIZEin antfly.h. - ANTFLY_
NOT_ FOUND - ANTFLY_
OK - ANTFLY_
OPEN_ FLAG_ GENERATED_ ENRICHMENT_ REPLAY - ANTFLY_
OPEN_ FLAG_ LOCAL_ RUNTIME_ CONFIGURED - ANTFLY_
OPEN_ FLAG_ NO_ SYNC - ANTFLY_
OPEN_ FLAG_ REMOTE_ PROVIDER_ CONFIGURED - ANTFLY_
OPEN_ FLAG_ TTL_ CLEANUP - ANTFLY_
OPEN_ MODE_ READONLY - ANTFLY_
OPEN_ MODE_ STATUS_ ONLY - ANTFLY_
OPEN_ MODE_ WRITER - ANTFLY_
OUTCOME_ RECEIPT_ APPLIED antfly_db_outcome_receipt_statusresult: the uncertain write applied.- ANTFLY_
OUTCOME_ RECEIPT_ NOT_ APPLIED antfly_db_outcome_receipt_statusresult: the uncertain write did not apply.- ANTFLY_
OUTCOME_ UNKNOWN - ANTFLY_
PROFILE_ HOSTED - ANTFLY_
PROFILE_ NATIVE - ANTFLY_
REPLACEMENT_ CONFIGURATION_ MISMATCH - ANTFLY_
REPLACEMENT_ FAILED - ANTFLY_
REPLACEMENT_ PENDING - ANTFLY_
STALLED - ANTFLY_
STORAGE_ KIND_ DIRECTORY - ANTFLY_
STORAGE_ KIND_ LITE - ANTFLY_
THREADING_ SERIALIZED - Threading contract, like
sqlite3_threadsafe(). Seeantfly_threading_mode. - ANTFLY_
TXN_ ABORTED - ANTFLY_
TXN_ COMMITTED - ANTFLY_
TXN_ NOT_ FOUND - ANTFLY_
TXN_ PENDING - ANTFLY_
UNSUPPORTED - ANTFLY_
VERSION_ CONFLICT
Functions§
- antfly_
abi_ ⚠version - antfly_
buffer_ ⚠free - antfly_
buffer_ ⚠free_ zero - antfly_
db_ ⚠add_ enrichment_ json - antfly_
db_ ⚠add_ index_ json - antfly_
db_ ⚠aggregate_ hits_ json - antfly_
db_ ⚠backup - antfly_
db_ ⚠backup_ json - antfly_
db_ ⚠batch - antfly_
db_ ⚠batch_ json - antfly_
db_ ⚠batch_ json_ with_ receipt - antfly_
db_ ⚠batch_ with_ receipt antfly_db_batch_jsonthat also returns the receipt inreceipt_out(only onANTFLY_OUTCOME_UNKNOWN), for callers whose consecutive native calls may run on different threads.- antfly_
db_ ⚠begin_ transaction_ with_ id - antfly_
db_ ⚠cancel_ replacement - antfly_
db_ ⚠capabilities_ json - antfly_
db_ ⚠close - antfly_
db_ ⚠compute_ enrichments_ json - antfly_
db_ ⚠create_ table_ json - antfly_
db_ ⚠create_ with_ options - antfly_
db_ ⚠curate_ entity_ json - antfly_
db_ ⚠cypher_ json - antfly_
db_ ⚠decide_ curation_ proposal_ json - antfly_
db_ ⚠delete_ enrichment - antfly_
db_ ⚠delete_ index - antfly_
db_ ⚠drop_ resolver_ identity - antfly_
db_ ⚠drop_ table - antfly_
db_ ⚠entity_ merge_ json - antfly_
db_ ⚠entity_ redirects_ json - antfly_
db_ ⚠entity_ suppress_ json - antfly_
db_ ⚠entity_ unmerge_ json - antfly_
db_ ⚠entity_ unsuppress_ json - antfly_
db_ ⚠execute_ graph_ queries_ json - antfly_
db_ ⚠extract_ enrichments_ json - antfly_
db_ ⚠find_ k_ shortest_ paths_ json - antfly_
db_ ⚠find_ shortest_ path_ json - antfly_
db_ ⚠get_ commit_ version - antfly_
db_ ⚠get_ curation_ proposal_ json - antfly_
db_ ⚠get_ edges_ json - antfly_
db_ ⚠get_ neighbors_ json - antfly_
db_ ⚠get_ raw - antfly_
db_ ⚠get_ schema_ json - antfly_
db_ ⚠get_ timestamp - antfly_
db_ ⚠get_ transaction_ status - antfly_
db_ ⚠graph_ catalog_ json - antfly_
db_ ⚠graph_ write_ status_ json - antfly_
db_ ⚠import_ backup - antfly_
db_ ⚠list_ curation_ proposals_ json - antfly_
db_ ⚠list_ enrichments_ json - antfly_
db_ ⚠list_ indexes_ json - antfly_
db_ ⚠list_ resolver_ identities_ json - antfly_
db_ ⚠list_ tables_ json - antfly_
db_ ⚠lookup_ artifact_ json - antfly_
db_ ⚠lookup_ json - antfly_
db_ ⚠match_ pattern_ json - antfly_
db_ ⚠memory_ json - antfly_
db_ ⚠merge_ resolver_ keys_ json - antfly_
db_ ⚠open - antfly_
db_ ⚠open_ table - antfly_
db_ ⚠open_ with_ options - antfly_
db_ ⚠outcome_ receipt_ forget - antfly_
db_ ⚠outcome_ receipt_ status - antfly_
db_ ⚠pending_ work_ stats_ json - antfly_
db_ ⚠propose_ curation_ json - antfly_
db_ ⚠render_ resolver_ key_ json - antfly_
db_ ⚠replay_ generated_ enrichments_ json - antfly_
db_ ⚠resolve_ intents - antfly_
db_ ⚠resolve_ query_ json - antfly_
db_ ⚠resolver_ curation_ json - antfly_
db_ ⚠resolver_ reviews_ json - antfly_
db_ ⚠run_ until_ idle - antfly_
db_ ⚠run_ until_ idle_ json - antfly_
db_ ⚠scan_ hashes - antfly_
db_ ⚠scan_ json - antfly_
db_ ⚠search_ dense - antfly_
db_ ⚠search_ dense_ profile - antfly_
db_ ⚠search_ dense_ wire - antfly_
db_ ⚠search_ dense_ wire_ profile - antfly_
db_ ⚠search_ hits_ json - antfly_
db_ ⚠search_ json - antfly_
db_ ⚠search_ text_ match - antfly_
db_ ⚠search_ text_ match_ phrase_ wire - antfly_
db_ ⚠search_ text_ match_ wire - antfly_
db_ ⚠search_ text_ term_ wire - antfly_
db_ ⚠set_ resolver_ namespace_ json - antfly_
db_ ⚠set_ schema_ json - antfly_
db_ ⚠sql_ close_ cursor - antfly_
db_ ⚠sql_ describe_ json - antfly_
db_ ⚠sql_ fetch_ cursor_ json - antfly_
db_ ⚠sql_ json - antfly_
db_ ⚠sql_ open_ cursor_ json - antfly_
db_ ⚠sql_ session_ close - antfly_
db_ ⚠sql_ session_ open - antfly_
db_ ⚠stats_ json - antfly_
db_ ⚠status_ json - antfly_
db_ ⚠suppress_ resolver_ keys_ json - antfly_
db_ ⚠traverse_ edges_ json - antfly_
db_ ⚠unmerge_ resolver_ key_ json - antfly_
db_ ⚠unsuppress_ resolver_ key_ json - antfly_
db_ ⚠write_ transaction - antfly_
decode_ ⚠artifact_ id_ json - antfly_
dense_ ⚠search_ result_ free - antfly_
error_ ⚠code_ description - antfly_
error_ ⚠code_ name - antfly_
inference_ ⚠chunk_ json - antfly_
inference_ ⚠close - antfly_
inference_ ⚠decide_ json - Model-independent typed decisions, matching
POST /ai/v1/decide. - antfly_
inference_ ⚠embed_ json - antfly_
inference_ ⚠extract_ json - antfly_
inference_ ⚠generate_ batch_ json - Up to 128 non-streaming generate requests in one call; per-item failures are reported in the response.
- antfly_
inference_ ⚠generate_ json - antfly_
inference_ ⚠generate_ stream_ json - Streams a generate request (the same body as
antfly_inference_generate_json;"stream"is set for the caller).on_chunkis called on the calling thread for each chunk as the model produces tokens. ReturnsANTFLY_OKonce generation finishes, orANTFLY_CANCELLEDwhenon_chunkreturnedfalse. A request rejected before generation starts (such as a missing model) fails likeantfly_inference_generate_json, with the JSON error inout; a failure mid-stream returnsANTFLY_INTERNALwith{"error": "STREAM_FAILED", ...}. - antfly_
inference_ ⚠list_ models_ json - The installed models, as returned by
GET /ai/v1/models. - antfly_
inference_ ⚠open optionsmay be NULL for defaults.- antfly_
inference_ ⚠options_ init - antfly_
inference_ ⚠options_ size - antfly_
inference_ ⚠pull_ json - Downloads a model from the Hugging Face Hub into the handle’s models
directory, like
antfly inference pull.progress(may be NULL) is called on the calling thread as files download. The call cannot be cancelled, andantfly_inference_closewaits for it. - antfly_
inference_ ⚠read_ json - antfly_
inference_ ⚠rerank_ json - antfly_
inference_ ⚠rewrite_ json - antfly_
last_ ⚠error_ code - antfly_
last_ ⚠error_ detail - antfly_
last_ ⚠error_ outcome_ receipt - Receipt of this thread’s most recent
ANTFLY_OUTCOME_UNKNOWNfrom an autocommit SQL write or batch export; call on the same thread before any other Antfly call.ANTFLY_NOT_FOUNDwhen that call issued none. - antfly_
lite_ ⚠check_ file_ json - antfly_
lite_ ⚠check_ json - antfly_
lite_ ⚠compact_ json - antfly_
lite_ ⚠copy_ stable_ snapshot_ file_ json - antfly_
lite_ ⚠copy_ stable_ snapshot_ json - antfly_
lite_ ⚠create - antfly_
lite_ ⚠create_ hosted - antfly_
lite_ ⚠open - antfly_
lite_ ⚠open_ hosted - antfly_
lite_ ⚠open_ readonly - antfly_
lite_ ⚠open_ status_ only - antfly_
lite_ ⚠vacuum_ json - antfly_
open_ ⚠options_ init - antfly_
open_ ⚠options_ size - antfly_
packed_ ⚠dense_ search_ result_ free - antfly_
restore_ ⚠backup_ file_ json - antfly_
restore_ ⚠backup_ json - antfly_
scan_ ⚠hash_ result_ free - antfly_
threading_ ⚠mode
Type Aliases§
- antfly_
error_ code - A stable Antfly C ABI error code. Represented as
i32to match a plain Cenum’s default underlying type on every target this crate supports. - antfly_
inference_ pull_ progress_ fn - Progress callback for
antfly_inference_pull_json. May beNone(a NULL function pointer). Called synchronously on the calling thread; the*const antfly_inference_pull_progressit receives is only valid for the duration of the call. Returntrueto continue,falseto cancel the pull (the call then returnsANTFLY_CANCELLED; completed files stay staged, so a later pull of the same model resumes rather than restarts). - antfly_
inference_ stream_ fn - Streaming callback for
antfly_inference_generate_stream_json. Receives one streamed chunk – the JSON of achat.completion.chunk– valid only during the call, called on the calling thread as the model produces tokens. Returntrueto continue,falseto stop generating (the call then returnsANTFLY_CANCELLED). - antfly_
txn_ status - Transaction intent lifecycle state. Every C ABI function that carries a
transaction status uses a raw
uint8_t, not this enum type, so this alias exists only for documentation/parity with the header.