Skip to content

Install the Aerospike Rust client

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Versions

  • The stable release of the Rust client is version 2.1.0.

  • With version 3.0.0, the Rust client will become an officially supported Aerospike client library.

Prerequisites

  • Rust at or above the minimum version for your target client version:

    Client versionMinimum Rust version
    2.1.01.87
    1.3.01.46
  • A choice of async runtime for your project: Tokio or async-std.

  • An Aerospike server. See the Client matrix for client/server version compatibility.

Install

To use the client in your own project, add it with the async runtime you chose.

For Tokio, use:

Terminal window
cargo add tokio
cargo add aerospike@2.1.0 --features rt-tokio

For async-std, use:

Terminal window
cargo add async-std
cargo add aerospike@2.1.0 --features rt-async-std

The client also supports a sync feature for the older, blocking API. Use it only if you can’t adopt async/await yet: it requires --no-default-features because async is a default feature.

Terminal window
cargo add aerospike@2.1.0 --no-default-features --features rt-tokio,sync

Build from source code

  1. Clone the Git repository:

    git clone --single-branch --branch v2 https://github.com/aerospike/aerospike-client-rust.git
    cd aerospike-client-rust
  2. Build the project:

    cargo build

Use as a dependency

  1. To use the client in your own project, add one of the following to your Cargo.toml:

    [dependencies]
    # Async API with tokio Runtime
    aerospike = { version = "2.2.0", features = ["rt-tokio"]}
    # OR
    # Async API with async-std runtime
    aerospike = { version = "2.2.0", 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 = "2.2.0", default-features = false, features = ["rt-tokio", "sync"]}
    # OR
    # Sync API with async-std
    aerospike = { version = "2.2.0", default-features = false, features = ["rt-async-std", "sync"]}
  2. Build the project:

    cargo build

Verify

Confirm the crate resolves and the project builds:

Terminal window
cargo build

Expected: the build completes without errors, and Cargo.lock lists an aerospike entry at the version you added.

Next steps

Usage examples

Ready for more code examples? We have usage examples for all the basic CRUD operations.

Usage examples →

Error handling

Actionable errors with recovery suggestions. Know exactly what went wrong and how to fix it.

Error handling →