Rust SDK
kalam-client is the official KalamDB client for Rust. It wraps the shared link-common implementation with a Tokio-native API for services, CLIs, and background workers.
Status: Beta — the API may still change between releases.
| Resource | Link |
|---|---|
| crates.io | kalam-client |
| API reference | docs.rs/kalam-client |
| Source | github.com/kalamdb/KalamDB |
Current version: 0.5.2-rc.2 · MSRV: Rust 1.92+
What you can do
kalam-client focuses on the core app and worker workflows:
- Execute SQL over HTTP (
execute_query,execute_with_files) - Upload and download FILE column attachments (
FileRef,BoundFileRef,download_bound_file) - Open materialized live rows over WebSocket (
live,live_with_config) - Consume low-level subscription frames (
live_events,live_events_with_config) - Authenticate with JWT, basic login bootstrap, system-user auth, or dynamic providers (
AuthProvider,login,refresh_access_token) - Observe connection lifecycle (
EventHandlers) - Inspect active subscriptions (
subscriptions) - Control the shared WebSocket explicitly (
connect,disconnect,is_connected) - Poll and commit topic records when the
consumerfeature is enabled (client.consumer())
Optional feature-gated helpers:
health_check()with thehealthcheckfeaturecheck_setup_status()/server_setup()with thesetupfeaturecluster_health_check()with theclusterfeature
Installation
Enable optional capabilities as needed:
| Feature | Description |
|---|---|
native-sdk (default) | Tokio runtime, HTTP SQL, auth flows, live subscriptions |
consumer | TopicConsumer, ConsumerBuilder, poll/commit APIs |
file-uploads | execute_with_files multipart uploads and FILE downloads |
healthcheck | Cached health_check() helper |
setup | check_setup_status() and server_setup() |
cluster | cluster_health_check() |
native-full | All native features (CLI-oriented bundle) |
Quick start
Runnable examples: Examples.
For live() and live_events(), keep SQL strict: SELECT ... FROM ... WHERE .... Do not put ORDER BY or LIMIT in live subscription SQL.
Recommended reading order
- Setup & Quick Start
- Authentication
- Auth-Aware Client
- Querying & DML
- FILE Columns & Uploads
- Realtime Subscriptions
- Client Lifecycle
- Types & Models
- Cell Values (KalamCellValue)
- Server Setup & Diagnostics Boundary
- Transport & Endpoints
- Examples
Examples
Runnable crates ship under link/sdks/rust/examples/:
| Example | Docs |
|---|---|
| Quickstart — first SQL query | Quickstart |
| File Attachments — FILE upload and download | File Attachments |
Live Inbox — live() subscriptions | Live Inbox |
| Topic Consumer — poll and commit offsets | Topic Consumer |
See Examples overview for run commands and prerequisites.
Why live() first
Most UIs want the latest reconciled row list, not raw insert/update/delete frames.
live()/live_with_config()— materialized rows (recommended default)live_events()/live_events_with_config()— low-level protocol events
Use SubscriptionOptions::with_last_rows() to rewind recent history. Use LiveRowsConfig { limit: Some(n), .. } to cap the materialized set the client keeps.
Builder options
| Method | Description |
|---|---|
base_url(...) | Required KalamDB server URL |
auth(...) / jwt_token(...) / auth_provider(...) | Static or dynamic credentials |
timeout(...) | HTTP request timeout (default 30s) |
max_retries(...) | Retries for idempotent HTTP queries (default 3) |
connection_options(...) | WebSocket lazy connect, compression, keepalive |
timeouts(...) | Fine-grained receive/send timeouts |
event_handlers(...) | Connect/disconnect/error hooks |
auth_refresher(...) | Custom TOKEN_EXPIRED recovery callback |
Notes
base_url(...)is required on every builder.- Basic auth is exchanged for JWT before protected SQL or WebSocket work.
- HTTP queries work without
connect(). Callconnect()before live subscriptions. - Default
ConnectionOptionsusesws_lazy_connect: true— the socket opens on the first subscription. - Close live streams and consumers with
close()during shutdown.