Skip to content

Commit 17fbeac

Browse files
committed
Add rust send_recording snippet
1 parent 0bd861f commit 17fbeac

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Send a `.rrd` to a new recording stream.
2+
3+
use rerun::external::re_chunk_store::{ChunkStore, ChunkStoreConfig};
4+
use rerun::external::re_log_types::{LogMsg, SetStoreInfo};
5+
use rerun::external::re_tuid::Tuid;
6+
use rerun::VersionPolicy;
7+
8+
fn main() -> Result<(), Box<dyn std::error::Error>> {
9+
// Get the filename from the command-line args.
10+
let filename = std::env::args().nth(2).ok_or("Missing filename argument")?;
11+
12+
// Load the chunk store from the file.
13+
let (store_id, store) =
14+
ChunkStore::from_rrd_filepath(&ChunkStoreConfig::DEFAULT, filename, VersionPolicy::Warn)?
15+
.into_iter()
16+
.next()
17+
.ok_or("Expected exactly one recording in the archive")?;
18+
19+
// Use the same app and recording IDs as the original.
20+
if let Some(info) = store.info().cloned() {
21+
let new_recording = rerun::RecordingStreamBuilder::new(info.application_id.clone())
22+
.recording_id(store_id.to_string())
23+
.spawn()?;
24+
25+
new_recording.record_msg(LogMsg::SetStoreInfo(SetStoreInfo {
26+
row_id: Tuid::new(),
27+
info,
28+
}));
29+
30+
// Forward all chunks to the new recording stream.
31+
new_recording.send_chunks(store.iter_chunks().map(|chunk| (**chunk).clone()));
32+
}
33+
34+
Ok(())
35+
}

docs/snippets/snippets.toml

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ features = [
101101
]
102102
"concepts/send_recording" = [ # No output
103103
"cpp",
104-
"rust",
105104
]
106105
"concepts/static/log_static" = [ # pseudo-code
107106
"py",

0 commit comments

Comments
 (0)