Expand description
Contract tables: a per-declaration fingerprint of each top-level module’s ABI.
A producer exports, for every top-level module m,
const {prefix}_contract_entry* {prefix}_{m}_contract(size_t* out_len):
a static table with one ContractEntry per declaration in m and its
submodules, sorted ascending by id. Every generated consumer checks, when
it loads the library, that each entry it was generated with is present in
the producer’s table with an equal hash. Extra producer entries are fine,
so adding a declaration never breaks a deployed binding, while removing
or changing one is reported by its dotted path.
entries is the one function that computes a table. The
#[weaveffi::module] macro, the CLI, and the C header generator all call
it on the validated Model, so the two sides agree by construction.
- The id is
fnv1a64of the declaration’s dotted path (kv.Store.put,kv.KvError,kv.stats.Summary). - The hash is
fnv1a64of a canonical signature string computed from the resolved model, never from source spelling: type aliases are already substituted,[u8]is alreadybytes, and every type is its resolved IDL spelling (seeTy’sDisplay). Docs, deprecation text, and error messages are excluded, and so is the order of sibling declarations, because each entry is independent.
The canonical strings are:
| Declaration | Signature |
|---|---|
| function or interface member | {kind} {name}({param}: {type}, ...) -> {type or void}, then throws, async, cancellable when set; kind is function, constructor, method, or static |
| record | record {name} {{field}: {type}, ...} |
| enum | enum {name} {{Variant} = {value}, ...}, a rich variant followed by {{field}: {type}, ...} |
| callback interface | callback {name} {{method}({param}: {type}, ...) -> {type or void}; ...}, a method followed by throws when set |
| error domain | errors {name} {{Code} = {value}, ...}, a code with fields followed by {{field}: {type}, ...} |
| interface | interface {name} (its members have their own entries) |
Structs§
- Contract
Entry - One declaration’s entry in a module’s contract table.