| Crates.io | helix-rs |
| lib.rs | helix-rs |
| version | 0.1.10 |
| created_at | 2025-07-14 09:47:57.419565+00 |
| updated_at | 2025-11-11 18:51:44.075837+00 |
| description | Rust SDK for HelixDB |
| homepage | |
| repository | https://github.com/HelixDB/helix-rs |
| max_upload_size | |
| id | 1751453 |
| size | 68,934 |
A Rust SDK for interacting with HelixDB - providing a simple, type-safe interface for database operations.
HelixDBClient traitcargo 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(())
}
You can specify a custom port when initializing the client:
let client = HelixDB::new(None, Some(8080), None); // Uses port 8080
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
}
}