Skip to main content

Use the Lattice SDK for gRPC in Rust

This page shows how you can install, set up, and use the Lattice SDK for gRPC in Rust to get information about an entity in your environment.

Click to go to the gRPC SDK repository. By downloading and/or using, you agree to the terms of use. If you do not agree, do not use the SDK.

Before you begin

  1. Complete the setup steps to generate a valid API bearer token and publish at least one entity to your environment.
  2. Install the latest version of Rust. When you install Rust using rustup, you also get the latest version of Cargo. You can use Cargo to set up your project and manage dependencies.

Set up your Rust project

Use cargo to set up an example project. In the following steps, you'll replace the starter code with examples that let you connect with your Lattice environment.

  1. Confirm that you have Cargo installed:

    cargo --version
  2. Create a new Rust project:


    cargo new $YOUR_PROJECT

    Cargo creates a project folder consisting of a Cargo.toml to list versioned dependencies, and a main.rs file where you implement the main function for your program.

Install the SDK

To install the gRPC SDK in Rust, do the following:

  1. Add the lattice-sdk-rust dependency to your Cargo.toml file. You will also need a gRPC implementation. We recommend that you use Tonic and Tokio:

    cargo add anduril-lattice-sdk
    # Optional packages.
    cargo add tonic -F features-tls
    cargo add tokio -F full

    After installing the packages, Cargo adds Cargo.lock to your project folder. This file is automatically generated and updated by Cargo when you build or update your project. Cargo.lock ensures reproducible builds of your project by locking dependency versions. This helps you ensure consistency across different developments.

  2. Verify that your Cargo.toml file looks similar to the following:

    [package]
    name = "$YOUR_PROJECT"
    version = "0.1.0"
    edition = "2021"

    [dependencies]
    anduril-lattice-sdk = "1.0.0"
    tonic = { version="0.8", features=["tls","tls-roots"] }
    tokio = { version="1.0", features=["full"] }
  3. Verify that you can fetch the required dependencies:

    cargo build

    This command compiles your Rust project and its dependencies. Cargo places the resulting binary files in target/debug.

What's next