helix-rs is a Rust library for interacting with helix-db a powerful graph-vector database written in rust. It enables intuitive and type-safe access to graph-based and vector-based queries, making it ideal for building knowledge graphs, search systems, and LLM pipelines.

Installation

cargo add helix-db

Quick Start

use helix_db::HelixDB;
use serde::{Serialize, Deserialize};

// Define your data structures based on the schema
#[derive(Serialize)]
struct AddUserInput {
    name: String,
    age: i32,
}

#[derive(Deserialize)]
struct AddUserOutput {
    id: String,
    name: String,
    age: i32,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize the client
    let client = HelixDB::new(None, None); // Uses default endpoint and port http://localhost:6969

    // Create a user
    let input = AddUserInput {
        name: "John".to_string(),
        age: 20,
    };

    // Define the output structure
    #[derive(Deserialize)]
    struct Result {
        user: AddUserOutput,
    }

    // Run the query
    let result: Result = client.query::<AddUserInput, Result>("addUser", &input).await?;

    println!("Created user with ID: {}", result.user.id);

    Ok(())
}

Configuration

Custom Endpoint and Port

You can specify a custom endpoint and port when initializing the client:

let client = HelixDB::new(Some("https://my-endpoint.com"), Some(8080)); // Uses port 8080