Expand description
Native Rust client for TigerBeetle.
This crate provides a high-performance client for TigerBeetle, the financial transactions database.
§Compatibility
This client is compatible with TigerBeetle 0.16.x.
TigerBeetle requires exact client-server protocol compatibility. This crate’s version
follows the format TB_VERSION+CRATE_VERSION (e.g., 0.16.0+0.1.0), where:
- The main version (
0.16.0) indicates TigerBeetle server compatibility - The build metadata (
+0.1.0) indicates the library version
§Features
- High-performance: Uses io_uring for efficient async I/O on Linux
- Type-safe: Strong typing for accounts, transfers, and results
- Simple API: One
Clienttype with a clean builder pattern
§Requirements
- Linux (kernel 5.6+) with io_uring support
§Quick Start
ⓘ
use tb_rs::{Client, Account, AccountFlags};
// Run inside tokio_uring runtime
tokio_uring::start(async {
// Connect to cluster
let mut client = Client::connect(0, "127.0.0.1:3000").await?;
// Create an account
let account = Account {
id: tb_rs::id(),
ledger: 1,
code: 1,
..Default::default()
};
let errors = client.create_accounts(&[account]).await?;
assert!(errors.is_empty(), "Account creation failed");
// Lookup the account
let accounts = client.lookup_accounts(&[account.id]).await?;
println!("Found {} accounts", accounts.len());
client.close().await;
Ok::<_, tb_rs::ClientError>(())
});§Configuration
Use the builder pattern for custom configuration:
ⓘ
use std::time::Duration;
use tb_rs::Client;
let client = Client::builder()
.cluster(0)
.addresses("127.0.0.1:3000,127.0.0.1:3001")?
.connect_timeout(Duration::from_secs(10))
.request_timeout(Duration::from_millis(100))
.build()
.await?;Re-exports§
pub use protocol::Account;pub use protocol::AccountBalance;pub use protocol::AccountFilter;pub use protocol::AccountFilterFlags;pub use protocol::AccountFlags;pub use protocol::CreateAccountResult;pub use protocol::CreateAccountsResult;pub use protocol::CreateTransferResult;pub use protocol::CreateTransfersResult;pub use protocol::QueryFilter;pub use protocol::QueryFilterFlags;pub use protocol::Transfer;pub use protocol::TransferFlags;
Modules§
- protocol
- TigerBeetle protocol implementation.
Structs§
- Client
- TigerBeetle client.
- Client
Builder - Builder for creating a
Clientwith custom configuration.
Enums§
- Client
Error - Main error type for client operations.
- Protocol
Error - Protocol-level errors.
Constants§
- CRATE_
VERSION - Library version (independent of TigerBeetle version).
- TIGERBEETLE_
VERSION - TigerBeetle server version this client is compatible with.
Functions§
- id
- Generate a unique TigerBeetle ID.
Type Aliases§
- Result
- Result type for client operations.