diff --git a/crates/store/re_types_core/src/lib.rs b/crates/store/re_types_core/src/lib.rs index 89015c2d6fbb..0e61de9ba8a3 100644 --- a/crates/store/re_types_core/src/lib.rs +++ b/crates/store/re_types_core/src/lib.rs @@ -89,6 +89,40 @@ impl AsComponents for C { } } +impl AsComponents for dyn ComponentBatch { + #[inline] + fn as_component_batches(&self) -> Vec> { + vec![MaybeOwnedComponentBatch::Ref(self)] + } +} + +impl AsComponents for [&dyn ComponentBatch; N] { + #[inline] + fn as_component_batches(&self) -> Vec> { + self.iter() + .map(|batch| MaybeOwnedComponentBatch::Ref(*batch)) + .collect() + } +} + +impl AsComponents for &[&dyn ComponentBatch] { + #[inline] + fn as_component_batches(&self) -> Vec> { + self.iter() + .map(|batch| MaybeOwnedComponentBatch::Ref(*batch)) + .collect() + } +} + +impl AsComponents for Vec<&dyn ComponentBatch> { + #[inline] + fn as_component_batches(&self) -> Vec> { + self.iter() + .map(|batch| MaybeOwnedComponentBatch::Ref(*batch)) + .collect() + } +} + // --- mod archetype; diff --git a/docs/snippets/all/archetypes/image_send_columns.rs b/docs/snippets/all/archetypes/image_send_columns.rs index f03df013e675..5f0e2c991f81 100644 --- a/docs/snippets/all/archetypes/image_send_columns.rs +++ b/docs/snippets/all/archetypes/image_send_columns.rs @@ -23,11 +23,7 @@ fn main() -> Result<(), Box> { // Log the ImageFormat and indicator once, as static. let format = rerun::components::ImageFormat::rgb8([width as _, height as _]); - rec.log_component_batches( - "images", - true, - [&format as _, &rerun::Image::indicator() as _], - )?; + rec.log_static("images", &[&format as _, &rerun::Image::indicator() as _])?; // Split up the image data into several components referencing the underlying data. let image_size_in_bytes = width * height * 3; diff --git a/docs/snippets/all/archetypes/manual_indicator.rs b/docs/snippets/all/archetypes/manual_indicator.rs index 55876b391394..eea5009d506a 100644 --- a/docs/snippets/all/archetypes/manual_indicator.rs +++ b/docs/snippets/all/archetypes/manual_indicator.rs @@ -7,10 +7,9 @@ fn main() -> Result<(), Box> { // Specify both a Mesh3D and a Points3D indicator component so that the data is shown as both a // 3D mesh _and_ a point cloud by default. - rec.log_component_batches( + rec.log( "points_and_mesh", - false, - [ + &[ rerun::Points3D::indicator().as_ref() as &dyn rerun::ComponentBatch, rerun::Mesh3D::indicator().as_ref(), &[[0.0, 0.0, 0.0], [10.0, 0.0, 0.0], [0.0, 10.0, 0.0]].map(rerun::Position3D::from), diff --git a/docs/snippets/all/archetypes/mesh3d_partial_updates.rs b/docs/snippets/all/archetypes/mesh3d_partial_updates.rs index 82e2701197ed..1027b254a0bb 100644 --- a/docs/snippets/all/archetypes/mesh3d_partial_updates.rs +++ b/docs/snippets/all/archetypes/mesh3d_partial_updates.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), Box> { (glam::Vec3::from(vertex_positions[1]) * factor).into(), (glam::Vec3::from(vertex_positions[2]) * factor).into(), ]; - rec.log_component_batches("triangle", false, [&vertex_positions as _])?; + rec.log("triangle", &[&vertex_positions as _])?; } Ok(()) diff --git a/docs/snippets/all/concepts/different_data_per_timeline.rs b/docs/snippets/all/concepts/different_data_per_timeline.rs index 603309513f75..0f13e9e4441b 100644 --- a/docs/snippets/all/concepts/different_data_per_timeline.rs +++ b/docs/snippets/all/concepts/different_data_per_timeline.rs @@ -11,19 +11,17 @@ fn main() -> Result<(), Box> { // Log a red color on one timeline. rec.reset_time(); // Clears all set timeline info. rec.set_time_seconds("red timeline", 1.0); - rec.log_component_batches( + rec.log( "points", - false, - [&rerun::components::Color::from_u32(0xFF0000FF) as &dyn rerun::ComponentBatch], + &[&rerun::components::Color::from_u32(0xFF0000FF) as &dyn rerun::ComponentBatch], )?; // And a blue color on the other. rec.reset_time(); // Clears all set timeline info. rec.set_time_sequence("blue timeline", 1); - rec.log_component_batches( + rec.log( "points", - false, - [&rerun::components::Color::from_u32(0x0000FFFF) as &dyn rerun::ComponentBatch], + &[&rerun::components::Color::from_u32(0x0000FFFF) as &dyn rerun::ComponentBatch], )?; // TODO(#5521): log VisualBounds2D diff --git a/examples/rust/incremental_logging/src/main.rs b/examples/rust/incremental_logging/src/main.rs index 799e5754c26a..c3eddb675dae 100644 --- a/examples/rust/incremental_logging/src/main.rs +++ b/examples/rust/incremental_logging/src/main.rs @@ -38,7 +38,7 @@ let radii = [rerun::Radius(0.1); 10]; // Only log colors and radii once. rec.set_time_sequence("frame_nr", 0); -rec.log_component_batches("points", false /* static */, [&colors as &dyn rerun::ComponentBatch, &radii])?; +rec.log("points", &[&colors as &dyn rerun::ComponentBatch, &radii])?; let mut rng = rand::thread_rng(); let dist = Uniform::new(-5., 5.); @@ -63,17 +63,9 @@ fn run(rec: &rerun::RecordingStream) -> anyhow::Result<()> { // Only log colors and radii once. rec.set_time_sequence("frame_nr", 0); - rec.log_component_batches( - "points", - false, /* static */ - [&colors as &dyn rerun::ComponentBatch, &radii], - )?; + rec.log("points", &[&colors as &dyn rerun::ComponentBatch, &radii])?; // Logging statically would also work. - // rec.log_component_batches( - // "points", - // true, /* static */ - // [&colors as &dyn rerun::ComponentBatch, &radii], - // )?; + // rec.log_static("points", &[&colors as &dyn rerun::ComponentBatch, &radii])?; let mut rng = rand::thread_rng(); let dist = Uniform::new(-5., 5.);