Geode Rust Client
A high-performance async Rust client library for Geode graph database with full GQL (ISO/IEC 39075:2024) support via QUIC+TLS.
Features
- 🚀 Fully async using tokio with type safety
- 🔒 QUIC + TLS 1.3 for secure, high-performance networking
- 📝 Full GQL support (98.6% ISO compliance)
- 🏗️ Query builders for programmatic query construction
- 🔐 Complete authentication with RBAC and RLS support
- 🏊 Connection pooling for concurrent workloads
- 📊 Rich type system with Decimal, temporal types
- 🎯 Type-safe with Rust's strong type system and zero-cost abstractions
Installation
Install from crates.io:
Or add to your Cargo.toml:
[]
= "0.1.1-alpha.4"
= { = "1", = ["full"] }
Requirements
- Rust 1.70+
- quinn >= 0.10 (QUIC support)
- tokio runtime
- Running Geode server with QUIC enabled
Quick Start
Basic QUIC Connection
use ;
async
Query with Parameters
use HashMap;
let mut params = new;
params.insert;
params.insert;
let page = conn.query.await?;
Using Query Builder
use QueryBuilder;
let = new
.match_pattern
.where_clause
.return_
.order_by
.limit
.with_param
.build;
let page = conn.query.await?;
Transactions
conn.begin.await?;
match conn.query.await
Savepoints (Partial Rollback)
conn.begin.await?;
// Create initial data
conn.query.await?;
// Create a savepoint
let sp = conn.savepoint?;
// Make changes
conn.query.await?;
// Rollback to savepoint (undoes the age change)
conn.rollback_to.await?;
// Alice's age is still 30
conn.commit.await?;
Connection Pooling
use ConnectionPool;
// Create connection pool
let pool = new
.skip_verify
.page_size;
// Acquire connection from pool
let conn = pool.acquire.await?;
let page = conn.query.await?;
// Connection automatically returns to pool when dropped
println!;
Prepared Statements
use PreparedStatement;
// Create a prepared statement
let stmt = conn.prepare?;
// Execute multiple times with different parameters
for id in 1..=100
Query Explain and Profile
// Get the execution plan without running the query
let plan = conn.explain.await?;
println!;
for op in &plan.operations
// Execute with profiling to get actual timing
let profile = conn.profile.await?;
println!;
println!;
Batch Queries
// Execute multiple queries efficiently
let results = conn.batch.await?;
for in results.iter.enumerate
Connection Configuration
The client uses a builder pattern for configuration:
let client = new // host and port
.skip_verify // Skip TLS verification (development only)
.page_size // Results page size
.client_name // Client name for server logs
.client_version // Client version
.conformance // GQL conformance level
.username // Authentication username
.password; // Authentication password
DSN Connection String
You can also create a client from a DSN (Data Source Name) string:
use Client;
// Simple DSN
let client = from_dsn.unwrap;
// With options
let client = from_dsn.unwrap;
// URL format with authentication
let client = from_dsn.unwrap;
Supported DSN options:
page_size- Results page size (default: 1000)hello_name- Client name (default: "geode-rust-quinn")hello_ver- Client version (default: "0.1.0")conformance- GQL conformance level (default: "min")insecure- Skip TLS verification (true/false, default: false)usernameoruser- Authentication usernamepasswordorpass- Authentication password
Configuration Options
skip_verify(bool)- Skip TLS certificate verification (default: false, insecure)page_size(usize)- Results page size (default: 1000)client_name(String)- Client name sent to server (default: "geode-rust")client_version(String)- Client version (default: "0.1.0")conformance(String)- GQL conformance level (default: "min")username(String)- Authentication username (optional)password(String)- Authentication password (optional)
Query Builders
QueryBuilder
Build queries programmatically:
let = new
.match_pattern
.where_clause
.return_
.order_by
.limit
.build;
PatternBuilder
Build graph patterns:
use ;
let pattern = new
.node
.edge
.node
.build;
Type System
The client provides a rich type system supporting all GQL data types:
use ;
let value = row.get.unwrap;
// Type-safe access with Result
let int_val = value.as_int?;
let str_val = value.as_string?;
let bool_val = value.as_bool?;
let decimal_val = value.as_decimal?;
let array_val = value.as_array?;
let object_val = value.as_object?;
let date_val = value.as_date?;
let timestamp_val = value.as_timestamp?;
// Check value kind
match value.kind
// Create values programmatically
let int_value = int;
let str_value = string;
let bool_value = bool;
let array_value = array;
Supported Types
| Type | Rust Type | Description |
|---|---|---|
Null |
() |
SQL NULL |
Int |
i64 |
64-bit integer |
Bool |
bool |
Boolean |
String |
String |
UTF-8 string |
Decimal |
rust_decimal::Decimal |
Arbitrary precision decimal |
Array |
Vec<Value> |
Ordered collection |
Object |
HashMap<String, Value> |
Key-value map |
Date |
chrono::NaiveDate |
Calendar date |
Timestamp |
chrono::DateTime<Utc> |
Date and time |
Bytea |
Vec<u8> |
Binary data |
Error Handling
The client provides comprehensive error types with retry support:
use ;
async
Error Types
| Error | Retryable | Description |
|---|---|---|
Connection |
Yes | Network/QUIC connection issues |
Query |
Conditional | Query execution errors (40001, 40P01, 40502 are retryable) |
Timeout |
Yes | Operation timed out |
Pool |
Yes | Connection pool exhausted |
Auth |
No | Authentication failure |
Tls |
No | TLS/certificate errors |
Validation |
No | Input validation failure |
Type |
No | Type conversion errors |
Validation
The client provides input validation utilities:
use validate;
// Validate queries before sending
query?;
// Validate parameter names
param_name?;
// Validate connection parameters
hostname?;
port?;
page_size?;
Examples
The client includes comprehensive examples demonstrating all features:
examples/basic.rs- Simple connection and queriesexamples/advanced.rs- Advanced features and patternsexamples/transactions.rs- Transaction management with savepoints
Run examples:
Development
# Build
# Run tests
# Run benchmarks
# Run fuzzing (requires nightly)
# Code quality
# Run examples
Testing
The library includes comprehensive testing:
| Test Type | Count | Command |
|---|---|---|
| Unit tests | 274 | cargo test |
| Property tests | 28 | cargo test --test proptest |
| Integration tests | 36 | cargo test --features integration |
| Benchmarks | 59 | cargo bench |
| Fuzz targets | 4 | cargo +nightly fuzz run <target> |
Running Integration Tests
Integration tests require a running Geode server:
# Terminal 1: Start Geode
&&
# Terminal 2: Run integration tests
Benchmarks
Benchmarks measure performance of key operations:
# Run all benchmarks
# Sample output:
# value_creation/int time: [5.2 ns]
# query_builder/complex time: [198 ns]
# decimal_parsing/4_places time: [8.3 ns]
Performance
The QUIC client provides:
- Low latency: ~1-2ms per query (localhost)
- High throughput: 10,000+ queries/second with connection pooling
- Zero-cost abstractions: Minimal overhead from Rust's type system
- Concurrent: Full async support for parallel queries
System-Level QUIC Optimizations
For optimal QUIC throughput on high-bandwidth connections, configure UDP buffer sizes at the OS level.
Linux:
# Increase UDP buffer sizes to 7MB
# Persist across reboots
|
|
BSD/macOS:
GSO (Generic Segmentation Offload): Automatically enabled on Linux 4.18+ by quinn. Batches UDP packets to reduce syscall overhead.
Path MTU Discovery (DPLPMTUD): Enabled by default in quinn, probes for optimal packet sizes to reduce per-packet overhead.
Troubleshooting
Connection Refused
Ensure Geode server is running with QUIC enabled:
TLS Verification Errors
For development, you can skip verification:
let client = new.skip_verify;
For production, ensure proper TLS certificates are configured on the server.
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork and clone the repository
- Create a feature branch from
main - Write tests for new functionality
- Run the test suite:
cargo test - Run clippy:
cargo clippy(must produce 0 warnings) - Format code:
cargo fmt - Submit a pull request
Code Quality Standards
- All public APIs must have rustdoc comments
- New features require unit tests
- Integration tests for server-facing changes
- Property-based tests for parsers/converters
- Benchmarks for performance-critical code
Development Setup
# Clone the repository
# Install development tools
# Run full test suite
License
Apache License 2.0 - see LICENSE file for details.
Related
- Geode Database - Main Geode project
- Python Client - Official Python client
- Go Client - Official Go client
- crates.io - Package on crates.io
- docs.rs - API documentation