helix-rs

Crates.iohelix-rs
lib.rshelix-rs
version0.1.10
created_at2025-07-14 09:47:57.419565+00
updated_at2025-11-11 18:51:44.075837+00
descriptionRust SDK for HelixDB
homepage
repositoryhttps://github.com/HelixDB/helix-rs
max_upload_size
id1751453
size68,934
Xav (xav-db)

documentation

README

helix-rs

A Rust SDK for interacting with HelixDB - providing a simple, type-safe interface for database operations.

Features

  • Type-safe query interface using Serde serialization/deserialization
  • Async/await support
  • Configurable port settings
  • Custom client implementation support via HelixDBClient trait

Quick Start

cargo add helix-rs
cargo add serde
cargo add tokio
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
    
    let input = AddUserInput {
        name: "John".to_string(),
        age: 20,
    };

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

    let result = client.query::<UserInput, Result>("add_user", &input).await?;
    println!("Created user with ID: {}", result.user.id);
    Ok(())
}

Configuration

Custom Port

You can specify a custom port when initializing the client:

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

Custom Client

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

use helix_rs::{HelixDBClient, HelixError};

struct MyCustomClient {
    // Your implementation details
}

impl HelixDBClient for MyCustomClient {
    type Err = HelixError;
    fn new(endpoint: Option<&str>, port: Option<u16>, api_key: Option<&str>) -> Self {
        // Your initialization logic
    }

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

Requirements

  • Rust 1.88.0 or higher
  • Running HelixDB instance
  • Tokio runtime for async operations
Commit count: 33

cargo fmt