Expand description
Raw FFI declarations for the SEMQ core.
Mirrors include/semq.h one-to-one: the constants, every enum value,
the plain structs, the opaque handles and all exported functions. Nothing
here is safe; the semq crate builds the safe API on top. The
declarations are written by hand so the build needs no libclang; layout
tests pin the structs whose size and offsets the ABI depends on.
C enums are declared as u32 aliases with one constant per value. Every
function that can fail returns a semq_status_t and fills the
semq_error_t it is given, when non-null.
Structs§
- semq_
codec_ t - Opaque codec handle (
struct semq_codec). - semq_
config_ t - A codec configuration.
opis asemq_operator_t;p1isscale(orbit),sectors(phase) orbins(quant);p2is the rule revision. - semq_
diff_ t - Opaque diff handle (
struct semq_diff). - semq_
encoding_ t - Opaque encoding handle (
struct semq_encoding). - semq_
error_ t - Error report.
statusis the returned status;whichis set only forSEMQ_ERR_INTEGRITY;rowandfieldareSEMQ_NONEwhen they do not apply.messageis always NUL-terminated and never contains input data. - semq_
floor_ t - Opaque floor handle (
struct semq_floor). - semq_
ids_ t - Identifiers of
nrows, in input order (any order; the core sorts). ForSEMQ_ID_U64passu64(n entries). ForSEMQ_ID_UTF8passutf8_offsets(n + 1 entries,offsets[0] = 0, non-decreasing) andutf8_bytes(offsets[n]bytes): idiisbytes[offsets[i] .. offsets[i+1]). - semq_
manifest_ change_ t - A change to one manifest key.
has_before/has_afterare 0 when the key is absent on that side; the pointers are then NULL. - semq_
pair_ t - One manifest pair. Keys and values are UTF-8 bytes, not NUL-terminated.
- semq_
part_ t - One borrowed part of the file image.
- semq_
verdict_ t - Opaque verdict handle (
struct semq_verdict).
Constants§
- SEMQ_
CHECK_ PER_ ROW - SEMQ_
CONFIG_ BYTES - Size of the canonical config form in bytes.
- SEMQ_
DIGEST_ BYTES - Size of each identity (
content_digest,state_id) in bytes. - SEMQ_
ERR_ FORMAT - A file image is not a valid v2 image.
- SEMQ_
ERR_ INCOMPATIBLE - Two states differ in config or id kind.
- SEMQ_
ERR_ INTEGRITY - A file image’s digest does not match.
- SEMQ_
ERR_ INTERNAL - A defect in the core; report it.
- SEMQ_
ERR_ INVALID_ INPUT - An argument violates its contract.
- SEMQ_
ERR_ NOMEM - An allocation failed.
- SEMQ_
ERR_ UNSUPPORTED - The operation or FP environment is not supported.
- SEMQ_
FIELD_ DIM - SEMQ_
FIELD_ OPERATOR - SEMQ_
FIELD_ P1 - scale, sectors or bins.
- SEMQ_
FIELD_ P2 - SEMQ_
FILE_ VERSION - File format version written and accepted by this core.
- SEMQ_
ID_ MAX_ BYTES - Largest
utf8id, in bytes. Ids are at least one byte. - SEMQ_
ID_ U64 - SEMQ_
ID_ UTF8 - SEMQ_
LIST_ ADDED - SEMQ_
LIST_ CHANGED - SEMQ_
LIST_ REMOVED - SEMQ_
MANIFEST_ KEY_ MAX - SEMQ_
MANIFEST_ MAX_ PAIRS - Manifest limits.
- SEMQ_
MANIFEST_ SECTION_ MAX - SEMQ_
MANIFEST_ VALUE_ MAX - SEMQ_
MAX_ DIM - Largest accepted vector dimension.
- SEMQ_
NONE - Sentinel for “no row” / “no field” in
semq_error_tand index lookups. - SEMQ_OK
- SEMQ_
ORBIT - SEMQ_
PHASE - SEMQ_
QUANT - SEMQ_
REASON_ CHANGED_ RATIO - SEMQ_
REASON_ ENCODER - SEMQ_
REASON_ HAMMING - SEMQ_
REASON_ NO_ COMMON_ ROWS - SEMQ_
REASON_ REMOVED_ ROWS - SEMQ_
REASON_ ROW_ ABOVE_ MAX - SEMQ_
RULE_ REVISION - Operator rule revision written into every config (
p2). - SEMQ_
SECTION_ CONFIG - SEMQ_
SECTION_ FOOTER - SEMQ_
SECTION_ FRAMING - SEMQ_
SECTION_ IDS - SEMQ_
SECTION_ MANIFEST - SEMQ_
SECTION_ ROWS - SEMQ_
SECTION_ SIZES - SEMQ_
WHICH_ CONTENT - SEMQ_
WHICH_ NONE - SEMQ_
WHICH_ STATE
Functions§
- semq_
backend_ ⚠name - Effective kernel for an operator on this host (“scalar”, “neon”, …).
- semq_
build_ ⚠id - Compile-time build recipe identifier. Not a provenance proof.
- semq_
codec_ ⚠backend - Name of the kernel this codec runs (“scalar”, “neon”, “avx2”, …).
- semq_
codec_ ⚠config - semq_
codec_ ⚠create - semq_
codec_ ⚠decode - Representatives,
n x dimfloat32, rowiforids[i]. - semq_
codec_ ⚠encode - semq_
codec_ ⚠free - semq_
codec_ ⚠unpack - Symbols,
n x units_per_rowbytes, one per unit. - semq_
config_ ⚠bytes_ per_ vector - semq_
config_ ⚠equal - 1 when the two configs have the same canonical bytes.
- semq_
config_ ⚠from_ bytes - Parse a 13-byte canonical form.
- semq_
config_ ⚠max_ magnitude - quant only:
(float)(2.0 / sqrt((double)dim)); 0 for other operators. - semq_
config_ ⚠orbit - semq_
config_ ⚠phase - semq_
config_ ⚠quant - semq_
config_ ⚠to_ bytes - Write the 13-byte canonical form.
cfgmust be valid. - semq_
config_ ⚠units_ per_ row - semq_
config_ ⚠validate - semq_
core_ ⚠version - Core version string, from the repository
VERSIONfile. - semq_
diff_ ⚠candidate_ id - semq_
diff_ ⚠config - semq_
diff_ ⚠count - semq_
diff_ ⚠evaluate - With
checks == 0,passedequalssemq_diff_within; an unknown bit isSEMQ_ERR_INVALID_INPUT.SEMQ_ERR_INCOMPATIBLEfor a floor of another context, or forSEMQ_CHECK_PER_ROWon a floor withoutmax_hamming. - semq_
diff_ ⚠free - The Diff keeps both Encodings alive until it is freed.
- semq_
diff_ ⚠hamming - Hamming distance of changed id
i(units whose symbol differs). - semq_
diff_ ⚠id - Id
iof a list, in canonical order. Foru64kinds*out_u64is set; forutf8kinds*bytes/*lenare set. - semq_
diff_ ⚠id_ kind - semq_
diff_ ⚠manifest_ change - semq_
diff_ ⚠manifest_ changes - semq_
diff_ ⚠n_ unchanged - semq_
diff_ ⚠reference_ id - semq_
diff_ ⚠units_ u64 - Differing units of an id present on both sides. Writes up to
capentries and the total count into*count. Passcap = 0to query. - semq_
diff_ ⚠units_ utf8 - semq_
diff_ ⚠within *out = 1iff the diff is within the floor (exact integer arithmetic). The floor must match the diff’s config, id kind and reference state_id (SEMQ_ERR_INCOMPATIBLEotherwise).- semq_
encoding_ ⚠concat - Merge
kEncodings with the same config, id kind and manifest and pairwise-disjoint ids. - semq_
encoding_ ⚠config - semq_
encoding_ ⚠content_ digest - semq_
encoding_ ⚠create - semq_
encoding_ ⚠diff reference.diff(candidate).- semq_
encoding_ ⚠file_ size - Total size of the file image.
- semq_
encoding_ ⚠find_ u64 - Row index of an id, or
SEMQ_NONEwhen absent. - semq_
encoding_ ⚠find_ utf8 - semq_
encoding_ ⚠free - semq_
encoding_ ⚠id_ kind - semq_
encoding_ ⚠ids_ u64 - Sorted ids.
u64kinds:nvalues. - semq_
encoding_ ⚠ids_ utf8_ bytes utf8kinds: the id bytes.- semq_
encoding_ ⚠ids_ utf8_ offsets utf8kinds:n + 1offsets.- semq_
encoding_ ⚠len - semq_
encoding_ ⚠load - Parse a complete file image. The bytes are copied.
- semq_
encoding_ ⚠manifest_ len - Manifest pairs in canonical (bytewise key) order.
- semq_
encoding_ ⚠manifest_ pair - semq_
encoding_ ⚠rows - Rows in id order,
n x bytes_per_vectorbytes. - semq_
encoding_ ⚠save - Write the whole file image into
out(cap>= file size). - semq_
encoding_ ⚠save_ parts - The file image as 5 ordered parts owned by the handle. Returns 5.
- semq_
encoding_ ⚠state_ id - semq_
floor_ ⚠changed_ rows - semq_
floor_ ⚠config - The config, owned by the handle.
- semq_
floor_ ⚠create - A floor from its fields.
configmust validate,id_kindmust be 0 or 1,reference_idis 32 bytes,nulls >= 1,total_rows >= 1,changed_rows <= total_rowsandhamming <= units_per_row(config); otherwiseSEMQ_ERR_INVALID_INPUT. - semq_
floor_ ⚠distinct_ nulls - Distinct null states among the nulls;
SEMQ_NONEwhen not recorded. - semq_
floor_ ⚠free - semq_
floor_ ⚠hamming - semq_
floor_ ⚠id_ kind - 0 = u64, 1 = utf8.
- semq_
floor_ ⚠json_ size - Length in bytes of the floor’s JSON form.
- semq_
floor_ ⚠load - Reads a floor from its JSON form; strict on the schema’s keys, other
keys ignored.
SEMQ_ERR_INVALID_INPUTon any violation. - semq_
floor_ ⚠max_ hamming SEMQ_NONEfor a floor without per-row data.- semq_
floor_ ⚠measure - Envelope of
k >= 1null diffs; every input diff is within the result. All nulls must share config, id kind and reference state_id (SEMQ_ERR_INCOMPATIBLE,field= the offending index) and each must be a valid null (SEMQ_ERR_INVALID_INPUT,field= index). - semq_
floor_ ⚠measure_ for semq_floor_measurethat also records what thechecks(SEMQ_CHECK_*flags) need: withSEMQ_CHECK_PER_ROW,max_hamminganddistinct_nulls. An unknown bit isSEMQ_ERR_INVALID_INPUT.- semq_
floor_ ⚠nulls - semq_
floor_ ⚠reference_ id - Writes the 32-byte state_id of the reference into
out. - semq_
floor_ ⚠save - Writes the floor’s JSON form into
out(cap >= semq_floor_json_size). - semq_
floor_ ⚠total_ rows - semq_
sha256 ⚠ - SHA-256 (FIPS 180-4) of
lenbytes. - semq_
status_ ⚠name - Static name of a status code (“ok”, “invalid_input”, …).
- semq_
verdict_ ⚠free - semq_
verdict_ ⚠passed - semq_
verdict_ ⚠reasons SEMQ_REASON_*flags; 0 when the verdict passed.- semq_
verdict_ ⚠row - Index in the diff’s changed list;
SEMQ_NONEwhen out of range. - semq_
verdict_ ⚠row_ count
Type Aliases§
- semq_
check_ t - Checks beyond those of
semq_diff_within: flags combined with|, forsemq_floor_measure_forandsemq_diff_evaluate. - semq_
config_ field_ t - Config fields named by
fieldinSEMQ_ERR_INVALID_INPUTerrors raised by the config constructors. - semq_
id_ kind_ t - Identifier kinds. Values are pinned: they appear in files.
- semq_
list_ t - Which id list of a Diff an accessor refers to.
- semq_
operator_ t - Operators. Values are pinned: they appear in the canonical config form.
- semq_
reason_ t - Why a verdict failed: flags combined with
|. - semq_
section_ t - File sections named by
fieldinSEMQ_ERR_FORMATerrors. - semq_
status_ t - Status codes. Each maps to exactly one host error type.
- semq_
which_ t - Which integrity check failed on load.