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

Add this to your Cargo.toml:

cargo add helix-db

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() -> anyhow::Result<()> {
    // Initialize the client
    let client = HelixDB::new(None); // Uses default port 6969

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

    let result: UserOutput = client.query("addUser", &input).await?;
    println!("Created user with ID: {}", result.id);
    Ok(())
}

Configuration

Custom Port

You can specify a custom port when initializing the client:

let client = HelixDB::new(Some(8080)); // Uses port 8080

Custom Client

You can implement your own client by implementing the HelixDBClient trait:

use helix_rs::HelixDBClient;

struct MyCustomClient {
    // Your implementation details
}

impl HelixDBClient for MyCustomClient {
    fn new(port: Option<u16>) -> Self {
        // Your initialization logic
    }

    async fn query<T, R>(&self, endpoint: &str, data: &T) -> anyhow::Result<R>
    where
        T: Serialize,
        R: for<'de> Deserialize<'de>
    {
        // Your query implementation
    }
}

Requirements

  • Rust 1.56 or higher
  • Running HelixDB instance
  • Tokio runtime for async operations