IndexCoretrait — the object-safe operational surface (insert,delete,search,len,dim,metric,flush,stats). The engine holds indexes asBox<dyn IndexCore>.Indextrait — typed construction: an associatedConfigand anew(dim, metric, config). Split out fromIndexCorebecause aSelf-returning constructor is not object-safe.- Associated
Config— each index exposes its own parameter struct, not a god-config enum. - Default batch shims —
insert_batch/search_batchship for free and are overridable when a backend has a vectorized fast path. IndexStats— uniform, allocation-light introspection across index types.- Documented contracts — best-first ordering (with the
DotProductnegation rule), deletion visibility, and theSend + Syncconcurrency model live on the trait, so every backend agrees.
Installation
[]
= "0.2"
Quick Start
Implement the two traits for your index, then construct, insert, and search
through one uniform surface. The full runnable version is in
examples/custom_index.rs.
use Arc;
use ;
use ;
// `FlatIndex` implements `IndexCore` + `Index` (see the example).
let mut index = new?;
index.insert_batch?;
let hits = index.search?;
assert_eq!; // best-first
// Hold any backend behind the object-safe trait:
let engine: = vec!;
assert_eq!;
The three tiers
| Tier | Surface | When |
|---|---|---|
| Tier 1 | Index::new + the IndexCore operations |
Build an index and use it. |
| Tier 2 | Index::Config |
Tune a specific backend. |
| Tier 3 | implement IndexCore + Index |
Add a new index strategy. |
Status
v0.2.0 — the load-bearing trait surface. IndexCore, Index, IndexStats, and the default batch shims are implemented and documented with runnable examples; the contract is validated by a brute-force reference index across a property-test suite (best-first ordering, deletion visibility, batch == loop). The remaining 0.x work — refining the trait against the real iqdb-flat / iqdb-hnsw / iqdb-ivf consumers, then the API freeze — is tracked in the ROADMAP. Full surface in docs/API.md.
Where It Fits
iqdb-index is the interface every index speaks. It is implemented by:
iqdb-types— the only dependencyiqdb-flat/iqdb-hnsw/iqdb-ivf— implement this traitiqdb-build/iqdb-eval/iqdb— are generic over it
Designing this trait so flat, HNSW, and IVF all fit cleanly is the crate's whole job.
Contributing
See dev/DIRECTIVES.md for engineering standards and the definition of done. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.