scann-core (Rust)
Rust bindings for scann-core: the nearest-neighbour search core of Google's ScaNN, as a standalone library.
scann-core is a derived work of ScaNN. It is not an official Google product and is not affiliated with or endorsed by Google.
use ;
let index = new
.tree
.score_ah
.reorder
.build_index?; // &[f32], row-major n x dim
let nn = index.search?;
println!;
ScannIndex supports single, batched and parallel batched search, adding,
updating and deleting points, retraining, and saving and loading. Indexes are
interchangeable with scann-core's C++ and Python APIs (and upstream ScaNN's
Python package). It is Send + Sync: search from as many threads as you
like; changing the index takes &mut self.
Building
The crate builds the C++ library with CMake the first time it compiles, so you need:
- CMake ≥ 3.27 and clang ≥ 19 or GCC ≥ 13 (clang is preferred
when
CXXisn't set); - Linux on x86-64 or aarch64 (both tested in CI);
- network access to download the C++ dependencies (abseil, protobuf,
highway, Eigen, zlib). To build offline, point CMake at local copies:
SCANN_CORE_CMAKE_ARGS="-DFETCHCONTENT_SOURCE_DIR_ABSL=/src/abseil-cpp ..."(see the repository README).
The first build takes a few minutes; later builds in the same target
directory reuse it. Each target directory (another project, CI, cargo install) builds the C++ library again; a compiler cache makes those
rebuilds cheap, since CMake picks up the launcher from the environment:
# hits across different target directories
(sccache works the same way.) The baseline
instruction set is AVX + FMA on x86-64 and Armv8 Neon on aarch64; faster
kernels (AVX2/AVX-512, SVE) are picked at run time when the CPU has them.
SCANN_CORE_CMAKE_ARGS="-DSCANN_ARCH_FLAGS=-march=native" also lets the
compiler use everything your CPU has for the rest of the code.
Documentation
- API docs:
cargo doc --open, or docs.rs/scann-core. - A seven-part tutorial with Python, C++ and Rust: docs/tutorial.
License
Apache 2.0. ScaNN is Copyright The Google Research Authors; scann-core's additions and modifications are Copyright 2026 Elias Benali (@ebenali) and TheCleaners. See NOTICE.