hyperstack-sdk
Rust client SDK for connecting to HyperStack streaming servers.
Installation
[]
= "0.1"
TLS Options
By default, the SDK uses rustls for TLS. You can switch to native TLS:
[]
= { = "0.1", = false, = ["native-tls"] }
Quick Start
use ;
use StreamExt;
// Import from your generated SDK crate
use ;
async
API Reference
HyperStack Client
The main client for connecting to HyperStack servers.
// Simple connection
let hs = connect.await?;
// With configuration
let hs = builder
.url
.auto_reconnect
.max_reconnect_attempts
.ping_interval
.connect
.await?;
Core Methods
| Method | Description |
|---|---|
get::<E>(key) |
Get a single entity by key |
list::<E>() |
Get all entities of type E |
watch::<E>() |
Stream all updates for entity type E |
watch_key::<E>(key) |
Stream updates for a specific key |
connection_state() |
Get current connection state |
disconnect() |
Close the connection |
Entity Trait
The Entity trait is implemented by generated SDK code for type-safe access:
Update Types
When streaming, you receive typed Update<T> variants:
Helper methods:
update.key // Get the entity key
update.data // Get data (Some for Upsert/Patch, None for Delete)
update.is_delete // Check if this is a deletion
Generating a Rust SDK
Use the HyperStack CLI to generate a typed Rust SDK from your spec:
# Generate SDK crate
# With custom output directory
# With custom crate name
This generates a crate with:
generated/settlement-game-stack/
├── Cargo.toml
└── src/
├── lib.rs # Re-exports
├── types.rs # Data structs (SettlementGame, Player, etc.)
└── entity.rs # Entity trait implementations
Add the generated crate to your Cargo.toml:
[]
= "0.1"
= { = "./generated/settlement-game-stack" }
Then use it:
use HyperStack;
use ;
let hs = connect.await?;
let game = hs..await;
Connection Management
Auto-Reconnection
The SDK automatically reconnects on connection loss with exponential backoff:
let hs = builder
.url
.auto_reconnect
.reconnect_intervals
.max_reconnect_attempts
.connect
.await?;
Connection State
Monitor connection health:
let state = hs.connection_state.await;
match state
Streaming Modes
| Mode | View | Description |
|---|---|---|
| State | Entity/state |
Single shared state object |
| KV | Entity/kv |
Key-value lookups by entity key |
| List | Entity/list |
All entities matching filters |
| Append | Entity/append |
Append-only event log |
Examples
See the examples/ directory for complete examples:
- flip/ - Flip game state tracking
- pump/ - Token launch and trade monitoring
Run examples with:
License
MIT