Skip to content

HelixDB/helix-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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

Installation

Add this to your Cargo.toml:

[dependencies]
helix-rs = "0.1.0"

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

About

Rust SDK to use HelixDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages