zvec-bindings 0.1.1

Idiomatic Rust bindings for zvec vector database
docs.rs failed to build zvec-bindings-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

zvec-bindings

Rust License

Idiomatic Rust bindings for zvec, an open-source in-process vector database built on Alibaba's Proxima engine.

Features

  • Full API coverage matching the Python bindings
  • Safe Rust API with proper error handling (Result<T, Error>)
  • Support for dense and sparse vectors
  • HNSW, IVF, and FLAT index types
  • Static linking for easy deployment
  • Optional thread-safe API via sync feature

Installation

Add to your Cargo.toml:

[dependencies]
zvec-bindings = "0.1"

Prerequisites

  • Linux x86_64 or macOS ARM64
  • CMake 3.13+
  • C++17 compiler (GCC 9+ or Clang 10+)
  • Rust 1.70+

Usage

Basic Example

use zvec_bindings::{create_and_open, CollectionSchema, Doc, VectorQuery, VectorSchema};

fn main() -> zvec_bindings::Result<()> {
    // Create schema with a vector field
    let mut schema = CollectionSchema::new("example");
    schema.add_field(VectorSchema::fp32("embedding", 128).into())?;
    
    // Create and open collection
    let collection = create_and_open("./my_vectors", schema)?;
    
    // Insert documents
    let mut doc = Doc::id("doc_1");
    doc.set_vector("embedding", &[0.1, 0.2, 0.3, /* ... */])?;
    collection.insert(&[doc])?;
    
    // Search
    let query = VectorQuery::new("embedding")
        .topk(10)
        .vector(&[0.4, 0.3, 0.2, /* ... */])?;
    
    let results = collection.query(query)?;
    for doc in results.iter() {
        println!("score={:.4}", doc.score());
    }
    
    Ok(())
}

Thread-Safe Usage (Feature: sync)

For multi-threaded applications, enable the sync feature:

[dependencies]
zvec-bindings = { version = "0.1", features = ["sync"] }

Feature Flags

Feature Description
sync Enables SharedCollection for thread-safe multi-threaded access
static Statically links the zvec C++ library

API Coverage

  • Collection operations: create_and_open, open, flush, destroy
  • DML: insert, upsert, update, delete, delete_by_filter
  • DQL: query, group_by_query, fetch
  • DDL: create_index, drop_index, optimize
  • Index types: HNSW, IVF, FLAT, INVERT
  • Data types: scalar types, dense vectors, sparse vectors

License

Apache-2.0