Rust Quick Start

Installing Rerun

The Rerun SDK for Rust requires a working installation of Rust 1.72+.

To use Rerun, you need to install the rerun binary with cargo install rerun-cli, and the rerun crate with cargo add rerun.

Let's try it out in a brand new Rust project:

$ cargo init cube && cd cube && cargo add rerun

Starting the viewer

Just run rerun to start the Rerun Viewer. It will wait for your application to log some data to it.

Logging some data

Add the following code to your (This example also lives in the rerun source tree example)

use rerun::{ components::{Color, Point3D, Radius}, demo_util::grid, external::glam, MsgSender, RecordingStreamBuilder, }; fn main() -> Result<(), Box<dyn std::error::Error>> { let recording = RecordingStreamBuilder::new("rerun_example_minimal").connect(rerun::default_server_addr())?; let points = grid(glam::Vec3::splat(-10.0), glam::Vec3::splat(10.0), 10) .map(Point3D::from) .collect::<Vec<_>>(); let colors = grid(glam::Vec3::ZERO, glam::Vec3::splat(255.0), 10) .map(|v| Color::from_rgb(v.x as u8, v.y as u8, v.z as u8)) .collect::<Vec<_>>(); MsgSender::new("my_points") .with_component(&points)? .with_component(&colors)? .with_splat(Radius(0.5))? .send(&recording)?; Ok(()) }

Now run your application:

cargo run

Once everything finishes compiling, you will see the points in the Rerun Viewer:

Rust getting started result

Using the viewer

Try out the following to interact with the viewer:

  • Click and drag in the main view to rotate the cube.
  • Zoom in and out with the scroll wheel.
  • Mouse over the "?" icons to find out about more controls.
  • Click on the cube to select all of the points.
  • Hover and select individual points to see more information.

If you're facing any difficulties, don't hesitate to open an issue or join the Discord server.

What's next

If you're ready to move on to more advanced topics, check out the Viewer Walkthrough or our more advanced guide for Logging Data in Rust where we will explore the core concepts that make Rerun tick and log our first non-trivial dataset.

If you'd rather learn from examples, check out the example gallery for some more realistic examples, or browse the Loggable Data Types section for more simple examples of how to use the main data types.