Aerospike Rust Client
Welcome to the preview of Aerospike's official Rust client. This is your opportunity to help shape the direction of the Rust client's ongoing development.
This early-release library brings async-native database operations to Rust developers, with support for batch updates and partition queries. We welcome your feedback as we work toward production readiness.
Feature highlights
Execution models:
- Async-First: Built for non-blocking IO, powered by Tokio by default, with optional support for async-std.
- Sync Support: Blocking APIs are available using a sync sub-crate for flexibility in legacy or mixed environments.
Advanced data operations:
- Batch protocol: full support for read, write, delete, and udf operations through the
new
BatchOperationAPI. - New query wire protocols: implements updated query protocols for improved consistency and performance.
Policy and expression enhancements:
- Replica policies: includes support for Replica, including PreferRack placement.
- Policy additions: new fields such as
allow_inline_ssd,respond_all_keysinBatchPolicy,read_touch_ttl, andQueryDurationinQueryPolicy. - Rate limiting: supports
records_per_secondfor query throttling.
Data model improvements:
- Type support: adds support for boolean particle type.
- New data constructs: returns types such as
Exists,OrderedMap,UnorderedMapnow supported for CDT reads. - Value conversions: implements
TryFromaerospike::Valuefor seamless type interoperability. - Infinity and wildcard: supports
Infinity,Wildcard, and corresponding expression buildersexpressions::infinity()andexpressions::wildcard(). - Size expressions: adds
expressions::record_size()andexpressions::memory_size()for granular control.
Take a look at the changelog for more details.
What’s coming next?
We are working toward full functional parity with our other officially supported clients. Features on the roadmap include:
- Partition queries
- Distributed ACID transactions
- Strong consistency
- Full TLS support for secure, production-ready deployments
Getting started
Prerequisites:
- Aerospike Database 6.4 or later.
- Rust version 1.75 or later
- Tokio runtime or async-std
Installation
-
Build from source code:
git clone --single-branch --branch v2 https://github.com/aerospike/aerospike-client-rust.git cd aerospike-client-rust -
Add the following to your
cargo.tomlfile:[dependencies] # Async API with tokio Runtime aerospike = { version = "<version>", features = ["rt-tokio"]} # OR # Async API with async-std runtime aerospike = { version = "<version>", features = ["rt-async-std"]} # The library still supports the old sync interface, but it will be deprecated in the future. # This is only for compatibility reasons and will be removed in a later stage. # Sync API with tokio aerospike = { version = "<version>", default-features = false, features = ["rt-tokio", "sync"]} # OR # Sync API with async-std aerospike = { version = "<version>", default-features = false, features = ["rt-async-std", "sync"]} -
Run the following command:
cargo build
Core feature examples
The following code examples demonstrate some of the Rust client's new features.
CRUD operations
extern crate aerospike;
extern crate tokio;
use env;
use Instant;
use ;
use operations;
async
Batch operations
let mut bpolicy = default;
let udf_body = r#"
function echo(rec, val)
return val
end
"#;
let task = client
.register_udf
.await
.unwrap;
task.wait_till_complete.await.unwrap;
let bin1 = as_bin!;
let bin2 = as_bin!;
let bin3 = as_bin!;
let key1 = as_key!;
let key2 = as_key!;
let key3 = as_key!;
let key4 = as_key!;
// key does not exist
let selected = from;
let all = All;
let none = None;
let wops = vec!;
let rops = vec!;
let bpr = default;
let bpw = default;
let bpd = default;
let bpu = default;
let batch = vec!;
let mut results = client.batch.await.unwrap;
dbg!;
// READ Operations
let batch = vec!;
let mut results = client.batch.await.unwrap;
dbg!;
// DELETE Operations
let batch = vec!;
let mut results = client.batch.await.unwrap;
dbg!;
// Read
let args1 = &;
let args2 = &;
let args3 = &;
let args4 = &;
let batch = vec!;
let mut results = client.batch.await.unwrap;
dbg!;
Feedback wanted
We need your help with:
- Real-world async patterns in your codebase
- Ergonomic pain points in API design
You’re not just testing this new client - you’re shaping the future of Rust in databases!
You can reach us through Github Issues or schedule a meeting to speak directly with our product team using this scheduling link.