Rust

USearch for Rust

cargo add usearch 3.0.0-rc.1 · 4c3e5023

The crate links the pre-instantiated C library and calls the stable C ABI in c/usearch/ through extern "C" declarations, so no index template is instantiated in your build. It needs Rust 1.100 or newer, CMake 3.28 and a C++20 compiler. It exposes dense indexes; sequence, matrix and geospatial indexes follow as the C library ships them. Detailed symbol documentation lives on docs.rs.

Topics

InstallationCMake builds the engine from the crate's sources and links it as a static archive.
QuickstartEvery batch input is a NumKong matrix of a base pointer, a row count and a byte stride, so a memory-mapped dataset feeds the index with no reshape and no copy.
Executors36An executor owns host threads or device streams, and the traversal scratch each of them walks with, grown to a high-water mark.
Keys2A Key is a 128-bit identity, rendered as a lowercase dashed UUID.
Inputs and Outputs33Every output whose length only the call knows, such as matches, rows, products, monoliths and cursor or stream batches, lands in an Arena you pass, and the verb answers a view over it without copying.
Metrics37A DenseIndex holds equidimensional dense vectors, built from DenseOptions: dimensions, metric, the stored quantization, and the connectivity and valuesperkey bounds, where zero derives.
Residency1Where the payload lives is the constructor's name, as in the C lifecycle verbs, so a residency an index lacks has no constructor to call.
Serialization10The path extension picks the layout: a .safegraphs path is one monolith, and a .safegraphs.json path is a manifest cataloging many.
Filtered Search2Cross-referencing an external database during traversal beats paging through results and filtering afterwards.
Refinement4refine re-runs the neighbor selection over entries already in the graph and returns a RefineReport of the nodes re-selected, those whose neighbors changed, the islands found and reconnected, and the reachability audit closing the heal, so a batch built at a low expansion factor reaches the quality of a slower build afterwards.
Linear Algebra10multiply, maxsim and attend treat the index as a sparse operand rather than as a kNN store, and each folds its arithmetic into the graph walk instead of materializing a match list.
Retrieval and Streaming19get lands every vector stored under a key in an arena, converted to the scalar type you name, one row per entry in insertion order; an absent key yields no rows.
Introspection7describe reads the frozen metadata and the counters once each, so under concurrent insertions they may come from slightly different moments, and memoryusage excludes the executor's scratch.
Errors3Every fallible call returns usearch::Result, whose Error carries a Status and a static message, so nothing allocates on the failure path.
Platform Notes