Skip to content

Commit

Permalink
more review
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Dec 9, 2024
1 parent 7c2aee3 commit 772fb23
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 36 deletions.
32 changes: 23 additions & 9 deletions docs/snippets/all/descriptors/descr_builtin_archetype.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
use rerun::{ChunkStore, ChunkStoreConfig, ComponentDescriptor, VersionPolicy};

#[allow(clippy::unwrap_used)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
const APP_ID: &str = "rerun_example_descriptors_builtin_archetype";

let rec = rerun::RecordingStreamBuilder::new(APP_ID).spawn()?;

fn example(rec: &rerun::RecordingStream) -> Result<(), Box<dyn std::error::Error>> {
rec.log_static(
"data",
&rerun::Points3D::new([(1.0, 2.0, 3.0)]).with_radii([0.3, 0.2, 0.1]),
)?;

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_archetype";
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.
Expand All @@ -23,7 +38,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&ChunkStoreConfig::ALL_DISABLED,
path_to_rrd,
VersionPolicy::Warn,
)?;
)
.unwrap();
assert_eq!(1, stores.len());

let store = stores.into_values().next().unwrap();
Expand Down Expand Up @@ -60,6 +76,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

similar_asserts::assert_eq!(expected, descriptors);
}

Ok(())
}
32 changes: 23 additions & 9 deletions docs/snippets/all/descriptors/descr_builtin_component.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
use rerun::{ChunkStore, ChunkStoreConfig, Component as _, ComponentDescriptor, VersionPolicy};

#[allow(clippy::unwrap_used)]
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()?;

fn example(rec: &rerun::RecordingStream) -> Result<(), Box<dyn std::error::Error>> {
rec.log_component_batches(
"data",
true,
[&rerun::components::Position3D::new(1.0, 2.0, 3.0) as &dyn rerun::ComponentBatch],
)?;

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.
Expand All @@ -24,7 +39,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&ChunkStoreConfig::ALL_DISABLED,
path_to_rrd,
VersionPolicy::Warn,
)?;
)
.unwrap();
assert_eq!(1, stores.len());

let store = stores.into_values().next().unwrap();
Expand All @@ -51,6 +67,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

similar_asserts::assert_eq!(expected, descriptors);
}

Ok(())
}
38 changes: 27 additions & 11 deletions docs/snippets/all/descriptors/descr_custom_archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ impl rerun::AsComponents for CustomPoints3D {
[
Some(Self::indicator().to_batch()),
Some(
rerun::ComponentBatchCowWithDescriptor::new(&self.positions as &dyn rerun::ComponentBatch)
.with_descriptor_override(Self::overridden_position_descriptor()),
rerun::ComponentBatchCowWithDescriptor::new(
&self.positions as &dyn rerun::ComponentBatch,
)
.with_descriptor_override(Self::overridden_position_descriptor()),
),
self.colors.as_ref().map(|colors| {
rerun::ComponentBatchCowWithDescriptor::new(colors as &dyn rerun::ComponentBatch)
Expand All @@ -80,12 +82,7 @@ impl rerun::AsComponents for CustomPoints3D {
}
}

#[allow(clippy::unwrap_used)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
const APP_ID: &str = "rerun_example_descriptors_custom_archetype";

let rec = rerun::RecordingStreamBuilder::new(APP_ID).spawn()?;

fn example(rec: &rerun::RecordingStream) -> Result<(), Box<dyn std::error::Error>> {
let position = CustomPosition3D(rerun::components::Position3D::new(1.0, 2.0, 3.0));
let color = rerun::components::Color::new(0xFF00FFFF);

Expand All @@ -96,6 +93,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

rec.log_static("data", &points as _)?;

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_custom_archetype";
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.
Expand All @@ -108,7 +125,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&ChunkStoreConfig::ALL_DISABLED,
path_to_rrd,
VersionPolicy::Warn,
)?;
)
.unwrap();
assert_eq!(1, stores.len());

let store = stores.into_values().next().unwrap();
Expand Down Expand Up @@ -145,6 +163,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

similar_asserts::assert_eq!(expected, descriptors);
}

Ok(())
}
28 changes: 21 additions & 7 deletions docs/snippets/all/descriptors/descr_custom_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,30 @@ impl Component for CustomPosition3D {
}
}

#[allow(clippy::unwrap_used)]
fn example(rec: &rerun::RecordingStream) -> Result<(), Box<dyn std::error::Error>> {
let position = CustomPosition3D(rerun::components::Position3D::new(1.0, 2.0, 3.0));
rec.log_component_batches("data", true, [&position as &dyn rerun::ComponentBatch])?;

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_custom_component";

let rec = rerun::RecordingStreamBuilder::new(APP_ID).spawn()?;

let position = CustomPosition3D(rerun::components::Position3D::new(1.0, 2.0, 3.0));
rec.log_component_batches("data", true, [&position as &dyn rerun::ComponentBatch])?;
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.
Expand All @@ -64,7 +79,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&ChunkStoreConfig::ALL_DISABLED,
path_to_rrd,
VersionPolicy::Warn,
)?;
)
.unwrap();
assert_eq!(1, stores.len());

let store = stores.into_values().next().unwrap();
Expand All @@ -91,6 +107,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

similar_asserts::assert_eq!(expected, descriptors);
}

Ok(())
}

0 comments on commit 772fb23

Please sign in to comment.