-
Notifications
You must be signed in to change notification settings - Fork 405
/
Copy pathdescr_builtin_component.rs
70 lines (56 loc) · 2.17 KB
/
descr_builtin_component.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use rerun::{ChunkStore, ChunkStoreConfig, Component as _, ComponentDescriptor, VersionPolicy};
fn example(rec: &rerun::RecordingStream) -> Result<(), Box<dyn std::error::Error>> {
use rerun::ComponentBatch as _;
rec.log_static(
"data",
&[rerun::components::Position3D::new(1.0, 2.0, 3.0).try_serialized()?],
)?;
Ok(())
}
// ---
// Everything below this line is _not_ part of the example.
// This is internal testing code to make sure the example yields the right data.
fn main() -> Result<(), Box<dyn std::error::Error>> {
const APP_ID: &str = "rerun_example_descriptors_builtin_component";
let rec = rerun::RecordingStreamBuilder::new(APP_ID).spawn()?;
example(&rec)?;
check_tags(&rec);
Ok(())
}
#[allow(clippy::unwrap_used)]
fn check_tags(rec: &rerun::RecordingStream) {
// When this snippet runs through the snippet comparison machinery, this environment variable
// will point to the output RRD.
// We can thus load this RRD to check that the proper tags were indeed forwarded.
//
// Python and C++ are indirectly checked by the snippet comparison tool itself.
if let Ok(path_to_rrd) = std::env::var("_RERUN_TEST_FORCE_SAVE") {
rec.flush_blocking();
let stores = ChunkStore::from_rrd_filepath(
&ChunkStoreConfig::ALL_DISABLED,
path_to_rrd,
VersionPolicy::Warn,
)
.unwrap();
assert_eq!(1, stores.len());
let store = stores.into_values().next().unwrap();
let chunks = store.iter_chunks().collect::<Vec<_>>();
assert_eq!(1, chunks.len());
let chunk = chunks.into_iter().next().unwrap();
let mut descriptors = chunk
.components()
.values()
.flat_map(|per_desc| per_desc.keys())
.cloned()
.collect::<Vec<_>>();
descriptors.sort();
let expected = vec![
ComponentDescriptor {
archetype_name: None,
archetype_field_name: None,
component_name: rerun::components::Position3D::name(),
}, //
];
similar_asserts::assert_eq!(expected, descriptors);
}
}