Expand description
Vector index backend trait.
This trait is the abstraction layer over the concrete ANN backend (hnsw_rs
or usearch). It exposes a stable interface that the rest of the crate
(search.rs, hnsw_ops.rs, config.rs, lib.rs) uses, so that switching the
backend is a matter of which impl is wired in at the hnsw_ops::rebuild_*
and HnswIndex factory call sites.
§Design notes
- The
VectorBackendtrait is intentionally minimal: just enough surface to satisfy the 8 call sites that currently use hnsw_rs. - All backends return
Result<_, MemoryError>so error handling at the trait boundary doesn’t leak backend-specific error types. HnswHitis renamed toVectorHitin the trait surface, but a type aliaspub type HnswHit = VectorHit;is preserved for source compatibility with downstream consumers.HnswConfigis kept as the user-facing config name (it’s a public type). The trait receives aVectorIndexConfiginternally; theFrom<HnswConfig>impl bridges them.
§Backend implementations
HnswBackend(inhnsw_backend.rs, gated onfeature = "hnsw"): the existing hnsw_rs 0.3 wrapper, behavior-preserving.UsearchBackend(inusearch_backend.rs, gated onfeature = "usearch-backend"): the new cxx-bridge to usearch 2.25. This file is the destination of the migration; until it’s wired in it is a stub that returns MemoryError::Unimplemented.
§Backwards compatibility
HnswIndex is renamed to VectorIndex (a thin newtype around
Arc<dyn VectorBackend + Send + Sync>). The old name is preserved as a
deprecated type alias to avoid breaking downstream consumers like
forge-pilot, llm-pipeline, and kernel-conformance that import
semantic_memory::hnsw::HnswIndex directly.
Structs§
- Vector
Hit - User-facing hit from a vector search.
- Vector
Index - Thread-safe handle to a vector index.
- Vector
Index Config - Configuration for the vector index.
Traits§
- Vector
Backend - Core vector index operations. All concrete backends implement this.