Statelet Rust SDK
Async Rust gRPC client for the Statelet distributed key-value store.
Add to Cargo.toml
[]
= { = "https://github.com/stateletlab/statelet-sdk", = "main" }
= { = "1", = ["rt-multi-thread", "macros"] }
Usage
use ;
async
Declarative graph query (openCypher subset)
Read-only pattern matching over the temporal graph, served by the gateway's
GraphQuery RPC: MATCH path patterns, WHERE on node properties,
RETURN / ORDER BY / LIMIT, a bitemporal AS OF <valid>[, <tx>] clause and
the retrieval procedures db.vectorSearch / db.hybridSearch / db.graphRag.
CREATE / MERGE are rejected.
use ;
let res = client
.graph_query
.await?;
println!; // ["m", "old"]
for row in &res.rows
println!; // non-empty ⇒ the result may be incomplete
// Time travel + vector-seeded expansion (inline query vector: named
// parameters like $q parse but are not resolvable yet).
let res = client
.graph_query
.await?;
Reranking (optional second stage)
A first-class, optional second-stage reranker over an over-fetched candidate
window — the analogue of Weaviate .with_additional({rerank}) and Pinecone
inference.rerank. See docs/reranking.md.
use RerankSpec;
// Cross-encoder: hydrate passage text via the {id}/{index} template and rescore.
let reranked = client
.vector_search_reranked
.await?;
// Score-fusion prefetch->rescore: blend the exact full-precision distance.
let blended = client
.vector_search_reranked
.await?;
// Dry-run pre-flight validation of a spec (no search executed).
client
.rerank_validate
.await?;
Durable change-feed (CDC)
subscribe_committed consumes the durable, ordered, resumable committed
change-feed with Kafka-style client-managed offsets. Supply a subscription_id
and a CheckpointStore (the default FileCheckpointStore persists offsets
atomically) to resume across restarts. With auto_commit, each change's offset
is committed after your handler returns Ok(true), giving at-least-once
delivery — so your handler must be idempotent.
use ;
let ckpt = open?;
let opts = SubscribeCommittedOptions ;
client.subscribe_committed.await?;
The consumer transparently reconnects from last_offset + 1 on disconnect, and
on a compaction notice it bootstraps a baseline via a paged scan (each entry
delivered as a synthetic put with is_snapshot = true) before resuming the
live tail from snapshot_offset + 1 — no gap.