Skip to main content

Crate antfly_embedded_sys

Crate antfly_embedded_sys 

Source
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 untyped void * 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 as antfly_db (see zig/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 with ANTFLY_INVALID_ARGUMENT.
antfly_inference_options
Options for antfly_inference_open. reserved/abi_size layout must mirror the header exactly – tests/abi_sizes.rs checks size_of::<antfly_inference_options>() against antfly_inference_options_size().
antfly_inference_pull_progress
One report to an antfly_inference_pull_json progress callback. The slices are valid only during the callback. Check abi_size before reading fields added in later versions.
antfly_open_options
One options struct for every storage kind. storage_kind (an ANTFLY_STORAGE_KIND_* value) picks a .aflite file 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.rs checks size_of::<antfly_open_options>() against antfly_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 false from its progress or stream callback.
ANTFLY_GRAPH_DIRECTION_BOTH
ANTFLY_GRAPH_DIRECTION_IN
ANTFLY_GRAPH_DIRECTION_OUT
direction values for antfly_db_get_edges_json and antfly_db_get_neighbors_json.
ANTFLY_INFERENCE_MODE_CALLER_SUPPLIED_ARTIFACTS
ANTFLY_INFERENCE_MODE_CALLER_SUPPLIED_OR_DISABLED
inference.mode values reported by antfly_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_SIZE in 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_status result: the uncertain write applied.
ANTFLY_OUTCOME_RECEIPT_NOT_APPLIED
antfly_db_outcome_receipt_status result: 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(). See antfly_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_json that also returns the receipt in receipt_out (only on ANTFLY_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_chunk is called on the calling thread for each chunk as the model produces tokens. Returns ANTFLY_OK once generation finishes, or ANTFLY_CANCELLED when on_chunk returned false. A request rejected before generation starts (such as a missing model) fails like antfly_inference_generate_json, with the JSON error in out; a failure mid-stream returns ANTFLY_INTERNAL with {"error": "STREAM_FAILED", ...}.
antfly_inference_list_models_json⚠
The installed models, as returned by GET /ai/v1/models.
antfly_inference_open⚠
options may 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, and antfly_inference_close waits 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_UNKNOWN from an autocommit SQL write or batch export; call on the same thread before any other Antfly call. ANTFLY_NOT_FOUND when 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 i32 to match a plain C enum’s default underlying type on every target this crate supports.
antfly_inference_pull_progress_fn
Progress callback for antfly_inference_pull_json. May be None (a NULL function pointer). Called synchronously on the calling thread; the *const antfly_inference_pull_progress it receives is only valid for the duration of the call. Return true to continue, false to cancel the pull (the call then returns ANTFLY_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 a chat.completion.chunk – valid only during the call, called on the calling thread as the model produces tokens. Return true to continue, false to stop generating (the call then returns ANTFLY_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.