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-rs
cargo add serde
cargo add tokio

Quick Start

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

// Define your data structures #[derive(Serialize)]
struct UserInput {
    name: String,
    age: i32,
}

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

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

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

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

    // Run the query
    let result: Result = client.query::<AddUserInput, Result>("add_user", &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), Some("my-api-key")); // Uses port 8080