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
- Complete the setup steps to generate a valid API bearer token and publish at least one entity to your environment.
- 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.
-
Confirm that you have Cargo installed:
cargo --version
-
Create a new Rust project:
cargo new $YOUR_PROJECTCargo creates a project folder consisting of a
Cargo.toml
to list versioned dependencies, and amain.rs
file where you implement the main function for your program.
Install the SDK
To install the gRPC SDK in Rust, do the following:
-
Add the
lattice-sdk-rust
dependency to yourCargo.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 fullAfter 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. -
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"] } -
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
- Start building and publishing entities into Lattice.
- Learn how to watch entities, stream specific components, and apply filters.
- See the Lattice sample applications.