Expand description
Production-grade Rust SDK for InferaDB Ledger service.
Provides a high-level, ergonomic API for Rust applications to interact with Ledger’s blockchain database. Wraps the gRPC services with automatic idempotency, resilient connectivity, and streaming support.
§Features
- Type-safe API: Strong typing for all Ledger operations
- Automatic idempotency: Server-assigned sequences with UUID-based deduplication
- Resilient connectivity: Exponential backoff retry and failover
- Streaming support: WatchBlocks with automatic reconnection
- Cancellation support: Per-request and client-level cancellation via
CancellationToken - Minimal-overhead abstractions: Efficient serialization and connection pooling
§Quick Start
use inferadb_ledger_sdk::{LedgerClient, ClientConfig, Operation, OrganizationSlug, UserSlug, ServerSource};
#[tokio::main]
async fn main() -> inferadb_ledger_sdk::Result<()> {
let config = ClientConfig::builder()
.servers(ServerSource::from_static(["http://localhost:50051"]))
.client_id("my-app-001")
.build()?;
let client = LedgerClient::new(config).await?;
// Read operations
let value = client.read(caller, organization, None, "user:123", None, None).await?;
// Write operations with automatic idempotency
let operations = vec![Operation::set_entity("user:123", b"data".to_vec(), None, None)];
let result = client.write(caller, organization, None, operations, None).await?;
println!("Committed at block {} with sequence {}", result.block_height, result.assigned_sequence);
Ok(())
}§Architecture
┌─────────────────────────────────────────────────────────────┐
│ LedgerClient (Public API) │
│ .read() │ .write() │ .watch_blocks() │ .admin() │
├─────────────────────────────────────────────────────────────┤
│ Idempotency Layer │
│ UUID generation │ Retry key preservation │ Dedup │
├─────────────────────────────────────────────────────────────┤
│ Resilience Layer (retry + cancellation) │
│ Retry middleware │ Exponential backoff │ Timeout │
├─────────────────────────────────────────────────────────────┤
│ Connection Pool │
│ Channel management │ Load balancing │ Health checks │
├─────────────────────────────────────────────────────────────┤
│ Tonic gRPC Clients │
│ ReadServiceClient │ WriteServiceClient │ AdminService │
└─────────────────────────────────────────────────────────────┘Re-exports§
pub use server::DnsConfig;pub use server::FileConfig;pub use server::ResolvedServer;pub use server::ServerResolver;pub use server::ServerSelector;pub use server::ServerSource;pub use token::PublicKeyInfo;pub use token::TokenPair;pub use token::ValidatedToken;
Modules§
- mock
- Mock gRPC server for SDK integration testing.
- server
- Server discovery and selection.
- token
- SDK types for the Token service.
Structs§
- AppClient
Assertion Info - A client assertion entry (public metadata only — private key is never returned after creation).
- AppClient
Secret Status - Result of getting a client secret’s status.
- AppCredentials
Info - Credential configuration for an app.
- AppId
- Internal sequential identifier for an application within an organization.
- AppInfo
- SDK representation of a client application.
- AppSlug
- Snowflake-generated external identifier for an application.
- AppVault
Connection Info - A vault connection for an app.
- Batch
Read Builder - Fluent builder for batch read requests.
- Blinding
KeyRehash Status - Status of a blinding key rehash operation.
- Blinding
KeyRotation Status - Status of a blinding key rotation initiated by
LedgerClient::rotate_blinding_key. - Block
Announcement - A block announcement from the WatchBlocks stream.
- Block
Header - Block header containing cryptographic commitments.
- Chain
Proof - Chain proof linking a trusted height to a response height.
- Circuit
Breaker - Per-endpoint circuit breaker.
- Circuit
Breaker Config - Configuration for the per-endpoint circuit breaker.
- Client
Assertion Id - Internal sequential identifier for a client assertion entry.
- Client
Config - Configuration for the Ledger SDK client.
- Client
Config Builder - Use builder syntax to set the inputs and finish with
build(). - Connection
Pool - Manages tonic gRPC channels with lazy connection establishment.
- Create
AppClient Assertion Result - Result of creating a client assertion — includes the private key PEM (returned only once).
- Discovery
Config - Configuration for peer discovery.
- Discovery
Result - Result of a peer discovery refresh operation.
- Discovery
Service - Service for discovering cluster peers and managing dynamic endpoints.
- Email
Verification Code - Verification code returned by
LedgerClient::initiate_email_verification. - Entity
- An entity stored in the ledger.
- Event
Filter - Filter criteria for event queries.
- Event
Page - Paginated result from event queries.
- Health
Check Result - Result of a health check operation.
- Height
Tracker - Height-based position tracker.
- Ingest
Rejection - A single rejected event from an ingestion batch.
- Ingest
Result - Result of an event ingestion request.
- Invitation
Created - Response from creating an organization invitation.
- Invitation
Info - Admin-facing invitation information.
- Invitation
Page - Paginated list of admin-facing invitations.
- Invite
Slug - External Snowflake identifier for an organization invitation.
- Ledger
Client - High-level client for interacting with the Ledger service.
- List
Entities Opts - Options for listing entities.
- List
Relationships Opts - Options for listing relationships.
- List
Resources Opts - Options for listing resources.
- Merkle
Proof - Merkle proof for verifying state inclusion.
- Merkle
Sibling - A sibling node in a Merkle proof path.
- Metrics
SdkMetrics - Metrics implementation using the
metricscrate facade. - Migration
Info - Information about an in-progress organization migration.
- Noop
SdkMetrics - No-op metrics implementation with zero overhead.
- Organization
Delete Info - Information returned when an organization is soft-deleted.
- Organization
Id - Internal sequential identifier for an organization (storage-layer only).
- Organization
Info - Information about an organization.
- Organization
Member Info - Information about an organization member.
- Organization
Slug - Snowflake-generated external identifier for an organization.
- Paged
Result - Paginated result from query operations.
- Passkey
Credential Info - WebAuthn passkey credential data.
- Peer
Info - Information about a discovered peer in the cluster.
- Received
Invitation Info - User-facing invitation information.
- Received
Invitation Page - Paginated list of user-facing received invitations.
- Reconnecting
Stream - A stream wrapper that automatically reconnects on disconnect.
- Recovery
Code Credential Info - Recovery code credential data.
- Recovery
Code Result - Result of consuming a recovery code.
- Registration
Result - Result of
LedgerClient::complete_registration. - Relationship
- A relationship in a vault (authorization tuple).
- Relationship
Query Builder - Fluent builder for relationship list queries.
- Retry
Policy - Retry policy with exponential backoff and jitter.
- Schema
Deploy Result - Result of deploying a schema.
- Schema
Diff Change - A single field-level change in a schema diff.
- Schema
Version - A full schema version with its definition.
- Schema
Version Summary - Summary of a single schema version in a listing.
- SdkEvent
Entry - An audit event entry from the events system.
- SdkIngest
Event Entry - A single event for external ingestion (from Engine or Control).
- TeamId
- Internal sequential identifier for a team within an organization.
- Team
Info - Information about an organization team.
- Team
Member Info - A member of a team.
- Team
Slug - Snowflake-generated external identifier for a team.
- TlsConfig
- TLS configuration for secure connections.
- TlsConfig
Builder - Use builder syntax to set the inputs and finish with
build(). - Totp
Credential Info - TOTP credential data (RFC 6238).
- Trace
Config - Configuration for distributed tracing in the SDK.
- User
Credential Id - Internal sequential identifier for a user credential.
- User
Credential Info - A user authentication credential as returned by the Ledger API.
- User
Email Id - Unique identifier for a user email record. Never exposed in APIs.
- User
Email Info - SDK representation of a user email record.
- User
Info - SDK representation of a user record.
- User
Migration Info - Information about a user region migration.
- User
Slug - Snowflake-generated external identifier for a user.
- VaultId
- Internal sequential identifier for a vault within an organization (storage-layer only).
- Vault
Info - Information about a vault.
- Vault
Slug - Snowflake-generated external identifier for a vault.
- Verified
Value - Result of a verified read operation.
- Verify
Opts - Options for verified read operations.
- Write
Builder - Fluent builder for constructing write requests.
- Write
Success - Result of a successful write operation.
Enums§
- AppCredential
Type - Credential type for enable/disable operations.
- Certificate
Data - Certificate data that can be either PEM or DER encoded.
- Circuit
State - Circuit breaker states.
- Connection
Event - Events for connection lifecycle tracking.
- Credential
Data - Type-specific credential data.
- Credential
Type - The type of authentication credential.
- Direction
- Direction of a sibling in a Merkle proof.
- Email
Verification Result - Result of
LedgerClient::verify_email_code. - Event
Emission Path - Emission path of an event (how it was generated).
- Event
Outcome - Outcome of an audited operation.
- Event
Scope - Scope of an event (system-wide or organization-scoped).
- Event
Source - Identifies which InferaDB component is the source of ingested events.
- Health
Status - Health status of a node or vault.
- Invitation
Status - Status of an organization invitation.
- Operation
- A write operation to be submitted to the ledger.
- Organization
Member Role - Role of a member within an organization.
- Organization
Status - Status of an organization.
- Organization
Tier - Billing tier for an organization.
- Read
Consistency - Consistency level for read operations.
- Region
- Geographic/jurisdictional region for data residency.
- SdkError
- SDK error types with context-rich error messages.
- SetCondition
- Condition for compare-and-set (CAS) writes.
- Team
Member Role - Role within a team.
- Totp
Algorithm - TOTP hash algorithm (RFC 6238).
- User
Role - User authorization role.
- User
Status - User account lifecycle status.
- Vault
Status - Status of a vault.
Traits§
- SdkMetrics
- Trait for SDK-side metrics collection.
Functions§
- with_
retry - Executes an async operation with retry using exponential backoff.
- with_
retry_ cancellable - Executes an async operation with retry and cancellation support.
Type Aliases§
- Result
- Result type alias for SDK operations.