Skip to main content

clankers_data/
lib.rs

1//! # MCAP logging, replay, and inspection
2//!
3//! Read, write, inspect, and compare robot logs in [MCAP](https://mcap.dev) format.
4//! Works with the `clankers` CLI (`clankers inspect`, `clankers replay`, `clankers compare`)
5//! and with [`ReplayContext`](https://docs.rs/clankers-testing/latest/clankers_testing/struct.ReplayContext.html) in tests.
6//!
7//! ## Inspect a log
8//!
9//! ```no_run
10//! use clankers_data::{format_inspect_report, McapLog};
11//!
12//! let log = McapLog::open("sample_data/camera_log.mcap")?;
13//! println!("{}", format_inspect_report(log.report()));
14//! # Ok::<(), clankers_core::RobotError>(())
15//! ```
16//!
17//! ## Replay messages
18//!
19//! ```no_run
20//! # #[tokio::main]
21//! # async fn main() -> clankers_core::RobotResult<()> {
22//! use clankers_data::Replay;
23//!
24//! let replay = Replay::from_mcap("sample_data/camera_log.mcap")?;
25//! let result = replay.run(|_msg| async { Ok(()) }).await?;
26//! println!("handled {} messages", result.summary.input_messages);
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! ## Key types
32//!
33//! | Type | Role |
34//! |------|------|
35//! | [`McapLog`] | Open a log and produce an [`InspectReport`] |
36//! | [`Replay`] | Stream messages with optional per-message handler |
37//! | [`ReplaySummary`] | Counts, duration, topics seen |
38//! | [`CompareReport`] | Diff two logs (used by `clankers compare`) |
39//! | [`McapWriter`] | Write MCAP files from nodes |
40
41pub mod compare;
42pub mod inspect;
43pub mod log;
44pub mod replay;
45pub mod sample;
46pub mod writer;
47
48pub use compare::{compare_logs, format_compare_report, CompareReport};
49pub use inspect::{format_inspect_report, InspectReport, McapLog};
50pub use log::McapRecord;
51pub use replay::{Replay, ReplayResult, ReplaySummary};
52pub use writer::McapWriter;