Expand description
§KeraDB Rust SDK
A MongoDB-compatible Rust client for KeraDB — a lightweight, embedded NoSQL document database with advanced vector search capabilities.
§Usage
use keradb_sdk::*;
use serde_json::json;
// Open / create a database
let mut client = connect("mydb.ndb").unwrap();
let db = client.database();
let users = db.collection("users");
// Insert
let result = users.insert_one(json!({"name": "Alice", "age": 30})).unwrap();
println!("Inserted: {}", result.inserted_id);
// Find
let doc = users.find_one(Some(&json!({"_id": result.inserted_id}))).unwrap();
println!("Found: {:?}", doc);
// Update
users.update_one(
&json!({"_id": result.inserted_id}),
&json!({"$set": {"age": 31}}),
).unwrap();
// Delete
users.delete_one(&json!({"_id": result.inserted_id})).unwrap();
client.close();§Vector search
use keradb_sdk::*;
let mut client = connect("vectors.ndb").unwrap();
let config = VectorConfig::new(128)
.with_distance(Distance::Cosine)
.with_m(16)
.with_ef_construction(200);
client.create_vector_collection("embeddings", &config).unwrap();
let embedding: Vec<f32> = (0..128).map(|i| i as f32 / 128.0).collect();
let id = client.insert_vector("embeddings", &embedding, None).unwrap();
let results = client.vector_search("embeddings", &embedding, 5).unwrap();
for r in results {
println!("{}", r);
}
client.close();Re-exports§
pub use client::connect;pub use client::Client;pub use client::Collection;pub use client::Cursor;pub use client::Database;pub use error::KeraDbError;pub use error::Result;pub use results::DeleteResult;pub use results::InsertManyResult;pub use results::InsertOneResult;pub use results::UpdateResult;pub use vector::CompressionConfig;pub use vector::CompressionMode;pub use vector::Distance;pub use vector::MetadataFilter;pub use vector::VectorCollectionInfo;pub use vector::VectorCollectionStats;pub use vector::VectorConfig;pub use vector::VectorDocument;pub use vector::VectorSearchResult;
Modules§
- client
- MongoDB-compatible client, database, and collection types.
- error
- Error types for the KeraDB Rust SDK.
- ffi
- FFI bindings to the KeraDB native shared library.
- results
- MongoDB-compatible result types for KeraDB operations.
- vector
- Vector search types mirroring the Python SDK’s
vector.py.
Constants§
- VERSION
- SDK version string.