From 600e1f7c6eaea9ad59e06f30105cd70f6e6ae58c Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 17:46:26 +0200 Subject: [PATCH 01/13] introduce re_types_core --- Cargo.lock | 32 +- Cargo.toml | 4 + crates/re_types_core/.gitattributes | 129 +++++ crates/re_types_core/Cargo.toml | 46 ++ crates/re_types_core/README.md | 10 + crates/re_types_core/src/archetype.rs | 275 +++++++++ crates/re_types_core/src/arrow_buffer.rs | 89 +++ crates/re_types_core/src/arrow_string.rs | 91 +++ crates/re_types_core/src/lib.rs | 123 ++++ crates/re_types_core/src/loggable.rs | 245 ++++++++ crates/re_types_core/src/loggable_batch.rs | 372 +++++++++++++ crates/re_types_core/src/result.rs | 317 +++++++++++ crates/re_types_core/src/size_bytes.rs | 618 +++++++++++++++++++++ 13 files changed, 2345 insertions(+), 6 deletions(-) create mode 100644 crates/re_types_core/.gitattributes create mode 100644 crates/re_types_core/Cargo.toml create mode 100644 crates/re_types_core/README.md create mode 100644 crates/re_types_core/src/archetype.rs create mode 100644 crates/re_types_core/src/arrow_buffer.rs create mode 100644 crates/re_types_core/src/arrow_string.rs create mode 100644 crates/re_types_core/src/lib.rs create mode 100644 crates/re_types_core/src/loggable.rs create mode 100644 crates/re_types_core/src/loggable_batch.rs create mode 100644 crates/re_types_core/src/result.rs create mode 100644 crates/re_types_core/src/size_bytes.rs diff --git a/Cargo.lock b/Cargo.lock index 54cec98276dc..5c9fa10fc9cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4115,6 +4115,7 @@ dependencies = [ "re_log_types", "re_tracing", "re_types", + "re_types_core", "smallvec", "thiserror", "tinyvec", @@ -4194,6 +4195,7 @@ dependencies = [ "re_smart_channel", "re_tracing", "re_types", + "re_types_core", "serde", "thiserror", ] @@ -4220,6 +4222,7 @@ dependencies = [ "re_renderer", "re_tracing", "re_types", + "re_types_core", "re_ui", "re_viewer_context", "rfd", @@ -4314,6 +4317,7 @@ dependencies = [ "re_tracing", "re_tuid", "re_types", + "re_types_core", "rmp-serde", "serde", "serde_bytes", @@ -4366,6 +4370,7 @@ dependencies = [ "re_log_types", "re_tracing", "re_types", + "re_types_core", "thiserror", ] @@ -4448,6 +4453,7 @@ dependencies = [ "re_sdk_comms", "re_smart_channel", "re_types", + "re_types_core", "re_web_viewer_server", "re_ws_comms", "similar-asserts", @@ -4686,9 +4692,8 @@ dependencies = [ "document-features", "getrandom", "once_cell", - "re_types", + "re_types_core", "serde", - "thiserror", "web-time", ] @@ -4699,7 +4704,6 @@ dependencies = [ "anyhow", "array-init", "arrow2", - "backtrace", "bytemuck", "document-features", "ecolor", @@ -4714,11 +4718,10 @@ dependencies = [ "rand", "rayon", "re_build_tools", - "re_error", "re_log", - "re_string_interner", "re_tracing", "re_types_builder", + "re_types_core", "serde", "similar-asserts", "smallvec", @@ -4754,6 +4757,22 @@ dependencies = [ "xshell", ] +[[package]] +name = "re_types_core" +version = "0.10.0-alpha.7+dev" +dependencies = [ + "anyhow", + "arrow2", + "backtrace", + "document-features", + "re_error", + "re_string_interner", + "re_tracing", + "serde", + "smallvec", + "thiserror", +] + [[package]] name = "re_ui" version = "0.10.0-alpha.7+dev" @@ -4776,7 +4795,6 @@ version = "0.10.0-alpha.7+dev" dependencies = [ "ahash 0.8.3", "anyhow", - "arrow2", "bytemuck", "cfg-if", "eframe", @@ -4856,6 +4874,7 @@ dependencies = [ "re_string_interner", "re_tracing", "re_types", + "re_types_core", "re_ui", "serde", "slotmap", @@ -4886,6 +4905,7 @@ dependencies = [ "re_space_view", "re_tracing", "re_types", + "re_types_core", "re_ui", "re_viewer_context", "serde", diff --git a/Cargo.toml b/Cargo.toml index 15f9c9c2fba5..f49dbb1f9bc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ re_tensor_ops = { path = "crates/re_tensor_ops", version = "=0.10.0-alpha.7", de re_time_panel = { path = "crates/re_time_panel", version = "=0.10.0-alpha.7", default-features = false } re_tracing = { path = "crates/re_tracing", version = "=0.10.0-alpha.7", default-features = false } re_tuid = { path = "crates/re_tuid", version = "=0.10.0-alpha.7", default-features = false } +re_types_core = { path = "crates/re_types_core", version = "=0.10.0-alpha.7", default-features = false } re_types = { path = "crates/re_types", version = "=0.10.0-alpha.7", default-features = false } re_types_builder = { path = "crates/re_types_builder", version = "=0.10.0-alpha.7", default-features = false } re_ui = { path = "crates/re_ui", version = "=0.10.0-alpha.7", default-features = false } @@ -158,9 +159,12 @@ puffin_http = "0.13" rand = { version = "0.8", default-features = false } rayon = "1.7" rfd = { version = "0.12", default_features = false, features = ["xdg-portal"] } +rmp-serde = "1" ron = "0.8.0" serde = "1" +serde_bytes = "0.11" serde_json = { version = "1", default-features = false, features = ["std"] } +serde_test = "1" serde_yaml = { version = "0.9.21", default-features = false } sha2 = "0.10" similar-asserts = "1.4.2" diff --git a/crates/re_types_core/.gitattributes b/crates/re_types_core/.gitattributes new file mode 100644 index 000000000000..d0ecc4487f58 --- /dev/null +++ b/crates/re_types_core/.gitattributes @@ -0,0 +1,129 @@ +# DO NOT EDIT! This file is generated by crates/re_types_builder/src/lib.rs + +.gitattributes linguist-generated=true +src/archetypes/annotation_context.rs linguist-generated=true +src/archetypes/arrows3d.rs linguist-generated=true +src/archetypes/asset3d.rs linguist-generated=true +src/archetypes/bar_chart.rs linguist-generated=true +src/archetypes/boxes2d.rs linguist-generated=true +src/archetypes/boxes3d.rs linguist-generated=true +src/archetypes/clear.rs linguist-generated=true +src/archetypes/depth_image.rs linguist-generated=true +src/archetypes/disconnected_space.rs linguist-generated=true +src/archetypes/image.rs linguist-generated=true +src/archetypes/line_strips2d.rs linguist-generated=true +src/archetypes/line_strips3d.rs linguist-generated=true +src/archetypes/mesh3d.rs linguist-generated=true +src/archetypes/mod.rs linguist-generated=true +src/archetypes/pinhole.rs linguist-generated=true +src/archetypes/points2d.rs linguist-generated=true +src/archetypes/points3d.rs linguist-generated=true +src/archetypes/segmentation_image.rs linguist-generated=true +src/archetypes/tensor.rs linguist-generated=true +src/archetypes/text_document.rs linguist-generated=true +src/archetypes/text_log.rs linguist-generated=true +src/archetypes/time_series_scalar.rs linguist-generated=true +src/archetypes/transform3d.rs linguist-generated=true +src/archetypes/view_coordinates.rs linguist-generated=true +src/components/annotation_context.rs linguist-generated=true +src/components/blob.rs linguist-generated=true +src/components/class_id.rs linguist-generated=true +src/components/clear_is_recursive.rs linguist-generated=true +src/components/color.rs linguist-generated=true +src/components/depth_meter.rs linguist-generated=true +src/components/disconnected_space.rs linguist-generated=true +src/components/draw_order.rs linguist-generated=true +src/components/half_sizes2d.rs linguist-generated=true +src/components/half_sizes3d.rs linguist-generated=true +src/components/instance_key.rs linguist-generated=true +src/components/keypoint_id.rs linguist-generated=true +src/components/line_strip2d.rs linguist-generated=true +src/components/line_strip3d.rs linguist-generated=true +src/components/material.rs linguist-generated=true +src/components/media_type.rs linguist-generated=true +src/components/mesh_properties.rs linguist-generated=true +src/components/mod.rs linguist-generated=true +src/components/out_of_tree_transform3d.rs linguist-generated=true +src/components/pinhole_projection.rs linguist-generated=true +src/components/position2d.rs linguist-generated=true +src/components/position3d.rs linguist-generated=true +src/components/radius.rs linguist-generated=true +src/components/resolution.rs linguist-generated=true +src/components/rotation3d.rs linguist-generated=true +src/components/scalar.rs linguist-generated=true +src/components/scalar_scattering.rs linguist-generated=true +src/components/tensor_data.rs linguist-generated=true +src/components/text.rs linguist-generated=true +src/components/text_log_level.rs linguist-generated=true +src/components/transform3d.rs linguist-generated=true +src/components/vector3d.rs linguist-generated=true +src/components/view_coordinates.rs linguist-generated=true +src/datatypes/angle.rs linguist-generated=true +src/datatypes/annotation_info.rs linguist-generated=true +src/datatypes/class_description.rs linguist-generated=true +src/datatypes/class_description_map_elem.rs linguist-generated=true +src/datatypes/class_id.rs linguist-generated=true +src/datatypes/float32.rs linguist-generated=true +src/datatypes/keypoint_id.rs linguist-generated=true +src/datatypes/keypoint_pair.rs linguist-generated=true +src/datatypes/mat3x3.rs linguist-generated=true +src/datatypes/mat4x4.rs linguist-generated=true +src/datatypes/material.rs linguist-generated=true +src/datatypes/mesh_properties.rs linguist-generated=true +src/datatypes/mod.rs linguist-generated=true +src/datatypes/quaternion.rs linguist-generated=true +src/datatypes/rgba32.rs linguist-generated=true +src/datatypes/rotation3d.rs linguist-generated=true +src/datatypes/rotation_axis_angle.rs linguist-generated=true +src/datatypes/scale3d.rs linguist-generated=true +src/datatypes/tensor_buffer.rs linguist-generated=true +src/datatypes/tensor_data.rs linguist-generated=true +src/datatypes/tensor_dimension.rs linguist-generated=true +src/datatypes/transform3d.rs linguist-generated=true +src/datatypes/translation_and_mat3x3.rs linguist-generated=true +src/datatypes/translation_rotation_scale3d.rs linguist-generated=true +src/datatypes/utf8.rs linguist-generated=true +src/datatypes/uvec2d.rs linguist-generated=true +src/datatypes/uvec3d.rs linguist-generated=true +src/datatypes/uvec4d.rs linguist-generated=true +src/datatypes/vec2d.rs linguist-generated=true +src/datatypes/vec3d.rs linguist-generated=true +src/datatypes/vec4d.rs linguist-generated=true +src/testing/archetypes/affix_fuzzer1.rs linguist-generated=true +src/testing/archetypes/affix_fuzzer2.rs linguist-generated=true +src/testing/archetypes/affix_fuzzer3.rs linguist-generated=true +src/testing/archetypes/affix_fuzzer4.rs linguist-generated=true +src/testing/archetypes/mod.rs linguist-generated=true +src/testing/components/affix_fuzzer1.rs linguist-generated=true +src/testing/components/affix_fuzzer10.rs linguist-generated=true +src/testing/components/affix_fuzzer11.rs linguist-generated=true +src/testing/components/affix_fuzzer12.rs linguist-generated=true +src/testing/components/affix_fuzzer13.rs linguist-generated=true +src/testing/components/affix_fuzzer14.rs linguist-generated=true +src/testing/components/affix_fuzzer15.rs linguist-generated=true +src/testing/components/affix_fuzzer16.rs linguist-generated=true +src/testing/components/affix_fuzzer17.rs linguist-generated=true +src/testing/components/affix_fuzzer18.rs linguist-generated=true +src/testing/components/affix_fuzzer19.rs linguist-generated=true +src/testing/components/affix_fuzzer2.rs linguist-generated=true +src/testing/components/affix_fuzzer20.rs linguist-generated=true +src/testing/components/affix_fuzzer21.rs linguist-generated=true +src/testing/components/affix_fuzzer3.rs linguist-generated=true +src/testing/components/affix_fuzzer4.rs linguist-generated=true +src/testing/components/affix_fuzzer5.rs linguist-generated=true +src/testing/components/affix_fuzzer6.rs linguist-generated=true +src/testing/components/affix_fuzzer7.rs linguist-generated=true +src/testing/components/affix_fuzzer8.rs linguist-generated=true +src/testing/components/affix_fuzzer9.rs linguist-generated=true +src/testing/components/mod.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer1.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer2.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer20.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer21.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer3.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer4.rs linguist-generated=true +src/testing/datatypes/affix_fuzzer5.rs linguist-generated=true +src/testing/datatypes/flattened_scalar.rs linguist-generated=true +src/testing/datatypes/mod.rs linguist-generated=true +src/testing/datatypes/primitive_component.rs linguist-generated=true +src/testing/datatypes/string_component.rs linguist-generated=true diff --git a/crates/re_types_core/Cargo.toml b/crates/re_types_core/Cargo.toml new file mode 100644 index 000000000000..24cda58479fa --- /dev/null +++ b/crates/re_types_core/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "re_types_core" +authors.workspace = true +description = "The core traits and types that power Rerun's data model." +edition.workspace = true +homepage.workspace = true +include.workspace = true +license.workspace = true +publish = true +readme = "README.md" +repository.workspace = true +rust-version.workspace = true +version.workspace = true + + +[package.metadata.docs.rs] +all-features = true + + +[features] +default = [] + +## Enable (de)serialization using serde. +serde = ["dep:serde", "re_string_interner/serde"] + + +[dependencies] +# Rerun +re_error.workspace = true +re_string_interner.workspace = true +re_tracing.workspace = true + +# External +anyhow.workspace = true +arrow2 = { workspace = true, features = [ + "io_ipc", + "io_print", + "compute_concatenate", +] } +backtrace.workspace = true +document-features.workspace = true +smallvec.workspace = true +thiserror.workspace = true + +# Optional dependencies +serde = { workspace = true, optional = true } diff --git a/crates/re_types_core/README.md b/crates/re_types_core/README.md new file mode 100644 index 000000000000..102ad6799cc9 --- /dev/null +++ b/crates/re_types_core/README.md @@ -0,0 +1,10 @@ +# re_types_core + +Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates. + +[![Latest version](https://img.shields.io/crates/v/re_types.svg)](https://crates.io/crates/re_types) +[![Documentation](https://docs.rs/re_types/badge.svg)](https://docs.rs/re_types) +![MIT](https://img.shields.io/badge/license-MIT-blue.svg) +![Apache](https://img.shields.io/badge/license-Apache-blue.svg) + +The core traits and types that power Rerun's data model. diff --git a/crates/re_types_core/src/archetype.rs b/crates/re_types_core/src/archetype.rs new file mode 100644 index 000000000000..f0c6a9676c27 --- /dev/null +++ b/crates/re_types_core/src/archetype.rs @@ -0,0 +1,275 @@ +use crate::{ + ComponentBatch, ComponentName, DeserializationResult, MaybeOwnedComponentBatch, + SerializationResult, _Backtrace, +}; + +#[allow(unused_imports)] // used in docstrings +use crate::{Component, Loggable, LoggableBatch}; + +// --- + +/// An archetype is a high-level construct that represents a set of [`Component`]s that usually +/// play well with each other (i.e. they compose nicely). +/// +/// Internally, it is no different than a collection of components, but working at that higher +/// layer of abstraction opens opportunities for nicer APIs & tools that wouldn't be possible +/// otherwise. +/// +/// E.g. consider the `crate::archetypes::Points3D` archetype, which represents the set of +/// components to consider when working with a 3D point cloud within Rerun. +pub trait Archetype { + /// The associated indicator component, whose presence indicates that the high-level + /// archetype-based APIs were used to log the data. + /// + /// ## Internal representation + /// + /// Indicator components are always-splatted null arrays. + /// Their names follow the pattern `rerun.components.{ArchetypeName}Indicator`, e.g. + /// `rerun.components.Points3DIndicator`. + /// + /// Since null arrays aren't actually arrays and we don't actually have any data to shuffle + /// around per-se, we can't implement the usual [`Loggable`] traits. + /// For this reason, indicator components directly implement [`LoggableBatch`] instead, and + /// bypass the entire iterator machinery. + // + // TODO(rust-lang/rust#29661): We'd like to just default this to the right thing which is + // pretty much always `A::Indicator`, but defaults are unstable. + // type Indicator: ComponentBatch = A::Indicator; + type Indicator: 'static + ComponentBatch + Default; + + /// The fully-qualified name of this archetype, e.g. `rerun.archetypes.Points2D`. + fn name() -> ArchetypeName; + + // --- + + // TODO(cmc): Should we also generate and return static IntSets? + + /// Creates a [`ComponentBatch`] out of the associated [`Self::Indicator`] component. + /// + /// This allows for associating arbitrary indicator components with arbitrary data. + /// Check out the `manual_indicator` API example to see what's possible. + #[inline] + fn indicator() -> MaybeOwnedComponentBatch<'static> { + MaybeOwnedComponentBatch::Owned(Box::<::Indicator>::default()) + } + + /// Returns the names of all components that _must_ be provided by the user when constructing + /// this archetype. + fn required_components() -> std::borrow::Cow<'static, [ComponentName]>; + + /// Returns the names of all components that _should_ be provided by the user when constructing + /// this archetype. + #[inline] + fn recommended_components() -> std::borrow::Cow<'static, [ComponentName]> { + std::borrow::Cow::Owned(vec![Self::indicator().name()]) + } + + /// Returns the names of all components that _may_ be provided by the user when constructing + /// this archetype. + #[inline] + fn optional_components() -> std::borrow::Cow<'static, [ComponentName]> { + std::borrow::Cow::Borrowed(&[]) + } + + /// Returns the names of all components that must, should and may be provided by the user when + /// constructing this archetype. + /// + /// The default implementation always does the right thing, at the cost of some runtime + /// allocations. + /// If you know all your components statically, you can override this method to get rid of the + /// extra allocations. + #[inline] + fn all_components() -> std::borrow::Cow<'static, [ComponentName]> { + [ + Self::required_components().into_owned(), + Self::recommended_components().into_owned(), + Self::optional_components().into_owned(), + ] + .into_iter() + .flatten() + .collect::>() + .into() + } + + // --- + + /// Given an iterator of Arrow arrays and their respective field metadata, deserializes them + /// into this archetype. + /// + /// Arrow arrays that are unknown to this [`Archetype`] will simply be ignored and a warning + /// logged to stderr. + #[inline] + fn from_arrow( + data: impl IntoIterator)>, + ) -> DeserializationResult + where + Self: Sized, + { + _ = data; // NOTE: do this here to avoid breaking users' autocomplete snippets + Err(crate::DeserializationError::NotImplemented { + fqname: Self::name().to_string(), + backtrace: _Backtrace::new_unresolved(), + }) + } +} + +// --- + +re_string_interner::declare_new_type!( + /// The fully-qualified name of an [`Archetype`], e.g. `rerun.archetypes.Points3D`. + pub struct ArchetypeName; +); + +impl ArchetypeName { + /// Returns the fully-qualified name, e.g. `rerun.archetypes.Points3D`. + /// + /// This is the default `Display` implementation for [`ArchetypeName`]. + #[inline] + pub fn full_name(&self) -> &'static str { + self.0.as_str() + } + + /// Returns the unqualified name, e.g. `Points3D`. + /// + /// Used for most UI elements. + /// + /// ``` + /// # use re_types_core::ArchetypeName; + /// assert_eq!(ArchetypeName::from("rerun.archetypes.Points3D").short_name(), "Points3D"); + /// ``` + #[inline] + pub fn short_name(&self) -> &'static str { + let full_name = self.0.as_str(); + if let Some(short_name) = full_name.strip_prefix("rerun.archetypes.") { + short_name + } else if let Some(short_name) = full_name.strip_prefix("rerun.") { + short_name + } else { + full_name + } + } +} + +// --- + +/// A generic [indicator component] that can be specialized for any [`Archetype`]. +/// +/// ```ignore +/// type MyArchetypeIndicator = GenericIndicatorComponent; +/// ``` +/// +/// [indicator component]: [`Archetype::Indicator`] +#[derive(Debug, Clone, Copy)] +pub struct GenericIndicatorComponent { + _phantom: std::marker::PhantomData, +} + +impl GenericIndicatorComponent { + pub const DEFAULT: Self = Self { + _phantom: std::marker::PhantomData::, + }; +} + +impl Default for GenericIndicatorComponent { + fn default() -> Self { + Self::DEFAULT + } +} + +impl crate::LoggableBatch for GenericIndicatorComponent { + type Name = ComponentName; + + #[inline] + fn name(&self) -> Self::Name { + format!("{}Indicator", A::name().full_name()) + .replace("archetypes", "components") + .into() + } + + #[inline] + fn num_instances(&self) -> usize { + 1 + } + + #[inline] + fn arrow_field(&self) -> arrow2::datatypes::Field { + let name = self.name().to_string(); + arrow2::datatypes::Field::new( + name.clone(), + arrow2::datatypes::DataType::Extension( + name, + Box::new(arrow2::datatypes::DataType::Null), + None, + ), + false, + ) + } + + #[inline] + fn to_arrow(&self) -> SerializationResult> { + Ok( + arrow2::array::NullArray::new(arrow2::datatypes::DataType::Null, self.num_instances()) + .boxed(), + ) + } +} + +impl crate::ComponentBatch for GenericIndicatorComponent {} + +// --- + +/// An arbitrary named [indicator component]. +/// +/// [indicator component]: [`Archetype::Indicator`] +#[derive(Debug, Clone, Copy)] +pub struct NamedIndicatorComponent(pub ComponentName); + +impl NamedIndicatorComponent { + #[inline] + pub fn as_batch(&self) -> MaybeOwnedComponentBatch<'_> { + MaybeOwnedComponentBatch::Ref(self) + } + + #[inline] + pub fn to_batch(self) -> MaybeOwnedComponentBatch<'static> { + MaybeOwnedComponentBatch::Owned(Box::new(self)) + } +} + +impl crate::LoggableBatch for NamedIndicatorComponent { + type Name = ComponentName; + + #[inline] + fn name(&self) -> Self::Name { + self.0 + } + + #[inline] + fn num_instances(&self) -> usize { + 1 + } + + #[inline] + fn arrow_field(&self) -> arrow2::datatypes::Field { + let name = self.name().to_string(); + arrow2::datatypes::Field::new( + name.clone(), + arrow2::datatypes::DataType::Extension( + name, + Box::new(arrow2::datatypes::DataType::Null), + None, + ), + false, + ) + } + + #[inline] + fn to_arrow(&self) -> SerializationResult> { + Ok( + arrow2::array::NullArray::new(arrow2::datatypes::DataType::Null, self.num_instances()) + .boxed(), + ) + } +} + +impl crate::ComponentBatch for NamedIndicatorComponent {} diff --git a/crates/re_types_core/src/arrow_buffer.rs b/crates/re_types_core/src/arrow_buffer.rs new file mode 100644 index 000000000000..1dc09bb43a0c --- /dev/null +++ b/crates/re_types_core/src/arrow_buffer.rs @@ -0,0 +1,89 @@ +use arrow2::buffer::Buffer; + +/// Convenience-wrapper around an arrow [`Buffer`] that is known to contain a +/// a primitive type. +/// +/// The arrow2 [`Buffer`] object is internally reference-counted and can be +/// easily converted back to a `&[T]` referencing the underlying storage. +/// This avoids some of the lifetime complexities that would otherwise +/// arise from returning a `&[T]` directly, but is significantly more +/// performant than doing the full allocation necessary to return a `Vec`. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct ArrowBuffer(Buffer); + +impl ArrowBuffer { + /// The number of instances of T stored in this buffer. + #[inline] + pub fn num_instances(&self) -> usize { + // WARNING: If you are touching this code, make sure you know what len() actually does. + // + // There is ambiguity in how arrow2 and arrow-rs talk about buffer lengths, including + // some incorrect documentation: https://github.com/jorgecarleitao/arrow2/issues/1430 + // + // Arrow2 `Buffer` is typed and `len()` is the number of units of `T`, but the documentation + // is currently incorrect. + // Arrow-rs `Buffer` is untyped and len() is in bytes, but `ScalarBuffer`s are in units of T. + self.0.len() + } + + /// The number of bytes stored in this buffer + #[inline] + pub fn size_in_bytes(&self) -> usize { + self.0.len() * std::mem::size_of::() + } + + #[inline] + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + #[inline] + pub fn as_slice(&self) -> &[T] { + self.0.as_slice() + } +} + +impl Eq for ArrowBuffer {} + +impl ArrowBuffer { + #[inline] + pub fn to_vec(&self) -> Vec { + self.0.as_slice().to_vec() + } +} + +impl From> for ArrowBuffer { + #[inline] + fn from(value: Buffer) -> Self { + Self(value) + } +} + +impl From> for ArrowBuffer { + #[inline] + fn from(value: Vec) -> Self { + Self(value.into()) + } +} + +impl From<&[T]> for ArrowBuffer { + #[inline] + fn from(value: &[T]) -> Self { + Self(value.iter().cloned().collect()) // TODO(emilk): avoid extra clones + } +} + +impl FromIterator for ArrowBuffer { + fn from_iter>(iter: I) -> Self { + Self(Buffer::from_iter(iter)) + } +} + +impl std::ops::Deref for ArrowBuffer { + type Target = [T]; + + #[inline] + fn deref(&self) -> &[T] { + self.0.as_slice() + } +} diff --git a/crates/re_types_core/src/arrow_string.rs b/crates/re_types_core/src/arrow_string.rs new file mode 100644 index 000000000000..abb22fe2c883 --- /dev/null +++ b/crates/re_types_core/src/arrow_string.rs @@ -0,0 +1,91 @@ +use arrow2::buffer::Buffer; + +/// Convenience-wrapper around an arrow [`Buffer`] that is known to contain a +/// UTF-8 encoded string. +/// +/// The arrow2 [`Buffer`] object is internally reference-counted and can be +/// easily converted back to a `&str` referencing the underlying storage. +/// This avoids some of the lifetime complexities that would otherwise +/// arise from returning a `&str` directly, but is significantly more +/// performant than doing the full allocation necessary to return a `String`. +#[derive(Clone, Debug, Default)] +pub struct ArrowString(pub Buffer); + +impl PartialEq for ArrowString { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.as_str() == other.as_str() + } +} + +impl Eq for ArrowString {} + +impl PartialOrd for ArrowString { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + self.as_str().partial_cmp(other.as_str()) + } +} + +impl Ord for ArrowString { + #[inline] + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.as_str().cmp(other.as_str()) + } +} + +impl std::hash::Hash for ArrowString { + #[inline] + fn hash(&self, state: &mut H) { + self.as_str().hash(state); + } +} + +impl ArrowString { + #[inline] + pub fn as_str(&self) -> &str { + std::str::from_utf8(self.0.as_ref()).unwrap_or("INVALID UTF-8") + } +} + +impl From for ArrowString { + #[inline] + fn from(value: String) -> Self { + Self(value.as_bytes().to_vec().into()) + } +} + +impl From<&str> for ArrowString { + #[inline] + fn from(value: &str) -> Self { + Self(value.as_bytes().to_vec().into()) + } +} + +impl std::fmt::Display for ArrowString { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.as_str().fmt(f) + } +} + +impl AsRef for ArrowString { + #[inline] + fn as_ref(&self) -> &str { + self.as_str() + } +} + +impl std::borrow::Borrow for ArrowString { + #[inline] + fn borrow(&self) -> &str { + self.as_str() + } +} + +impl std::ops::Deref for ArrowString { + type Target = str; + #[inline] + fn deref(&self) -> &str { + self.as_str() + } +} diff --git a/crates/re_types_core/src/lib.rs b/crates/re_types_core/src/lib.rs new file mode 100644 index 000000000000..9543e877c770 --- /dev/null +++ b/crates/re_types_core/src/lib.rs @@ -0,0 +1,123 @@ +//! The core types and traits that power Rerun's data model. +//! +//! This crate contains both the IDL definitions for Rerun types (flatbuffers) as well as the code +//! generated from those using `re_types_builder`. +//! +//! The [`Archetype`] trait is the core of this crate and is a good starting point to get familiar +//! with the code. +//! An archetype is a logical collection of batches of [`Component`]s that play well with each other. +//! +//! Rerun (and the underlying Arrow data framework) is designed to work with large arrays of +//! [`Component`]s, as opposed to single instances. +//! When multiple instances of a [`Component`] are put together in an array, they yield a +//! [`ComponentBatch`]: the atomic unit of (de)serialization. +//! +//! Internally, [`Component`]s are implemented using many different [`Datatype`]s. +//! +//! All builtin archetypes, components and datatypes can be found in their respective top-level +//! modules. + +// --- + +/// Describes the interface for interpreting an object as a bundle of [`Component`]s. +/// +/// ## Custom bundles +/// +/// While, in most cases, component bundles are code generated from our [IDL definitions], +/// it is possible to manually extend existing bundles, or even implement fully custom ones. +/// +/// All [`AsComponents`] methods are optional to implement, with the exception of +/// [`AsComponents::as_component_batches`], which describes how the bundle can be interpreted +/// as a set of [`ComponentBatch`]es: arrays of components that are ready to be serialized. +/// +/// Have a look at our [Custom Data] example to learn more about handwritten bundles. +/// +/// [IDL definitions]: https://github.com/rerun-io/rerun/tree/latest/crates/re_types/definitions/rerun +/// [Custom Data]: https://github.com/rerun-io/rerun/blob/latest/examples/rust/custom_data/src/main.rs +pub trait AsComponents { + /// Exposes the object's contents as a set of [`ComponentBatch`]s. + /// + /// This is the main mechanism for easily extending builtin archetypes or even writing + /// fully custom ones. + /// Have a look at our [Custom Data] example to learn more about extending archetypes. + /// + /// [Custom Data]: https://github.com/rerun-io/rerun/blob/latest/examples/rust/custom_data/src/main.rs + // + // NOTE: Don't bother returning a CoW here: we need to dynamically discard optional components + // depending on their presence (or lack thereof) at runtime anyway. + fn as_component_batches(&self) -> Vec>; + + /// The number of instances in each batch. + /// + /// If not implemented, the number of instances will be determined by the longest + /// batch in the bundle. + /// + /// Each batch returned by `as_component_batches` should have this number of elements, + /// or 1 in the case it is a splat, or 0 in the case that component is being cleared. + #[inline] + fn num_instances(&self) -> usize { + self.as_component_batches() + .into_iter() + .map(|comp_batch| comp_batch.as_ref().num_instances()) + .max() + .unwrap_or(0) + } + + // --- + + /// Serializes all non-null [`Component`]s of this bundle into Arrow arrays. + /// + /// The default implementation will simply serialize the result of [`Self::as_component_batches`] + /// as-is, which is what you want in 99.9% of cases. + #[inline] + fn to_arrow( + &self, + ) -> SerializationResult)>> + { + self.as_component_batches() + .into_iter() + .map(|comp_batch| { + comp_batch + .as_ref() + .to_arrow() + .map(|array| (comp_batch.as_ref().arrow_field(), array)) + .with_context(comp_batch.as_ref().name()) + }) + .collect() + } +} + +// --- + +mod archetype; +mod loggable; +mod loggable_batch; +mod result; +mod size_bytes; + +pub use self::archetype::{ + Archetype, ArchetypeName, GenericIndicatorComponent, NamedIndicatorComponent, +}; +pub use self::loggable::{ + Component, ComponentName, ComponentNameSet, Datatype, DatatypeName, Loggable, +}; +pub use self::loggable_batch::{ + ComponentBatch, DatatypeBatch, LoggableBatch, MaybeOwnedComponentBatch, +}; +pub use self::result::{ + DeserializationError, DeserializationResult, ResultExt, SerializationError, + SerializationResult, _Backtrace, +}; +pub use self::size_bytes::SizeBytes; + +// --- + +mod arrow_buffer; +mod arrow_string; +pub use self::arrow_buffer::ArrowBuffer; +pub use self::arrow_string::ArrowString; + +pub mod external { + pub use anyhow; + pub use arrow2; +} diff --git a/crates/re_types_core/src/loggable.rs b/crates/re_types_core/src/loggable.rs new file mode 100644 index 000000000000..1ff08fe5b36e --- /dev/null +++ b/crates/re_types_core/src/loggable.rs @@ -0,0 +1,245 @@ +use crate::{result::_Backtrace, DeserializationResult, ResultExt as _, SerializationResult}; + +#[allow(unused_imports)] // used in docstrings +use crate::{Archetype, ComponentBatch, DatatypeBatch, LoggableBatch}; + +// --- + +/// A [`Loggable`] represents a single instance in an array of loggable data. +/// +/// Internally, Arrow, and by extension Rerun, only deal with arrays of data. +/// We refer to individual entries in these arrays as instances. +/// +/// [`Datatype`] and [`Component`] are specialization of the [`Loggable`] trait that are +/// automatically implemented based on the type used for [`Loggable::Name`]. +/// +/// Implementing the [`Loggable`] trait (and by extension [`Datatype`]/[`Component`]) +/// automatically derives the [`LoggableBatch`] implementation (and by extension +/// [`DatatypeBatch`]/[`ComponentBatch`]), which makes it possible to work with lists' worth of data +/// in a generic fashion. +pub trait Loggable: Clone + Sized { + type Name: std::fmt::Display; + + /// The fully-qualified name of this loggable, e.g. `rerun.datatypes.Vec2D`. + fn name() -> Self::Name; + + /// The underlying [`arrow2::datatypes::DataType`], excluding datatype extensions. + fn arrow_datatype() -> arrow2::datatypes::DataType; + + /// Given an iterator of options of owned or reference values to the current + /// [`Loggable`], serializes them into an Arrow array. + /// The Arrow array's datatype will match [`Loggable::arrow_field`]. + /// + /// When using Rerun's builtin components & datatypes, this can only fail if the data + /// exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, + /// 2^63 for large arrays). + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult> + where + Self: 'a; + + // --- Optional metadata methods --- + + /// The underlying [`arrow2::datatypes::DataType`], including datatype extensions. + /// + /// The default implementation will simply wrap [`Self::arrow_datatype`] in an extension called + /// [`Self::name`], which is what you want in most cases. + #[inline] + fn extended_arrow_datatype() -> arrow2::datatypes::DataType { + arrow2::datatypes::DataType::Extension( + Self::name().to_string(), + Box::new(Self::arrow_datatype()), + None, + ) + } + + /// The underlying [`arrow2::datatypes::Field`], including datatype extensions. + /// + /// The default implementation will simply wrap [`Self::extended_arrow_datatype`] in a + /// [`arrow2::datatypes::Field`], which is what you want in most cases (e.g. because you want + /// to declare the field as nullable). + #[inline] + fn arrow_field() -> arrow2::datatypes::Field { + arrow2::datatypes::Field::new( + Self::name().to_string(), + Self::extended_arrow_datatype(), + false, + ) + } + + // --- Optional serialization methods --- + + /// Given an iterator of owned or reference values to the current [`Loggable`], serializes + /// them into an Arrow array. + /// The Arrow array's datatype will match [`Loggable::arrow_field`]. + /// + /// When using Rerun's builtin components & datatypes, this can only fail if the data + /// exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, + /// 2^63 for large arrays). + #[inline] + fn to_arrow<'a>( + data: impl IntoIterator>>, + ) -> SerializationResult> + where + Self: 'a, + { + re_tracing::profile_function!(); + Self::to_arrow_opt(data.into_iter().map(Some)) + } + + // --- Optional deserialization methods --- + + /// Given an Arrow array, deserializes it into a collection of [`Loggable`]s. + /// + /// This will _never_ fail if the Arrow array's datatype matches the one returned by + /// [`Loggable::arrow_field`]. + #[inline] + fn from_arrow(data: &dyn ::arrow2::array::Array) -> DeserializationResult> { + re_tracing::profile_function!(); + Self::from_arrow_opt(data)? + .into_iter() + .map(|opt| { + opt.ok_or_else(|| crate::DeserializationError::MissingData { + backtrace: _Backtrace::new_unresolved(), + }) + }) + .collect::>>() + .with_context(Self::name().to_string()) + } + + /// Given an Arrow array, deserializes it into a collection of optional [`Loggable`]s. + /// + /// This will _never_ fail if the Arrow array's datatype matches the one returned by + /// [`Loggable::arrow_field`]. + fn from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> DeserializationResult>> { + _ = data; // NOTE: do this here to avoid breaking users' autocomplete snippets + Err(crate::DeserializationError::NotImplemented { + fqname: Self::name().to_string(), + backtrace: _Backtrace::new_unresolved(), + }) + } +} + +/// A [`Datatype`] describes plain old data that can be used by any number of [`Component`]s. +/// +/// Any [`Loggable`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically implements +/// [`Datatype`]. +pub trait Datatype: Loggable {} + +impl> Datatype for L {} + +/// A [`Component`] describes semantic data that can be used by any number of [`Archetype`]s. +/// +/// Any [`Loggable`] with a [`Loggable::Name`] set to [`ComponentName`] automatically implements +/// [`Component`]. +pub trait Component: Loggable {} + +impl> Component for L {} + +// --- + +pub type ComponentNameSet = std::collections::BTreeSet; + +re_string_interner::declare_new_type!( + /// The fully-qualified name of a [`Component`], e.g. `rerun.components.Position2D`. + pub struct ComponentName; +); + +impl ComponentName { + /// Returns the fully-qualified name, e.g. `rerun.components.Position2D`. + /// + /// This is the default `Display` implementation for [`ComponentName`]. + #[inline] + pub fn full_name(&self) -> &'static str { + self.0.as_str() + } + + /// Returns the unqualified name, e.g. `Position2D`. + /// + /// Used for most UI elements. + /// + /// ``` + /// # use re_types_core::ComponentName; + /// assert_eq!(ComponentName::from("rerun.components.Position2D").short_name(), "Position2D"); + /// ``` + #[inline] + pub fn short_name(&self) -> &'static str { + let full_name = self.0.as_str(); + if let Some(short_name) = full_name.strip_prefix("rerun.components.") { + short_name + } else if let Some(short_name) = full_name.strip_prefix("rerun.") { + short_name + } else { + full_name + } + } + + /// Is this an indicator component for an archetype? + pub fn is_indicator_component(&self) -> bool { + self.starts_with("rerun.components.") && self.ends_with("Indicator") + } + + /// If this is an indicator component, for which archetype? + pub fn indicator_component_archetype(&self) -> Option { + if let Some(name) = self.strip_prefix("rerun.components.") { + if let Some(name) = name.strip_suffix("Indicator") { + return Some(name.to_owned()); + } + } + None + } +} + +// --- + +impl crate::SizeBytes for ComponentName { + #[inline] + fn heap_size_bytes(&self) -> u64 { + 0 + } +} + +re_string_interner::declare_new_type!( + /// The fully-qualified name of a [`Datatype`], e.g. `rerun.datatypes.Vec2D`. + pub struct DatatypeName; +); + +impl DatatypeName { + /// Returns the fully-qualified name, e.g. `rerun.datatypes.Vec2D`. + /// + /// This is the default `Display` implementation for [`DatatypeName`]. + #[inline] + pub fn full_name(&self) -> &'static str { + self.0.as_str() + } + + /// Returns the unqualified name, e.g. `Vec2D`. + /// + /// Used for most UI elements. + /// + /// ``` + /// # use re_types_core::DatatypeName; + /// assert_eq!(DatatypeName::from("rerun.datatypes.Vec2D").short_name(), "Vec2D"); + /// ``` + #[inline] + pub fn short_name(&self) -> &'static str { + let full_name = self.0.as_str(); + if let Some(short_name) = full_name.strip_prefix("rerun.datatypes.") { + short_name + } else if let Some(short_name) = full_name.strip_prefix("rerun.") { + short_name + } else { + full_name + } + } +} + +impl crate::SizeBytes for DatatypeName { + #[inline] + fn heap_size_bytes(&self) -> u64 { + 0 + } +} diff --git a/crates/re_types_core/src/loggable_batch.rs b/crates/re_types_core/src/loggable_batch.rs new file mode 100644 index 000000000000..9708e25e1f97 --- /dev/null +++ b/crates/re_types_core/src/loggable_batch.rs @@ -0,0 +1,372 @@ +use crate::{Component, ComponentName, Datatype, DatatypeName, Loggable, SerializationResult}; + +#[allow(unused_imports)] // used in docstrings +use crate::Archetype; + +// --- + +/// A [`LoggableBatch`] represents an array's worth of [`Loggable`] instances, ready to be +/// serialized. +/// +/// [`LoggableBatch`] is carefully designed to be erasable ("object-safe"), so that it is possible +/// to build heterogeneous collections of [`LoggableBatch`]s (e.g. `Vec`). +/// This erasability is what makes extending [`Archetype`]s possible with little effort. +/// +/// You should almost never need to implement [`LoggableBatch`] manually, as it is already +/// blanket implemented for most common use cases (arrays/vectors/slices of loggables, etc). +pub trait LoggableBatch { + type Name; + + // NOTE: It'd be tempting to have the following associated type, but that'd be + // counterproductive, the whole point of this is to allow for heterogeneous collections! + // type Loggable: Loggable; + + /// The fully-qualified name of this batch, e.g. `rerun.datatypes.Vec2D`. + fn name(&self) -> Self::Name; + + /// The number of component instances stored into this batch. + fn num_instances(&self) -> usize; + + /// The underlying [`arrow2::datatypes::Field`], including datatype extensions. + fn arrow_field(&self) -> arrow2::datatypes::Field; + + /// Serializes the batch into an Arrow array. + fn to_arrow(&self) -> SerializationResult>; +} + +/// A [`DatatypeBatch`] represents an array's worth of [`Datatype`] instances. +/// +/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically +/// implements [`DatatypeBatch`]. +pub trait DatatypeBatch: LoggableBatch {} + +/// A [`ComponentBatch`] represents an array's worth of [`Component`] instances. +/// +/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`ComponentName`] automatically +/// implements [`ComponentBatch`]. +pub trait ComponentBatch: LoggableBatch {} + +/// Holds either an owned [`ComponentBatch`] that lives on heap, or a reference to one. +/// +/// This doesn't use [`std::borrow::Cow`] on purpose: `Cow` requires `Clone`, which would break +/// object-safety, which would prevent us from erasing [`ComponentBatch`]s in the first place. +pub enum MaybeOwnedComponentBatch<'a> { + Owned(Box), + Ref(&'a dyn ComponentBatch), +} + +impl<'a> From<&'a dyn ComponentBatch> for MaybeOwnedComponentBatch<'a> { + #[inline] + fn from(comp_batch: &'a dyn ComponentBatch) -> Self { + Self::Ref(comp_batch) + } +} + +impl From> for MaybeOwnedComponentBatch<'_> { + #[inline] + fn from(comp_batch: Box) -> Self { + Self::Owned(comp_batch) + } +} + +impl<'a> AsRef for MaybeOwnedComponentBatch<'a> { + fn as_ref(&self) -> &(dyn ComponentBatch + 'a) { + match self { + MaybeOwnedComponentBatch::Owned(this) => &**this, + MaybeOwnedComponentBatch::Ref(this) => *this, + } + } +} + +impl<'a> std::ops::Deref for MaybeOwnedComponentBatch<'a> { + type Target = dyn ComponentBatch + 'a; + + fn deref(&self) -> &(dyn ComponentBatch + 'a) { + match self { + MaybeOwnedComponentBatch::Owned(this) => &**this, + MaybeOwnedComponentBatch::Ref(this) => *this, + } + } +} + +// --- Unary --- + +impl LoggableBatch for L { + type Name = L::Name; + + #[inline] + fn name(&self) -> Self::Name { + L::name() + } + + #[inline] + fn num_instances(&self) -> usize { + 1 + } + + #[inline] + fn arrow_field(&self) -> arrow2::datatypes::Field { + L::arrow_field() + } + + #[inline] + fn to_arrow(&self) -> SerializationResult> { + L::to_arrow([std::borrow::Cow::Borrowed(self)]) + } +} + +impl DatatypeBatch for D {} + +impl ComponentBatch for C {} + +// --- Vec --- + +impl LoggableBatch for Vec { + type Name = L::Name; + + #[inline] + fn name(&self) -> Self::Name { + L::name() + } + + #[inline] + fn num_instances(&self) -> usize { + self.len() + } + + #[inline] + fn arrow_field(&self) -> arrow2::datatypes::Field { + L::arrow_field() + } + + #[inline] + fn to_arrow(&self) -> SerializationResult> { + L::to_arrow(self.iter().map(|v| std::borrow::Cow::Borrowed(v))) + } +} + +impl DatatypeBatch for Vec {} + +impl ComponentBatch for Vec {} + +// --- Vec, -} - -impl GenericIndicatorComponent { - pub const DEFAULT: Self = Self { - _phantom: std::marker::PhantomData::, - }; -} - -impl Default for GenericIndicatorComponent { - fn default() -> Self { - Self::DEFAULT - } -} - -impl crate::LoggableBatch for GenericIndicatorComponent { - type Name = ComponentName; - - #[inline] - fn name(&self) -> Self::Name { - format!("{}Indicator", A::name().full_name()) - .replace("archetypes", "components") - .into() - } - - #[inline] - fn num_instances(&self) -> usize { - 1 - } - - #[inline] - fn arrow_field(&self) -> arrow2::datatypes::Field { - let name = self.name().to_string(); - arrow2::datatypes::Field::new( - name.clone(), - arrow2::datatypes::DataType::Extension( - name, - Box::new(arrow2::datatypes::DataType::Null), - None, - ), - false, - ) - } - - #[inline] - fn to_arrow(&self) -> SerializationResult> { - Ok( - arrow2::array::NullArray::new(arrow2::datatypes::DataType::Null, self.num_instances()) - .boxed(), - ) - } -} - -impl crate::ComponentBatch for GenericIndicatorComponent {} - -// --- - -/// An arbitrary named [indicator component]. -/// -/// [indicator component]: [`Archetype::Indicator`] -#[derive(Debug, Clone, Copy)] -pub struct NamedIndicatorComponent(pub ComponentName); - -impl NamedIndicatorComponent { - #[inline] - pub fn as_batch(&self) -> MaybeOwnedComponentBatch<'_> { - MaybeOwnedComponentBatch::Ref(self) - } - - #[inline] - pub fn to_batch(self) -> MaybeOwnedComponentBatch<'static> { - MaybeOwnedComponentBatch::Owned(Box::new(self)) - } -} - -impl crate::LoggableBatch for NamedIndicatorComponent { - type Name = ComponentName; - - #[inline] - fn name(&self) -> Self::Name { - self.0 - } - - #[inline] - fn num_instances(&self) -> usize { - 1 - } - - #[inline] - fn arrow_field(&self) -> arrow2::datatypes::Field { - let name = self.name().to_string(); - arrow2::datatypes::Field::new( - name.clone(), - arrow2::datatypes::DataType::Extension( - name, - Box::new(arrow2::datatypes::DataType::Null), - None, - ), - false, - ) - } - - #[inline] - fn to_arrow(&self) -> SerializationResult> { - Ok( - arrow2::array::NullArray::new(arrow2::datatypes::DataType::Null, self.num_instances()) - .boxed(), - ) - } -} - -impl crate::ComponentBatch for NamedIndicatorComponent {} diff --git a/crates/re_types/src/archetypes/annotation_context.rs b/crates/re_types/src/archetypes/annotation_context.rs index 4fb66bcc9be2..eb5cedb9722c 100644 --- a/crates/re_types/src/archetypes/annotation_context.rs +++ b/crates/re_types/src/archetypes/annotation_context.rs @@ -75,16 +75,16 @@ pub struct AnnotationContext { pub context: crate::components::AnnotationContext, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.AnnotationContext".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.AnnotationContextIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.AnnotationContext".into(), @@ -97,40 +97,41 @@ impl AnnotationContext { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`AnnotationContext`] [`crate::Archetype`] -pub type AnnotationContextIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`AnnotationContext`] [`::re_types_core::Archetype`] +pub type AnnotationContextIndicator = + ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for AnnotationContext { +impl ::re_types_core::Archetype for AnnotationContext { type Indicator = AnnotationContextIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.AnnotationContext".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: AnnotationContextIndicator = AnnotationContextIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -139,9 +140,9 @@ impl crate::Archetype for AnnotationContext { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -149,27 +150,27 @@ impl crate::Archetype for AnnotationContext { let context = { let array = arrays_by_name .get("rerun.components.AnnotationContext") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.AnnotationContext#context")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.AnnotationContext#context")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.AnnotationContext#context")? }; Ok(Self { context }) } } -impl crate::AsComponents for AnnotationContext { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for AnnotationContext { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.context as &dyn crate::ComponentBatch).into()), + Some((&self.context as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/arrows3d.rs b/crates/re_types/src/archetypes/arrows3d.rs index 8b3717efc703..85f9cef440f8 100644 --- a/crates/re_types/src/archetypes/arrows3d.rs +++ b/crates/re_types/src/archetypes/arrows3d.rs @@ -91,10 +91,10 @@ pub struct Arrows3D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Vector3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Arrows3DIndicator".into(), @@ -102,7 +102,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -113,7 +113,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 8usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 8usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Vector3D".into(), @@ -131,40 +131,40 @@ impl Arrows3D { pub const NUM_COMPONENTS: usize = 8usize; } -/// Indicator component for the [`Arrows3D`] [`crate::Archetype`] -pub type Arrows3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Arrows3D`] [`::re_types_core::Archetype`] +pub type Arrows3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Arrows3D { +impl ::re_types_core::Archetype for Arrows3D { type Indicator = Arrows3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Arrows3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Arrows3DIndicator = Arrows3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -173,9 +173,9 @@ impl crate::Archetype for Arrows3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -183,13 +183,13 @@ impl crate::Archetype for Arrows3D { let vectors = { let array = arrays_by_name .get("rerun.components.Vector3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Arrows3D#vectors")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#vectors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#vectors")? }; let origins = if let Some(array) = arrays_by_name.get("rerun.components.Position3D") { @@ -197,8 +197,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#origins")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#origins")? }) } else { @@ -209,8 +209,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#radii")? }) } else { @@ -221,8 +221,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#colors")? }) } else { @@ -233,8 +233,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#labels")? }) } else { @@ -245,8 +245,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#class_ids")? }) } else { @@ -258,8 +258,8 @@ impl crate::Archetype for Arrows3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Arrows3D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Arrows3D#instance_keys")? }) } else { @@ -277,31 +277,31 @@ impl crate::Archetype for Arrows3D { } } -impl crate::AsComponents for Arrows3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Arrows3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.vectors as &dyn crate::ComponentBatch).into()), + Some((&self.vectors as &dyn ::re_types_core::ComponentBatch).into()), self.origins .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/asset3d.rs b/crates/re_types/src/archetypes/asset3d.rs index 10ba5d416cda..2ef168d503a0 100644 --- a/crates/re_types/src/archetypes/asset3d.rs +++ b/crates/re_types/src/archetypes/asset3d.rs @@ -72,10 +72,10 @@ pub struct Asset3D { pub transform: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Blob".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Asset3DIndicator".into(), @@ -83,7 +83,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.InstanceKey".into(), @@ -91,7 +91,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Blob".into(), @@ -106,40 +106,40 @@ impl Asset3D { pub const NUM_COMPONENTS: usize = 5usize; } -/// Indicator component for the [`Asset3D`] [`crate::Archetype`] -pub type Asset3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Asset3D`] [`::re_types_core::Archetype`] +pub type Asset3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Asset3D { +impl ::re_types_core::Archetype for Asset3D { type Indicator = Asset3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Asset3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Asset3DIndicator = Asset3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -148,9 +148,9 @@ impl crate::Archetype for Asset3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -158,14 +158,14 @@ impl crate::Archetype for Asset3D { let blob = { let array = arrays_by_name .get("rerun.components.Blob") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Asset3D#blob")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Asset3D#blob")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Asset3D#blob")? }; let media_type = if let Some(array) = arrays_by_name.get("rerun.components.MediaType") { @@ -175,7 +175,7 @@ impl crate::Archetype for Asset3D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Asset3D#media_type")? }) } else { @@ -189,7 +189,7 @@ impl crate::Archetype for Asset3D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Asset3D#transform")? }) } else { @@ -203,19 +203,19 @@ impl crate::Archetype for Asset3D { } } -impl crate::AsComponents for Asset3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Asset3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.blob as &dyn crate::ComponentBatch).into()), + Some((&self.blob as &dyn ::re_types_core::ComponentBatch).into()), self.media_type .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.transform .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/bar_chart.rs b/crates/re_types/src/archetypes/bar_chart.rs index 7fa353cb565e..4003d75029f2 100644 --- a/crates/re_types/src/archetypes/bar_chart.rs +++ b/crates/re_types/src/archetypes/bar_chart.rs @@ -51,16 +51,16 @@ pub struct BarChart { pub values: crate::components::TensorData, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorData".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.BarChartIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TensorData".into(), @@ -73,40 +73,40 @@ impl BarChart { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`BarChart`] [`crate::Archetype`] -pub type BarChartIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`BarChart`] [`::re_types_core::Archetype`] +pub type BarChartIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for BarChart { +impl ::re_types_core::Archetype for BarChart { type Indicator = BarChartIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.BarChart".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: BarChartIndicator = BarChartIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -115,9 +115,9 @@ impl crate::Archetype for BarChart { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -125,27 +125,27 @@ impl crate::Archetype for BarChart { let values = { let array = arrays_by_name .get("rerun.components.TensorData") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.BarChart#values")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.BarChart#values")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.BarChart#values")? }; Ok(Self { values }) } } -impl crate::AsComponents for BarChart { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for BarChart { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.values as &dyn crate::ComponentBatch).into()), + Some((&self.values as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/boxes2d.rs b/crates/re_types/src/archetypes/boxes2d.rs index 466c5071a6e9..f2d5846e2e57 100644 --- a/crates/re_types/src/archetypes/boxes2d.rs +++ b/crates/re_types/src/archetypes/boxes2d.rs @@ -79,10 +79,10 @@ pub struct Boxes2D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.HalfSizes2D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Boxes2DIndicator".into(), @@ -91,7 +91,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -102,7 +102,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 9usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 9usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.HalfSizes2D".into(), @@ -121,40 +121,40 @@ impl Boxes2D { pub const NUM_COMPONENTS: usize = 9usize; } -/// Indicator component for the [`Boxes2D`] [`crate::Archetype`] -pub type Boxes2DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Boxes2D`] [`::re_types_core::Archetype`] +pub type Boxes2DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Boxes2D { +impl ::re_types_core::Archetype for Boxes2D { type Indicator = Boxes2DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Boxes2D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Boxes2DIndicator = Boxes2DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -163,9 +163,9 @@ impl crate::Archetype for Boxes2D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -173,13 +173,13 @@ impl crate::Archetype for Boxes2D { let half_sizes = { let array = arrays_by_name .get("rerun.components.HalfSizes2D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Boxes2D#half_sizes")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#half_sizes")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#half_sizes")? }; let centers = if let Some(array) = arrays_by_name.get("rerun.components.Position2D") { @@ -187,8 +187,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#centers")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#centers")? }) } else { @@ -199,8 +199,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#colors")? }) } else { @@ -211,8 +211,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#radii")? }) } else { @@ -223,8 +223,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#labels")? }) } else { @@ -237,7 +237,7 @@ impl crate::Archetype for Boxes2D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Boxes2D#draw_order")? }) } else { @@ -248,8 +248,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#class_ids")? }) } else { @@ -261,8 +261,8 @@ impl crate::Archetype for Boxes2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes2D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes2D#instance_keys")? }) } else { @@ -281,34 +281,34 @@ impl crate::Archetype for Boxes2D { } } -impl crate::AsComponents for Boxes2D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Boxes2D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.half_sizes as &dyn crate::ComponentBatch).into()), + Some((&self.half_sizes as &dyn ::re_types_core::ComponentBatch).into()), self.centers .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/boxes3d.rs b/crates/re_types/src/archetypes/boxes3d.rs index 997bb32ad7bd..678a933c7173 100644 --- a/crates/re_types/src/archetypes/boxes3d.rs +++ b/crates/re_types/src/archetypes/boxes3d.rs @@ -86,10 +86,10 @@ pub struct Boxes3D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.HalfSizes3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Boxes3DIndicator".into(), @@ -99,7 +99,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -109,7 +109,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 9usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 9usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.HalfSizes3D".into(), @@ -128,40 +128,40 @@ impl Boxes3D { pub const NUM_COMPONENTS: usize = 9usize; } -/// Indicator component for the [`Boxes3D`] [`crate::Archetype`] -pub type Boxes3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Boxes3D`] [`::re_types_core::Archetype`] +pub type Boxes3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Boxes3D { +impl ::re_types_core::Archetype for Boxes3D { type Indicator = Boxes3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Boxes3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Boxes3DIndicator = Boxes3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -170,9 +170,9 @@ impl crate::Archetype for Boxes3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -180,13 +180,13 @@ impl crate::Archetype for Boxes3D { let half_sizes = { let array = arrays_by_name .get("rerun.components.HalfSizes3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Boxes3D#half_sizes")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#half_sizes")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#half_sizes")? }; let centers = if let Some(array) = arrays_by_name.get("rerun.components.Position3D") { @@ -194,8 +194,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#centers")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#centers")? }) } else { @@ -206,8 +206,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#rotations")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#rotations")? }) } else { @@ -218,8 +218,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#colors")? }) } else { @@ -230,8 +230,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#radii")? }) } else { @@ -242,8 +242,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#labels")? }) } else { @@ -254,8 +254,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#class_ids")? }) } else { @@ -267,8 +267,8 @@ impl crate::Archetype for Boxes3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Boxes3D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Boxes3D#instance_keys")? }) } else { @@ -287,34 +287,34 @@ impl crate::Archetype for Boxes3D { } } -impl crate::AsComponents for Boxes3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Boxes3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.half_sizes as &dyn crate::ComponentBatch).into()), + Some((&self.half_sizes as &dyn ::re_types_core::ComponentBatch).into()), self.centers .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.rotations .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/clear.rs b/crates/re_types/src/archetypes/clear.rs index deca34280f99..ebcd07c82a82 100644 --- a/crates/re_types/src/archetypes/clear.rs +++ b/crates/re_types/src/archetypes/clear.rs @@ -68,16 +68,16 @@ pub struct Clear { pub is_recursive: crate::components::ClearIsRecursive, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.ClearIsRecursive".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.ClearIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClearIsRecursive".into(), @@ -90,40 +90,40 @@ impl Clear { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`Clear`] [`crate::Archetype`] -pub type ClearIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Clear`] [`::re_types_core::Archetype`] +pub type ClearIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Clear { +impl ::re_types_core::Archetype for Clear { type Indicator = ClearIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Clear".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: ClearIndicator = ClearIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -132,9 +132,9 @@ impl crate::Archetype for Clear { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -142,27 +142,27 @@ impl crate::Archetype for Clear { let is_recursive = { let array = arrays_by_name .get("rerun.components.ClearIsRecursive") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Clear#is_recursive")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Clear#is_recursive")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Clear#is_recursive")? }; Ok(Self { is_recursive }) } } -impl crate::AsComponents for Clear { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Clear { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.is_recursive as &dyn crate::ComponentBatch).into()), + Some((&self.is_recursive as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/depth_image.rs b/crates/re_types/src/archetypes/depth_image.rs index f8a6cf705535..ef5893ed3208 100644 --- a/crates/re_types/src/archetypes/depth_image.rs +++ b/crates/re_types/src/archetypes/depth_image.rs @@ -77,13 +77,13 @@ pub struct DepthImage { pub draw_order: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorData".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.DepthImageIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.DepthMeter".into(), @@ -92,7 +92,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TensorData".into(), @@ -107,40 +107,40 @@ impl DepthImage { pub const NUM_COMPONENTS: usize = 5usize; } -/// Indicator component for the [`DepthImage`] [`crate::Archetype`] -pub type DepthImageIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`DepthImage`] [`::re_types_core::Archetype`] +pub type DepthImageIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for DepthImage { +impl ::re_types_core::Archetype for DepthImage { type Indicator = DepthImageIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.DepthImage".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: DepthImageIndicator = DepthImageIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -149,9 +149,9 @@ impl crate::Archetype for DepthImage { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -159,14 +159,14 @@ impl crate::Archetype for DepthImage { let data = { let array = arrays_by_name .get("rerun.components.TensorData") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DepthImage#data")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.DepthImage#data")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DepthImage#data")? }; let meter = if let Some(array) = arrays_by_name.get("rerun.components.DepthMeter") { @@ -176,7 +176,7 @@ impl crate::Archetype for DepthImage { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DepthImage#meter")? }) } else { @@ -189,7 +189,7 @@ impl crate::Archetype for DepthImage { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DepthImage#draw_order")? }) } else { @@ -203,19 +203,19 @@ impl crate::Archetype for DepthImage { } } -impl crate::AsComponents for DepthImage { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for DepthImage { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.data as &dyn crate::ComponentBatch).into()), + Some((&self.data as &dyn ::re_types_core::ComponentBatch).into()), self.meter .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/depth_image_ext.rs b/crates/re_types/src/archetypes/depth_image_ext.rs index f75f86423afa..50fbfc1f868e 100644 --- a/crates/re_types/src/archetypes/depth_image_ext.rs +++ b/crates/re_types/src/archetypes/depth_image_ext.rs @@ -38,7 +38,7 @@ impl DepthImage { } } -fn assign_if_none(name: &mut Option, new_name: &str) { +fn assign_if_none(name: &mut Option<::re_types_core::ArrowString>, new_name: &str) { if name.is_none() { *name = Some(new_name.into()); } diff --git a/crates/re_types/src/archetypes/disconnected_space.rs b/crates/re_types/src/archetypes/disconnected_space.rs index 90bde42a6da8..f3054a8f3e5c 100644 --- a/crates/re_types/src/archetypes/disconnected_space.rs +++ b/crates/re_types/src/archetypes/disconnected_space.rs @@ -66,16 +66,16 @@ pub struct DisconnectedSpace { pub disconnected_space: crate::components::DisconnectedSpace, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.DisconnectedSpace".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.DisconnectedSpaceIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.DisconnectedSpace".into(), @@ -88,40 +88,41 @@ impl DisconnectedSpace { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`DisconnectedSpace`] [`crate::Archetype`] -pub type DisconnectedSpaceIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`DisconnectedSpace`] [`::re_types_core::Archetype`] +pub type DisconnectedSpaceIndicator = + ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for DisconnectedSpace { +impl ::re_types_core::Archetype for DisconnectedSpace { type Indicator = DisconnectedSpaceIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.DisconnectedSpace".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: DisconnectedSpaceIndicator = DisconnectedSpaceIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -130,9 +131,9 @@ impl crate::Archetype for DisconnectedSpace { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -140,27 +141,27 @@ impl crate::Archetype for DisconnectedSpace { let disconnected_space = { let array = arrays_by_name .get("rerun.components.DisconnectedSpace") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DisconnectedSpace#disconnected_space")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.DisconnectedSpace#disconnected_space")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.DisconnectedSpace#disconnected_space")? }; Ok(Self { disconnected_space }) } } -impl crate::AsComponents for DisconnectedSpace { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for DisconnectedSpace { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.disconnected_space as &dyn crate::ComponentBatch).into()), + Some((&self.disconnected_space as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/image.rs b/crates/re_types/src/archetypes/image.rs index bdaeb5bbaf76..f2da36aab4a1 100644 --- a/crates/re_types/src/archetypes/image.rs +++ b/crates/re_types/src/archetypes/image.rs @@ -67,13 +67,13 @@ pub struct Image { pub draw_order: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorData".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.ImageIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.DrawOrder".into(), @@ -81,7 +81,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TensorData".into(), @@ -95,40 +95,40 @@ impl Image { pub const NUM_COMPONENTS: usize = 4usize; } -/// Indicator component for the [`Image`] [`crate::Archetype`] -pub type ImageIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Image`] [`::re_types_core::Archetype`] +pub type ImageIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Image { +impl ::re_types_core::Archetype for Image { type Indicator = ImageIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Image".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: ImageIndicator = ImageIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -137,9 +137,9 @@ impl crate::Archetype for Image { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -147,14 +147,14 @@ impl crate::Archetype for Image { let data = { let array = arrays_by_name .get("rerun.components.TensorData") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Image#data")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Image#data")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Image#data")? }; let draw_order = if let Some(array) = arrays_by_name.get("rerun.components.DrawOrder") { @@ -164,7 +164,7 @@ impl crate::Archetype for Image { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Image#draw_order")? }) } else { @@ -174,16 +174,16 @@ impl crate::Archetype for Image { } } -impl crate::AsComponents for Image { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Image { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.data as &dyn crate::ComponentBatch).into()), + Some((&self.data as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/image_ext.rs b/crates/re_types/src/archetypes/image_ext.rs index fe0fcd3e4d10..45f2bbd65ee2 100644 --- a/crates/re_types/src/archetypes/image_ext.rs +++ b/crates/re_types/src/archetypes/image_ext.rs @@ -45,7 +45,7 @@ impl Image { } } -fn assign_if_none(name: &mut Option, new_name: &str) { +fn assign_if_none(name: &mut Option<::re_types_core::ArrowString>, new_name: &str) { if name.is_none() { *name = Some(new_name.into()); } diff --git a/crates/re_types/src/archetypes/line_strips2d.rs b/crates/re_types/src/archetypes/line_strips2d.rs index c442c021c649..22627a4efb53 100644 --- a/crates/re_types/src/archetypes/line_strips2d.rs +++ b/crates/re_types/src/archetypes/line_strips2d.rs @@ -84,10 +84,10 @@ pub struct LineStrips2D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.LineStrip2D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Color".into(), @@ -96,7 +96,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -106,7 +106,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 8usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 8usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.LineStrip2D".into(), @@ -124,40 +124,40 @@ impl LineStrips2D { pub const NUM_COMPONENTS: usize = 8usize; } -/// Indicator component for the [`LineStrips2D`] [`crate::Archetype`] -pub type LineStrips2DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`LineStrips2D`] [`::re_types_core::Archetype`] +pub type LineStrips2DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for LineStrips2D { +impl ::re_types_core::Archetype for LineStrips2D { type Indicator = LineStrips2DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.LineStrips2D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: LineStrips2DIndicator = LineStrips2DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -166,9 +166,9 @@ impl crate::Archetype for LineStrips2D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -176,13 +176,13 @@ impl crate::Archetype for LineStrips2D { let strips = { let array = arrays_by_name .get("rerun.components.LineStrip2D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.LineStrips2D#strips")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#strips")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#strips")? }; let radii = if let Some(array) = arrays_by_name.get("rerun.components.Radius") { @@ -190,8 +190,8 @@ impl crate::Archetype for LineStrips2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#radii")? }) } else { @@ -202,8 +202,8 @@ impl crate::Archetype for LineStrips2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#colors")? }) } else { @@ -214,8 +214,8 @@ impl crate::Archetype for LineStrips2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#labels")? }) } else { @@ -228,7 +228,7 @@ impl crate::Archetype for LineStrips2D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.LineStrips2D#draw_order")? }) } else { @@ -239,8 +239,8 @@ impl crate::Archetype for LineStrips2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#class_ids")? }) } else { @@ -252,8 +252,8 @@ impl crate::Archetype for LineStrips2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips2D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips2D#instance_keys")? }) } else { @@ -271,31 +271,31 @@ impl crate::Archetype for LineStrips2D { } } -impl crate::AsComponents for LineStrips2D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for LineStrips2D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.strips as &dyn crate::ComponentBatch).into()), + Some((&self.strips as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/line_strips3d.rs b/crates/re_types/src/archetypes/line_strips3d.rs index 070ef4d1fb2f..5b8dace59ba5 100644 --- a/crates/re_types/src/archetypes/line_strips3d.rs +++ b/crates/re_types/src/archetypes/line_strips3d.rs @@ -81,10 +81,10 @@ pub struct LineStrips3D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.LineStrip3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Color".into(), @@ -93,7 +93,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -102,7 +102,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 7usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 7usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.LineStrip3D".into(), @@ -119,40 +119,40 @@ impl LineStrips3D { pub const NUM_COMPONENTS: usize = 7usize; } -/// Indicator component for the [`LineStrips3D`] [`crate::Archetype`] -pub type LineStrips3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`LineStrips3D`] [`::re_types_core::Archetype`] +pub type LineStrips3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for LineStrips3D { +impl ::re_types_core::Archetype for LineStrips3D { type Indicator = LineStrips3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.LineStrips3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: LineStrips3DIndicator = LineStrips3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -161,9 +161,9 @@ impl crate::Archetype for LineStrips3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -171,13 +171,13 @@ impl crate::Archetype for LineStrips3D { let strips = { let array = arrays_by_name .get("rerun.components.LineStrip3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.LineStrips3D#strips")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#strips")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#strips")? }; let radii = if let Some(array) = arrays_by_name.get("rerun.components.Radius") { @@ -185,8 +185,8 @@ impl crate::Archetype for LineStrips3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#radii")? }) } else { @@ -197,8 +197,8 @@ impl crate::Archetype for LineStrips3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#colors")? }) } else { @@ -209,8 +209,8 @@ impl crate::Archetype for LineStrips3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#labels")? }) } else { @@ -221,8 +221,8 @@ impl crate::Archetype for LineStrips3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#class_ids")? }) } else { @@ -234,8 +234,8 @@ impl crate::Archetype for LineStrips3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.LineStrips3D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.LineStrips3D#instance_keys")? }) } else { @@ -252,28 +252,28 @@ impl crate::Archetype for LineStrips3D { } } -impl crate::AsComponents for LineStrips3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for LineStrips3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.strips as &dyn crate::ComponentBatch).into()), + Some((&self.strips as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/mesh3d.rs b/crates/re_types/src/archetypes/mesh3d.rs index 99a464646b7d..25520d7eb754 100644 --- a/crates/re_types/src/archetypes/mesh3d.rs +++ b/crates/re_types/src/archetypes/mesh3d.rs @@ -80,10 +80,10 @@ pub struct Mesh3D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Position3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Mesh3DIndicator".into(), @@ -92,7 +92,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -102,7 +102,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 8usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 8usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Position3D".into(), @@ -120,40 +120,40 @@ impl Mesh3D { pub const NUM_COMPONENTS: usize = 8usize; } -/// Indicator component for the [`Mesh3D`] [`crate::Archetype`] -pub type Mesh3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Mesh3D`] [`::re_types_core::Archetype`] +pub type Mesh3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Mesh3D { +impl ::re_types_core::Archetype for Mesh3D { type Indicator = Mesh3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Mesh3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Mesh3DIndicator = Mesh3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -162,9 +162,9 @@ impl crate::Archetype for Mesh3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -172,13 +172,13 @@ impl crate::Archetype for Mesh3D { let vertex_positions = { let array = arrays_by_name .get("rerun.components.Position3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Mesh3D#vertex_positions")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Mesh3D#vertex_positions")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Mesh3D#vertex_positions")? }; let mesh_properties = @@ -189,7 +189,7 @@ impl crate::Archetype for Mesh3D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Mesh3D#mesh_properties")? }) } else { @@ -200,8 +200,8 @@ impl crate::Archetype for Mesh3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Mesh3D#vertex_normals")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Mesh3D#vertex_normals")? }) } else { @@ -212,8 +212,8 @@ impl crate::Archetype for Mesh3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Mesh3D#vertex_colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Mesh3D#vertex_colors")? }) } else { @@ -226,7 +226,7 @@ impl crate::Archetype for Mesh3D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Mesh3D#mesh_material")? }) } else { @@ -237,8 +237,8 @@ impl crate::Archetype for Mesh3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Mesh3D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Mesh3D#class_ids")? }) } else { @@ -250,8 +250,8 @@ impl crate::Archetype for Mesh3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Mesh3D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Mesh3D#instance_keys")? }) } else { @@ -269,31 +269,31 @@ impl crate::Archetype for Mesh3D { } } -impl crate::AsComponents for Mesh3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Mesh3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.vertex_positions as &dyn crate::ComponentBatch).into()), + Some((&self.vertex_positions as &dyn ::re_types_core::ComponentBatch).into()), self.mesh_properties .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.vertex_normals .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.vertex_colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.mesh_material .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/pinhole.rs b/crates/re_types/src/archetypes/pinhole.rs index 921409776db4..ad5df17857aa 100644 --- a/crates/re_types/src/archetypes/pinhole.rs +++ b/crates/re_types/src/archetypes/pinhole.rs @@ -94,10 +94,10 @@ pub struct Pinhole { pub camera_xyz: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.PinholeProjection".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.PinholeIndicator".into(), @@ -105,7 +105,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.InstanceKey".into(), @@ -113,7 +113,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.PinholeProjection".into(), @@ -128,40 +128,40 @@ impl Pinhole { pub const NUM_COMPONENTS: usize = 5usize; } -/// Indicator component for the [`Pinhole`] [`crate::Archetype`] -pub type PinholeIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Pinhole`] [`::re_types_core::Archetype`] +pub type PinholeIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Pinhole { +impl ::re_types_core::Archetype for Pinhole { type Indicator = PinholeIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Pinhole".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: PinholeIndicator = PinholeIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -170,9 +170,9 @@ impl crate::Archetype for Pinhole { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -180,14 +180,14 @@ impl crate::Archetype for Pinhole { let image_from_camera = { let array = arrays_by_name .get("rerun.components.PinholeProjection") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Pinhole#image_from_camera")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Pinhole#image_from_camera")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Pinhole#image_from_camera")? }; let resolution = if let Some(array) = arrays_by_name.get("rerun.components.Resolution") { @@ -197,7 +197,7 @@ impl crate::Archetype for Pinhole { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Pinhole#resolution")? }) } else { @@ -211,7 +211,7 @@ impl crate::Archetype for Pinhole { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Pinhole#camera_xyz")? }) } else { @@ -225,19 +225,19 @@ impl crate::Archetype for Pinhole { } } -impl crate::AsComponents for Pinhole { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Pinhole { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.image_from_camera as &dyn crate::ComponentBatch).into()), + Some((&self.image_from_camera as &dyn ::re_types_core::ComponentBatch).into()), self.resolution .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.camera_xyz .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/points2d.rs b/crates/re_types/src/archetypes/points2d.rs index 79a3660421f5..f69f316422aa 100644 --- a/crates/re_types/src/archetypes/points2d.rs +++ b/crates/re_types/src/archetypes/points2d.rs @@ -91,10 +91,10 @@ pub struct Points2D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Position2D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Color".into(), @@ -103,7 +103,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 5usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -114,7 +114,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 5usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 9usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 9usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Position2D".into(), @@ -133,40 +133,40 @@ impl Points2D { pub const NUM_COMPONENTS: usize = 9usize; } -/// Indicator component for the [`Points2D`] [`crate::Archetype`] -pub type Points2DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Points2D`] [`::re_types_core::Archetype`] +pub type Points2DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Points2D { +impl ::re_types_core::Archetype for Points2D { type Indicator = Points2DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Points2D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Points2DIndicator = Points2DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -175,9 +175,9 @@ impl crate::Archetype for Points2D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -185,13 +185,13 @@ impl crate::Archetype for Points2D { let positions = { let array = arrays_by_name .get("rerun.components.Position2D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Points2D#positions")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#positions")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#positions")? }; let radii = if let Some(array) = arrays_by_name.get("rerun.components.Radius") { @@ -199,8 +199,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#radii")? }) } else { @@ -211,8 +211,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#colors")? }) } else { @@ -223,8 +223,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#labels")? }) } else { @@ -237,7 +237,7 @@ impl crate::Archetype for Points2D { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Points2D#draw_order")? }) } else { @@ -248,8 +248,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#class_ids")? }) } else { @@ -260,8 +260,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#keypoint_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#keypoint_ids")? }) } else { @@ -273,8 +273,8 @@ impl crate::Archetype for Points2D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points2D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points2D#instance_keys")? }) } else { @@ -293,34 +293,34 @@ impl crate::Archetype for Points2D { } } -impl crate::AsComponents for Points2D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Points2D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.positions as &dyn crate::ComponentBatch).into()), + Some((&self.positions as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.keypoint_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/points3d.rs b/crates/re_types/src/archetypes/points3d.rs index 0cbcfab9adfc..d1e2bc1b0dec 100644 --- a/crates/re_types/src/archetypes/points3d.rs +++ b/crates/re_types/src/archetypes/points3d.rs @@ -86,10 +86,10 @@ pub struct Points3D { pub instance_keys: Option>, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Position3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Color".into(), @@ -98,7 +98,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ClassId".into(), @@ -108,7 +108,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 8usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 8usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Position3D".into(), @@ -126,40 +126,40 @@ impl Points3D { pub const NUM_COMPONENTS: usize = 8usize; } -/// Indicator component for the [`Points3D`] [`crate::Archetype`] -pub type Points3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Points3D`] [`::re_types_core::Archetype`] +pub type Points3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Points3D { +impl ::re_types_core::Archetype for Points3D { type Indicator = Points3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Points3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Points3DIndicator = Points3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -168,9 +168,9 @@ impl crate::Archetype for Points3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -178,13 +178,13 @@ impl crate::Archetype for Points3D { let positions = { let array = arrays_by_name .get("rerun.components.Position3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Points3D#positions")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#positions")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#positions")? }; let radii = if let Some(array) = arrays_by_name.get("rerun.components.Radius") { @@ -192,8 +192,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#radii")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#radii")? }) } else { @@ -204,8 +204,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#colors")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#colors")? }) } else { @@ -216,8 +216,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#labels")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#labels")? }) } else { @@ -228,8 +228,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#class_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#class_ids")? }) } else { @@ -240,8 +240,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#keypoint_ids")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#keypoint_ids")? }) } else { @@ -253,8 +253,8 @@ impl crate::Archetype for Points3D { ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Points3D#instance_keys")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .collect::>>() + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.archetypes.Points3D#instance_keys")? }) } else { @@ -272,31 +272,31 @@ impl crate::Archetype for Points3D { } } -impl crate::AsComponents for Points3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Points3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.positions as &dyn crate::ComponentBatch).into()), + Some((&self.positions as &dyn ::re_types_core::ComponentBatch).into()), self.radii .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.colors .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.labels .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.class_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.keypoint_ids .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), self.instance_keys .as_ref() - .map(|comp_batch| (comp_batch as &dyn crate::ComponentBatch).into()), + .map(|comp_batch| (comp_batch as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/segmentation_image.rs b/crates/re_types/src/archetypes/segmentation_image.rs index fa48de27fb4b..63a5c9b49d1f 100644 --- a/crates/re_types/src/archetypes/segmentation_image.rs +++ b/crates/re_types/src/archetypes/segmentation_image.rs @@ -76,13 +76,13 @@ pub struct SegmentationImage { pub draw_order: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorData".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.SegmentationImageIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.DrawOrder".into(), @@ -90,7 +90,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TensorData".into(), @@ -104,40 +104,41 @@ impl SegmentationImage { pub const NUM_COMPONENTS: usize = 4usize; } -/// Indicator component for the [`SegmentationImage`] [`crate::Archetype`] -pub type SegmentationImageIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`SegmentationImage`] [`::re_types_core::Archetype`] +pub type SegmentationImageIndicator = + ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for SegmentationImage { +impl ::re_types_core::Archetype for SegmentationImage { type Indicator = SegmentationImageIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.SegmentationImage".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: SegmentationImageIndicator = SegmentationImageIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -146,9 +147,9 @@ impl crate::Archetype for SegmentationImage { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -156,14 +157,14 @@ impl crate::Archetype for SegmentationImage { let data = { let array = arrays_by_name .get("rerun.components.TensorData") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.SegmentationImage#data")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.SegmentationImage#data")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.SegmentationImage#data")? }; let draw_order = if let Some(array) = arrays_by_name.get("rerun.components.DrawOrder") { @@ -173,7 +174,7 @@ impl crate::Archetype for SegmentationImage { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.SegmentationImage#draw_order")? }) } else { @@ -183,16 +184,16 @@ impl crate::Archetype for SegmentationImage { } } -impl crate::AsComponents for SegmentationImage { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for SegmentationImage { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.data as &dyn crate::ComponentBatch).into()), + Some((&self.data as &dyn ::re_types_core::ComponentBatch).into()), self.draw_order .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/segmentation_image_ext.rs b/crates/re_types/src/archetypes/segmentation_image_ext.rs index 5daeb64f512d..81108e6bf683 100644 --- a/crates/re_types/src/archetypes/segmentation_image_ext.rs +++ b/crates/re_types/src/archetypes/segmentation_image_ext.rs @@ -37,7 +37,7 @@ impl SegmentationImage { } } -fn assign_if_none(name: &mut Option, new_name: &str) { +fn assign_if_none(name: &mut Option<::re_types_core::ArrowString>, new_name: &str) { if name.is_none() { *name = Some(new_name.into()); } diff --git a/crates/re_types/src/archetypes/tensor.rs b/crates/re_types/src/archetypes/tensor.rs index f82302c859ae..888ed8c77a29 100644 --- a/crates/re_types/src/archetypes/tensor.rs +++ b/crates/re_types/src/archetypes/tensor.rs @@ -53,16 +53,16 @@ pub struct Tensor { pub data: crate::components::TensorData, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorData".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TensorIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TensorData".into(), @@ -75,40 +75,40 @@ impl Tensor { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`Tensor`] [`crate::Archetype`] -pub type TensorIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Tensor`] [`::re_types_core::Archetype`] +pub type TensorIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Tensor { +impl ::re_types_core::Archetype for Tensor { type Indicator = TensorIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Tensor".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: TensorIndicator = TensorIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -117,9 +117,9 @@ impl crate::Archetype for Tensor { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -127,27 +127,27 @@ impl crate::Archetype for Tensor { let data = { let array = arrays_by_name .get("rerun.components.TensorData") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Tensor#data")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Tensor#data")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Tensor#data")? }; Ok(Self { data }) } } -impl crate::AsComponents for Tensor { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Tensor { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.data as &dyn crate::ComponentBatch).into()), + Some((&self.data as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/tensor_ext.rs b/crates/re_types/src/archetypes/tensor_ext.rs index 1f59688d1ae2..885182ae278b 100644 --- a/crates/re_types/src/archetypes/tensor_ext.rs +++ b/crates/re_types/src/archetypes/tensor_ext.rs @@ -1,7 +1,6 @@ -use crate::{ - datatypes::{TensorData, TensorDimension}, - ArrowString, -}; +use crate::datatypes::{TensorData, TensorDimension}; + +use re_types_core::ArrowString; use super::Tensor; diff --git a/crates/re_types/src/archetypes/text_document.rs b/crates/re_types/src/archetypes/text_document.rs index 16b076b7916a..10986f31d820 100644 --- a/crates/re_types/src/archetypes/text_document.rs +++ b/crates/re_types/src/archetypes/text_document.rs @@ -32,13 +32,13 @@ pub struct TextDocument { pub media_type: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Text".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.TextDocumentIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.InstanceKey".into(), @@ -46,7 +46,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Text".into(), @@ -60,40 +60,40 @@ impl TextDocument { pub const NUM_COMPONENTS: usize = 4usize; } -/// Indicator component for the [`TextDocument`] [`crate::Archetype`] -pub type TextDocumentIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`TextDocument`] [`::re_types_core::Archetype`] +pub type TextDocumentIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for TextDocument { +impl ::re_types_core::Archetype for TextDocument { type Indicator = TextDocumentIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.TextDocument".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: TextDocumentIndicator = TextDocumentIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -102,9 +102,9 @@ impl crate::Archetype for TextDocument { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -112,14 +112,14 @@ impl crate::Archetype for TextDocument { let text = { let array = arrays_by_name .get("rerun.components.Text") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextDocument#text")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.TextDocument#text")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextDocument#text")? }; let media_type = if let Some(array) = arrays_by_name.get("rerun.components.MediaType") { @@ -129,7 +129,7 @@ impl crate::Archetype for TextDocument { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextDocument#media_type")? }) } else { @@ -139,16 +139,16 @@ impl crate::Archetype for TextDocument { } } -impl crate::AsComponents for TextDocument { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for TextDocument { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.text as &dyn crate::ComponentBatch).into()), + Some((&self.text as &dyn ::re_types_core::ComponentBatch).into()), self.media_type .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/text_log.rs b/crates/re_types/src/archetypes/text_log.rs index bd822228b8b1..49ea85001822 100644 --- a/crates/re_types/src/archetypes/text_log.rs +++ b/crates/re_types/src/archetypes/text_log.rs @@ -70,10 +70,10 @@ pub struct TextLog { pub color: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Text".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 2usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.TextLogIndicator".into(), @@ -81,10 +81,10 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 2usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 4usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 4usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Text".into(), @@ -98,40 +98,40 @@ impl TextLog { pub const NUM_COMPONENTS: usize = 4usize; } -/// Indicator component for the [`TextLog`] [`crate::Archetype`] -pub type TextLogIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`TextLog`] [`::re_types_core::Archetype`] +pub type TextLogIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for TextLog { +impl ::re_types_core::Archetype for TextLog { type Indicator = TextLogIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.TextLog".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: TextLogIndicator = TextLogIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -140,9 +140,9 @@ impl crate::Archetype for TextLog { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -150,14 +150,14 @@ impl crate::Archetype for TextLog { let text = { let array = arrays_by_name .get("rerun.components.Text") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextLog#text")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.TextLog#text")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextLog#text")? }; let level = if let Some(array) = arrays_by_name.get("rerun.components.TextLogLevel") { @@ -167,7 +167,7 @@ impl crate::Archetype for TextLog { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextLog#level")? }) } else { @@ -180,7 +180,7 @@ impl crate::Archetype for TextLog { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TextLog#color")? }) } else { @@ -190,19 +190,19 @@ impl crate::Archetype for TextLog { } } -impl crate::AsComponents for TextLog { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for TextLog { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.text as &dyn crate::ComponentBatch).into()), + Some((&self.text as &dyn ::re_types_core::ComponentBatch).into()), self.level .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.color .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/time_series_scalar.rs b/crates/re_types/src/archetypes/time_series_scalar.rs index e7b388c2fc63..5a273dee8397 100644 --- a/crates/re_types/src/archetypes/time_series_scalar.rs +++ b/crates/re_types/src/archetypes/time_series_scalar.rs @@ -97,10 +97,10 @@ pub struct TimeSeriesScalar { pub scattered: Option, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Scalar".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Color".into(), @@ -109,7 +109,7 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usi ] }); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.InstanceKey".into(), @@ -118,7 +118,7 @@ static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize] ] }); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 7usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 7usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Scalar".into(), @@ -135,40 +135,40 @@ impl TimeSeriesScalar { pub const NUM_COMPONENTS: usize = 7usize; } -/// Indicator component for the [`TimeSeriesScalar`] [`crate::Archetype`] -pub type TimeSeriesScalarIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`TimeSeriesScalar`] [`::re_types_core::Archetype`] +pub type TimeSeriesScalarIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for TimeSeriesScalar { +impl ::re_types_core::Archetype for TimeSeriesScalar { type Indicator = TimeSeriesScalarIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.TimeSeriesScalar".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: TimeSeriesScalarIndicator = TimeSeriesScalarIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -177,9 +177,9 @@ impl crate::Archetype for TimeSeriesScalar { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -187,14 +187,14 @@ impl crate::Archetype for TimeSeriesScalar { let scalar = { let array = arrays_by_name .get("rerun.components.Scalar") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#scalar")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.TimeSeriesScalar#scalar")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#scalar")? }; let radius = if let Some(array) = arrays_by_name.get("rerun.components.Radius") { @@ -204,7 +204,7 @@ impl crate::Archetype for TimeSeriesScalar { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#radius")? }) } else { @@ -217,7 +217,7 @@ impl crate::Archetype for TimeSeriesScalar { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#color")? }) } else { @@ -230,7 +230,7 @@ impl crate::Archetype for TimeSeriesScalar { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#label")? }) } else { @@ -244,7 +244,7 @@ impl crate::Archetype for TimeSeriesScalar { .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.TimeSeriesScalar#scattered")? }) } else { @@ -260,25 +260,25 @@ impl crate::Archetype for TimeSeriesScalar { } } -impl crate::AsComponents for TimeSeriesScalar { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for TimeSeriesScalar { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.scalar as &dyn crate::ComponentBatch).into()), + Some((&self.scalar as &dyn ::re_types_core::ComponentBatch).into()), self.radius .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.color .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.label .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), self.scattered .as_ref() - .map(|comp| (comp as &dyn crate::ComponentBatch).into()), + .map(|comp| (comp as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/transform3d.rs b/crates/re_types/src/archetypes/transform3d.rs index b806b36ee607..89bd517b5da8 100644 --- a/crates/re_types/src/archetypes/transform3d.rs +++ b/crates/re_types/src/archetypes/transform3d.rs @@ -68,16 +68,16 @@ pub struct Transform3D { pub transform: crate::components::Transform3D, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Transform3D".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.Transform3DIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.Transform3D".into(), @@ -90,40 +90,40 @@ impl Transform3D { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`Transform3D`] [`crate::Archetype`] -pub type Transform3DIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`Transform3D`] [`::re_types_core::Archetype`] +pub type Transform3DIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for Transform3D { +impl ::re_types_core::Archetype for Transform3D { type Indicator = Transform3DIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.Transform3D".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: Transform3DIndicator = Transform3DIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -132,9 +132,9 @@ impl crate::Archetype for Transform3D { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -142,27 +142,27 @@ impl crate::Archetype for Transform3D { let transform = { let array = arrays_by_name .get("rerun.components.Transform3D") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Transform3D#transform")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.Transform3D#transform")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.Transform3D#transform")? }; Ok(Self { transform }) } } -impl crate::AsComponents for Transform3D { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for Transform3D { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.transform as &dyn crate::ComponentBatch).into()), + Some((&self.transform as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/archetypes/view_coordinates.rs b/crates/re_types/src/archetypes/view_coordinates.rs index 861ddb32848a..c707ae75db8f 100644 --- a/crates/re_types/src/archetypes/view_coordinates.rs +++ b/crates/re_types/src/archetypes/view_coordinates.rs @@ -61,16 +61,16 @@ pub struct ViewCoordinates { pub xyz: crate::components::ViewCoordinates, } -static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.ViewCoordinates".into()]); -static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.ViewCoordinatesIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 1usize]> = +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.components.InstanceKey".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[crate::ComponentName; 3usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[::re_types_core::ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.components.ViewCoordinates".into(), @@ -83,40 +83,40 @@ impl ViewCoordinates { pub const NUM_COMPONENTS: usize = 3usize; } -/// Indicator component for the [`ViewCoordinates`] [`crate::Archetype`] -pub type ViewCoordinatesIndicator = crate::GenericIndicatorComponent; +/// Indicator component for the [`ViewCoordinates`] [`::re_types_core::Archetype`] +pub type ViewCoordinatesIndicator = ::re_types_core::GenericIndicatorComponent; -impl crate::Archetype for ViewCoordinates { +impl ::re_types_core::Archetype for ViewCoordinates { type Indicator = ViewCoordinatesIndicator; #[inline] - fn name() -> crate::ArchetypeName { + fn name() -> ::re_types_core::ArchetypeName { "rerun.archetypes.ViewCoordinates".into() } #[inline] - fn indicator() -> crate::MaybeOwnedComponentBatch<'static> { + fn indicator() -> ::re_types_core::MaybeOwnedComponentBatch<'static> { static INDICATOR: ViewCoordinatesIndicator = ViewCoordinatesIndicator::DEFAULT; - crate::MaybeOwnedComponentBatch::Ref(&INDICATOR) + ::re_types_core::MaybeOwnedComponentBatch::Ref(&INDICATOR) } #[inline] - fn required_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn required_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { REQUIRED_COMPONENTS.as_slice().into() } #[inline] - fn recommended_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn recommended_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { RECOMMENDED_COMPONENTS.as_slice().into() } #[inline] - fn optional_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn optional_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { OPTIONAL_COMPONENTS.as_slice().into() } #[inline] - fn all_components() -> ::std::borrow::Cow<'static, [crate::ComponentName]> { + fn all_components() -> ::std::borrow::Cow<'static, [::re_types_core::ComponentName]> { ALL_COMPONENTS.as_slice().into() } @@ -125,9 +125,9 @@ impl crate::Archetype for ViewCoordinates { arrow_data: impl IntoIterator< Item = (::arrow2::datatypes::Field, Box), >, - ) -> crate::DeserializationResult { + ) -> ::re_types_core::DeserializationResult { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; + use ::re_types_core::{Loggable as _, ResultExt as _}; let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data .into_iter() .map(|(field, array)| (field.name, array)) @@ -135,27 +135,27 @@ impl crate::Archetype for ViewCoordinates { let xyz = { let array = arrays_by_name .get("rerun.components.ViewCoordinates") - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.ViewCoordinates#xyz")?; ::from_arrow_opt(&**array) .with_context("rerun.archetypes.ViewCoordinates#xyz")? .into_iter() .next() .flatten() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.archetypes.ViewCoordinates#xyz")? }; Ok(Self { xyz }) } } -impl crate::AsComponents for ViewCoordinates { - fn as_component_batches(&self) -> Vec> { +impl ::re_types_core::AsComponents for ViewCoordinates { + fn as_component_batches(&self) -> Vec<::re_types_core::MaybeOwnedComponentBatch<'_>> { re_tracing::profile_function!(); - use crate::Archetype as _; + use ::re_types_core::Archetype as _; [ Some(Self::indicator()), - Some((&self.xyz as &dyn crate::ComponentBatch).into()), + Some((&self.xyz as &dyn ::re_types_core::ComponentBatch).into()), ] .into_iter() .flatten() diff --git a/crates/re_types/src/arrow_buffer.rs b/crates/re_types/src/arrow_buffer.rs deleted file mode 100644 index 1dc09bb43a0c..000000000000 --- a/crates/re_types/src/arrow_buffer.rs +++ /dev/null @@ -1,89 +0,0 @@ -use arrow2::buffer::Buffer; - -/// Convenience-wrapper around an arrow [`Buffer`] that is known to contain a -/// a primitive type. -/// -/// The arrow2 [`Buffer`] object is internally reference-counted and can be -/// easily converted back to a `&[T]` referencing the underlying storage. -/// This avoids some of the lifetime complexities that would otherwise -/// arise from returning a `&[T]` directly, but is significantly more -/// performant than doing the full allocation necessary to return a `Vec`. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct ArrowBuffer(Buffer); - -impl ArrowBuffer { - /// The number of instances of T stored in this buffer. - #[inline] - pub fn num_instances(&self) -> usize { - // WARNING: If you are touching this code, make sure you know what len() actually does. - // - // There is ambiguity in how arrow2 and arrow-rs talk about buffer lengths, including - // some incorrect documentation: https://github.com/jorgecarleitao/arrow2/issues/1430 - // - // Arrow2 `Buffer` is typed and `len()` is the number of units of `T`, but the documentation - // is currently incorrect. - // Arrow-rs `Buffer` is untyped and len() is in bytes, but `ScalarBuffer`s are in units of T. - self.0.len() - } - - /// The number of bytes stored in this buffer - #[inline] - pub fn size_in_bytes(&self) -> usize { - self.0.len() * std::mem::size_of::() - } - - #[inline] - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - - #[inline] - pub fn as_slice(&self) -> &[T] { - self.0.as_slice() - } -} - -impl Eq for ArrowBuffer {} - -impl ArrowBuffer { - #[inline] - pub fn to_vec(&self) -> Vec { - self.0.as_slice().to_vec() - } -} - -impl From> for ArrowBuffer { - #[inline] - fn from(value: Buffer) -> Self { - Self(value) - } -} - -impl From> for ArrowBuffer { - #[inline] - fn from(value: Vec) -> Self { - Self(value.into()) - } -} - -impl From<&[T]> for ArrowBuffer { - #[inline] - fn from(value: &[T]) -> Self { - Self(value.iter().cloned().collect()) // TODO(emilk): avoid extra clones - } -} - -impl FromIterator for ArrowBuffer { - fn from_iter>(iter: I) -> Self { - Self(Buffer::from_iter(iter)) - } -} - -impl std::ops::Deref for ArrowBuffer { - type Target = [T]; - - #[inline] - fn deref(&self) -> &[T] { - self.0.as_slice() - } -} diff --git a/crates/re_types/src/arrow_string.rs b/crates/re_types/src/arrow_string.rs deleted file mode 100644 index abb22fe2c883..000000000000 --- a/crates/re_types/src/arrow_string.rs +++ /dev/null @@ -1,91 +0,0 @@ -use arrow2::buffer::Buffer; - -/// Convenience-wrapper around an arrow [`Buffer`] that is known to contain a -/// UTF-8 encoded string. -/// -/// The arrow2 [`Buffer`] object is internally reference-counted and can be -/// easily converted back to a `&str` referencing the underlying storage. -/// This avoids some of the lifetime complexities that would otherwise -/// arise from returning a `&str` directly, but is significantly more -/// performant than doing the full allocation necessary to return a `String`. -#[derive(Clone, Debug, Default)] -pub struct ArrowString(pub Buffer); - -impl PartialEq for ArrowString { - #[inline] - fn eq(&self, other: &Self) -> bool { - self.as_str() == other.as_str() - } -} - -impl Eq for ArrowString {} - -impl PartialOrd for ArrowString { - #[inline] - fn partial_cmp(&self, other: &Self) -> Option { - self.as_str().partial_cmp(other.as_str()) - } -} - -impl Ord for ArrowString { - #[inline] - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.as_str().cmp(other.as_str()) - } -} - -impl std::hash::Hash for ArrowString { - #[inline] - fn hash(&self, state: &mut H) { - self.as_str().hash(state); - } -} - -impl ArrowString { - #[inline] - pub fn as_str(&self) -> &str { - std::str::from_utf8(self.0.as_ref()).unwrap_or("INVALID UTF-8") - } -} - -impl From for ArrowString { - #[inline] - fn from(value: String) -> Self { - Self(value.as_bytes().to_vec().into()) - } -} - -impl From<&str> for ArrowString { - #[inline] - fn from(value: &str) -> Self { - Self(value.as_bytes().to_vec().into()) - } -} - -impl std::fmt::Display for ArrowString { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.as_str().fmt(f) - } -} - -impl AsRef for ArrowString { - #[inline] - fn as_ref(&self) -> &str { - self.as_str() - } -} - -impl std::borrow::Borrow for ArrowString { - #[inline] - fn borrow(&self) -> &str { - self.as_str() - } -} - -impl std::ops::Deref for ArrowString { - type Target = str; - #[inline] - fn deref(&self) -> &str { - self.as_str() - } -} diff --git a/crates/re_types/src/blueprint/auto_space_views.rs b/crates/re_types/src/blueprint/auto_space_views.rs index 58d70dde0d81..d8827ef7461e 100644 --- a/crates/re_types/src/blueprint/auto_space_views.rs +++ b/crates/re_types/src/blueprint/auto_space_views.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a AutoSpaceViews> for ::std::borrow::Cow<'a, AutoSpaceViews> { } } -impl crate::Loggable for AutoSpaceViews { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for AutoSpaceViews { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -67,13 +67,13 @@ impl crate::Loggable for AutoSpaceViews { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -102,27 +102,27 @@ impl crate::Loggable for AutoSpaceViews { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) }) .with_context("rerun.blueprint.AutoSpaceViews#enabled")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.blueprint.AutoSpaceViews#enabled") .with_context("rerun.blueprint.AutoSpaceViews")?) } diff --git a/crates/re_types/src/blueprint/panel_view.rs b/crates/re_types/src/blueprint/panel_view.rs index 97394f78e0b6..925c2d935e9c 100644 --- a/crates/re_types/src/blueprint/panel_view.rs +++ b/crates/re_types/src/blueprint/panel_view.rs @@ -50,8 +50,8 @@ impl<'a> From<&'a PanelView> for ::std::borrow::Cow<'a, PanelView> { } } -impl crate::Loggable for PanelView { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for PanelView { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for PanelView { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -128,19 +128,19 @@ impl crate::Loggable for PanelView { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![Field { name: "is_expanded".to_owned(), data_type: DataType::Boolean, @@ -163,10 +163,12 @@ impl crate::Loggable for PanelView { .collect(); let is_expanded = { if !arrays_by_name.contains_key("is_expanded") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "is_expanded", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "is_expanded", + ), + ) .with_context("rerun.blueprint.PanelView"); } let arrow_data = &**arrays_by_name["is_expanded"]; @@ -174,7 +176,7 @@ impl crate::Loggable for PanelView { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) @@ -190,13 +192,13 @@ impl crate::Loggable for PanelView { opt.map(|(is_expanded)| { Ok(Self { is_expanded: is_expanded - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.blueprint.PanelView#is_expanded")?, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.blueprint.PanelView")? } }) diff --git a/crates/re_types/src/components/annotation_context.rs b/crates/re_types/src/components/annotation_context.rs index 04fc286bf7bf..d534e21a5869 100644 --- a/crates/re_types/src/components/annotation_context.rs +++ b/crates/re_types/src/components/annotation_context.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a AnnotationContext> for ::std::borrow::Cow<'a, AnnotationContex } } -impl crate::Loggable for AnnotationContext { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for AnnotationContext { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -72,13 +72,13 @@ impl crate::Loggable for AnnotationContext { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -129,19 +129,19 @@ impl crate::Loggable for AnnotationContext { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: ::arrow_datatype( @@ -173,7 +173,7 @@ impl crate::Loggable for AnnotationContext { let start = *start as usize; let end = start + len; if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -191,13 +191,13 @@ impl crate::Loggable for AnnotationContext { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.AnnotationContext#class_map") .with_context("rerun.components.AnnotationContext")?) } diff --git a/crates/re_types/src/components/blob.rs b/crates/re_types/src/components/blob.rs index 79aed4354d84..af0cae7b8943 100644 --- a/crates/re_types/src/components/blob.rs +++ b/crates/re_types/src/components/blob.rs @@ -17,16 +17,16 @@ /// **Component**: A binary blob of data. #[derive(Clone, Debug, PartialEq, Eq)] #[repr(transparent)] -pub struct Blob(pub crate::ArrowBuffer); +pub struct Blob(pub ::re_types_core::ArrowBuffer); -impl From> for Blob { +impl From<::re_types_core::ArrowBuffer> for Blob { #[inline] - fn from(data: crate::ArrowBuffer) -> Self { + fn from(data: ::re_types_core::ArrowBuffer) -> Self { Self(data) } } -impl From for crate::ArrowBuffer { +impl From for ::re_types_core::ArrowBuffer { #[inline] fn from(value: Blob) -> Self { value.0 @@ -47,8 +47,8 @@ impl<'a> From<&'a Blob> for ::std::borrow::Cow<'a, Blob> { } } -impl crate::Loggable for Blob { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Blob { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -70,13 +70,13 @@ impl crate::Loggable for Blob { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -126,19 +126,19 @@ impl crate::Loggable for Blob { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt8, @@ -158,7 +158,7 @@ impl crate::Loggable for Blob { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt8, arrow_data_inner.data_type().clone(), ) @@ -176,7 +176,7 @@ impl crate::Loggable for Blob { let start = *start as usize; let end = start + len; if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -188,18 +188,18 @@ impl crate::Loggable for Blob { .clone() .sliced_unchecked(start as usize, end - start as usize) }; - let data = crate::ArrowBuffer::from(data); + let data = ::re_types_core::ArrowBuffer::from(data); Ok(data) }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Blob#data") .with_context("rerun.components.Blob")?) } diff --git a/crates/re_types/src/components/class_id.rs b/crates/re_types/src/components/class_id.rs index 469eedff3bc2..4389fd93048e 100644 --- a/crates/re_types/src/components/class_id.rs +++ b/crates/re_types/src/components/class_id.rs @@ -60,8 +60,8 @@ impl<'a> From<&'a ClassId> for ::std::borrow::Cow<'a, ClassId> { } } -impl crate::Loggable for ClassId { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for ClassId { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -78,13 +78,13 @@ impl crate::Loggable for ClassId { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -123,18 +123,18 @@ impl crate::Loggable for ClassId { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -143,9 +143,9 @@ impl crate::Loggable for ClassId { .into_iter() .map(|opt| opt.copied()) .map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::ClassId(v))) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.ClassId#id") .with_context("rerun.components.ClassId")?) } @@ -154,16 +154,16 @@ impl crate::Loggable for ClassId { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -171,7 +171,7 @@ impl crate::Loggable for ClassId { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/clear_is_recursive.rs b/crates/re_types/src/components/clear_is_recursive.rs index 68abd1430f27..2c4d5f2d6cbc 100644 --- a/crates/re_types/src/components/clear_is_recursive.rs +++ b/crates/re_types/src/components/clear_is_recursive.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a ClearIsRecursive> for ::std::borrow::Cow<'a, ClearIsRecursive> } } -impl crate::Loggable for ClearIsRecursive { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for ClearIsRecursive { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -67,13 +67,13 @@ impl crate::Loggable for ClearIsRecursive { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -102,27 +102,27 @@ impl crate::Loggable for ClearIsRecursive { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) }) .with_context("rerun.components.ClearIsRecursive#recursive")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.ClearIsRecursive#recursive") .with_context("rerun.components.ClearIsRecursive")?) } diff --git a/crates/re_types/src/components/color.rs b/crates/re_types/src/components/color.rs index 5e8bdddd9b4d..8b6b32076edb 100644 --- a/crates/re_types/src/components/color.rs +++ b/crates/re_types/src/components/color.rs @@ -58,8 +58,8 @@ impl<'a> From<&'a Color> for ::std::borrow::Cow<'a, Color> { } } -impl crate::Loggable for Color { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Color { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -76,13 +76,13 @@ impl crate::Loggable for Color { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -121,18 +121,18 @@ impl crate::Loggable for Color { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data.data_type().clone(), ) @@ -141,9 +141,9 @@ impl crate::Loggable for Color { .into_iter() .map(|opt| opt.copied()) .map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Rgba32(v))) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Color#rgba") .with_context("rerun.components.Color")?) } @@ -152,16 +152,16 @@ impl crate::Loggable for Color { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -169,7 +169,7 @@ impl crate::Loggable for Color { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/depth_meter.rs b/crates/re_types/src/components/depth_meter.rs index d3fb6bca1409..4a18925e772d 100644 --- a/crates/re_types/src/components/depth_meter.rs +++ b/crates/re_types/src/components/depth_meter.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a DepthMeter> for ::std::borrow::Cow<'a, DepthMeter> { } } -impl crate::Loggable for DepthMeter { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for DepthMeter { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -65,13 +65,13 @@ impl crate::Loggable for DepthMeter { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -100,18 +100,18 @@ impl crate::Loggable for DepthMeter { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -119,9 +119,9 @@ impl crate::Loggable for DepthMeter { .with_context("rerun.components.DepthMeter#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.DepthMeter#value") .with_context("rerun.components.DepthMeter")?) } @@ -130,16 +130,16 @@ impl crate::Loggable for DepthMeter { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -147,7 +147,7 @@ impl crate::Loggable for DepthMeter { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/disconnected_space.rs b/crates/re_types/src/components/disconnected_space.rs index e0c8cdd81f98..2ddf4c170499 100644 --- a/crates/re_types/src/components/disconnected_space.rs +++ b/crates/re_types/src/components/disconnected_space.rs @@ -53,8 +53,8 @@ impl<'a> From<&'a DisconnectedSpace> for ::std::borrow::Cow<'a, DisconnectedSpac } } -impl crate::Loggable for DisconnectedSpace { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for DisconnectedSpace { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -71,13 +71,13 @@ impl crate::Loggable for DisconnectedSpace { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -106,27 +106,27 @@ impl crate::Loggable for DisconnectedSpace { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) }) .with_context("rerun.components.DisconnectedSpace#is_disconnected")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.DisconnectedSpace#is_disconnected") .with_context("rerun.components.DisconnectedSpace")?) } diff --git a/crates/re_types/src/components/draw_order.rs b/crates/re_types/src/components/draw_order.rs index 5f8e8ae54b55..d4eec8821367 100644 --- a/crates/re_types/src/components/draw_order.rs +++ b/crates/re_types/src/components/draw_order.rs @@ -53,8 +53,8 @@ impl<'a> From<&'a DrawOrder> for ::std::borrow::Cow<'a, DrawOrder> { } } -impl crate::Loggable for DrawOrder { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for DrawOrder { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -71,13 +71,13 @@ impl crate::Loggable for DrawOrder { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -106,18 +106,18 @@ impl crate::Loggable for DrawOrder { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -125,9 +125,9 @@ impl crate::Loggable for DrawOrder { .with_context("rerun.components.DrawOrder#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.DrawOrder#value") .with_context("rerun.components.DrawOrder")?) } @@ -136,16 +136,16 @@ impl crate::Loggable for DrawOrder { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -153,7 +153,7 @@ impl crate::Loggable for DrawOrder { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/half_sizes2d.rs b/crates/re_types/src/components/half_sizes2d.rs index 8acc8351d2dc..ea92ee241832 100644 --- a/crates/re_types/src/components/half_sizes2d.rs +++ b/crates/re_types/src/components/half_sizes2d.rs @@ -57,8 +57,8 @@ impl<'a> From<&'a HalfSizes2D> for ::std::borrow::Cow<'a, HalfSizes2D> { } } -impl crate::Loggable for HalfSizes2D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for HalfSizes2D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -83,13 +83,13 @@ impl crate::Loggable for HalfSizes2D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -151,19 +151,19 @@ impl crate::Loggable for HalfSizes2D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -189,7 +189,7 @@ impl crate::Loggable for HalfSizes2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -207,7 +207,7 @@ impl crate::Loggable for HalfSizes2D { elem.map(|(start, end)| { debug_assert!(end - start == 2usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -225,13 +225,13 @@ impl crate::Loggable for HalfSizes2D { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec2D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.HalfSizes2D#xy") .with_context("rerun.components.HalfSizes2D")?) } @@ -240,16 +240,16 @@ impl crate::Loggable for HalfSizes2D { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -258,7 +258,7 @@ impl crate::Loggable for HalfSizes2D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -278,7 +278,7 @@ impl crate::Loggable for HalfSizes2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/half_sizes3d.rs b/crates/re_types/src/components/half_sizes3d.rs index 09c2487a148c..b14e690c51ee 100644 --- a/crates/re_types/src/components/half_sizes3d.rs +++ b/crates/re_types/src/components/half_sizes3d.rs @@ -57,8 +57,8 @@ impl<'a> From<&'a HalfSizes3D> for ::std::borrow::Cow<'a, HalfSizes3D> { } } -impl crate::Loggable for HalfSizes3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for HalfSizes3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -83,13 +83,13 @@ impl crate::Loggable for HalfSizes3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -151,19 +151,19 @@ impl crate::Loggable for HalfSizes3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -189,7 +189,7 @@ impl crate::Loggable for HalfSizes3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -207,7 +207,7 @@ impl crate::Loggable for HalfSizes3D { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -225,13 +225,13 @@ impl crate::Loggable for HalfSizes3D { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec3D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.HalfSizes3D#xyz") .with_context("rerun.components.HalfSizes3D")?) } @@ -240,16 +240,16 @@ impl crate::Loggable for HalfSizes3D { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -258,7 +258,7 @@ impl crate::Loggable for HalfSizes3D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -278,7 +278,7 @@ impl crate::Loggable for HalfSizes3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/instance_key.rs b/crates/re_types/src/components/instance_key.rs index d2d750fd49f4..ef5d7881df14 100644 --- a/crates/re_types/src/components/instance_key.rs +++ b/crates/re_types/src/components/instance_key.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a InstanceKey> for ::std::borrow::Cow<'a, InstanceKey> { } } -impl crate::Loggable for InstanceKey { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for InstanceKey { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -65,13 +65,13 @@ impl crate::Loggable for InstanceKey { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -100,18 +100,18 @@ impl crate::Loggable for InstanceKey { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt64, arrow_data.data_type().clone(), ) @@ -119,9 +119,9 @@ impl crate::Loggable for InstanceKey { .with_context("rerun.components.InstanceKey#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.InstanceKey#value") .with_context("rerun.components.InstanceKey")?) } @@ -130,16 +130,16 @@ impl crate::Loggable for InstanceKey { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -147,7 +147,7 @@ impl crate::Loggable for InstanceKey { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt64, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/keypoint_id.rs b/crates/re_types/src/components/keypoint_id.rs index fd506eea4d5b..0ece63eea00b 100644 --- a/crates/re_types/src/components/keypoint_id.rs +++ b/crates/re_types/src/components/keypoint_id.rs @@ -62,8 +62,8 @@ impl<'a> From<&'a KeypointId> for ::std::borrow::Cow<'a, KeypointId> { } } -impl crate::Loggable for KeypointId { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for KeypointId { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -80,13 +80,13 @@ impl crate::Loggable for KeypointId { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -125,18 +125,18 @@ impl crate::Loggable for KeypointId { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -145,9 +145,9 @@ impl crate::Loggable for KeypointId { .into_iter() .map(|opt| opt.copied()) .map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::KeypointId(v))) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.KeypointId#id") .with_context("rerun.components.KeypointId")?) } @@ -156,16 +156,16 @@ impl crate::Loggable for KeypointId { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -173,7 +173,7 @@ impl crate::Loggable for KeypointId { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/line_strip2d.rs b/crates/re_types/src/components/line_strip2d.rs index 8569ff1ffa7e..bb2ef0c1151e 100644 --- a/crates/re_types/src/components/line_strip2d.rs +++ b/crates/re_types/src/components/line_strip2d.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a LineStrip2D> for ::std::borrow::Cow<'a, LineStrip2D> { } } -impl crate::Loggable for LineStrip2D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for LineStrip2D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -72,13 +72,13 @@ impl crate::Loggable for LineStrip2D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -172,40 +172,40 @@ impl crate::Loggable for LineStrip2D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { - name: "item".to_owned(), - data_type: ::arrow_datatype(), - is_nullable: false, - metadata: [].into(), - })), + use ::re_types_core::{Loggable as _, ResultExt as _}; + Ok( + { + let arrow_data = arrow_data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: ::arrow_datatype(), + is_nullable: false, + metadata: [].into(), + }), + ), arrow_data.data_type().clone(), - ) - }) - .with_context("rerun.components.LineStrip2D#points")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - { - let arrow_data_inner = arrow_data_inner - .as_any() - .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + )) + .with_context("rerun.components.LineStrip2D#points")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let arrow_data_inner = { + let arrow_data_inner = &**arrow_data.values(); + { + let arrow_data_inner = arrow_data_inner + .as_any() + .downcast_ref::<::arrow2::array::FixedSizeListArray>() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -216,103 +216,120 @@ impl crate::Loggable for LineStrip2D { 2usize, ), arrow_data_inner.data_type().clone(), - ) - }) - .with_context("rerun.components.LineStrip2D#points")?; - if arrow_data_inner.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(2usize) - .zip((2usize..).step_by(2usize).take(arrow_data_inner.len())); - let arrow_data_inner_inner = { - let arrow_data_inner_inner = &**arrow_data_inner.values(); - arrow_data_inner_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + )) + .with_context("rerun.components.LineStrip2D#points")?; + if arrow_data_inner.is_empty() { + Vec::new() + } else { + let offsets = (0..) + .step_by(2usize) + .zip( + (2usize..).step_by(2usize).take(arrow_data_inner.len()), + ); + let arrow_data_inner_inner = { + let arrow_data_inner_inner = &**arrow_data_inner.values(); + arrow_data_inner_inner + .as_any() + .downcast_ref::() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner_inner.data_type().clone(), - ) + )) + .with_context("rerun.components.LineStrip2D#points")? + .into_iter() + .map(|opt| opt.copied()) + .collect::>() + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets, + arrow_data_inner.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 2usize); + if end as usize > arrow_data_inner_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner_inner.len(), + ), + ); + } + + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner_inner + .get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .with_context("rerun.components.LineStrip2D#points")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data_inner.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 2usize); - if end as usize > arrow_data_inner_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner_inner.len(), - )); + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec2D(v)) + }) + }) + .collect::< + ::re_types_core::DeserializationResult>>, + >()? + } + .into_iter() + } + .collect::>() + }; + let offsets = arrow_data.offsets(); + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] let data = unsafe { - arrow_data_inner_inner - .get_unchecked(start as usize..end as usize) + arrow_data_inner.get_unchecked(start as usize..end as usize) }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) }) .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec2D(v)) - }) - }) - .collect::>>>()? - } - .into_iter() - } - .collect::>() - }; - let offsets = arrow_data.offsets(); - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = - unsafe { arrow_data_inner.get_unchecked(start as usize..end as usize) }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) - }) - .transpose() - }) - .collect::>>>()? + }) + .collect::< + ::re_types_core::DeserializationResult>>, + >()? + } + .into_iter() } - .into_iter() - } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() - .with_context("rerun.components.LineStrip2D#points") - .with_context("rerun.components.LineStrip2D")?) + .map(|v| { + v.ok_or_else(::re_types_core::DeserializationError::missing_data) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::<::re_types_core::DeserializationResult>>>() + .with_context("rerun.components.LineStrip2D#points") + .with_context("rerun.components.LineStrip2D")?, + ) } } diff --git a/crates/re_types/src/components/line_strip3d.rs b/crates/re_types/src/components/line_strip3d.rs index 44eae2820698..88baa28002d5 100644 --- a/crates/re_types/src/components/line_strip3d.rs +++ b/crates/re_types/src/components/line_strip3d.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a LineStrip3D> for ::std::borrow::Cow<'a, LineStrip3D> { } } -impl crate::Loggable for LineStrip3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for LineStrip3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -72,13 +72,13 @@ impl crate::Loggable for LineStrip3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -172,40 +172,40 @@ impl crate::Loggable for LineStrip3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { - name: "item".to_owned(), - data_type: ::arrow_datatype(), - is_nullable: false, - metadata: [].into(), - })), + use ::re_types_core::{Loggable as _, ResultExt as _}; + Ok( + { + let arrow_data = arrow_data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: ::arrow_datatype(), + is_nullable: false, + metadata: [].into(), + }), + ), arrow_data.data_type().clone(), - ) - }) - .with_context("rerun.components.LineStrip3D#points")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - { - let arrow_data_inner = arrow_data_inner - .as_any() - .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + )) + .with_context("rerun.components.LineStrip3D#points")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let arrow_data_inner = { + let arrow_data_inner = &**arrow_data.values(); + { + let arrow_data_inner = arrow_data_inner + .as_any() + .downcast_ref::<::arrow2::array::FixedSizeListArray>() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -216,103 +216,120 @@ impl crate::Loggable for LineStrip3D { 3usize, ), arrow_data_inner.data_type().clone(), - ) - }) - .with_context("rerun.components.LineStrip3D#points")?; - if arrow_data_inner.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(3usize) - .zip((3usize..).step_by(3usize).take(arrow_data_inner.len())); - let arrow_data_inner_inner = { - let arrow_data_inner_inner = &**arrow_data_inner.values(); - arrow_data_inner_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + )) + .with_context("rerun.components.LineStrip3D#points")?; + if arrow_data_inner.is_empty() { + Vec::new() + } else { + let offsets = (0..) + .step_by(3usize) + .zip( + (3usize..).step_by(3usize).take(arrow_data_inner.len()), + ); + let arrow_data_inner_inner = { + let arrow_data_inner_inner = &**arrow_data_inner.values(); + arrow_data_inner_inner + .as_any() + .downcast_ref::() + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner_inner.data_type().clone(), - ) + )) + .with_context("rerun.components.LineStrip3D#points")? + .into_iter() + .map(|opt| opt.copied()) + .collect::>() + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets, + arrow_data_inner.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner_inner.len(), + ), + ); + } + + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner_inner + .get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .with_context("rerun.components.LineStrip3D#points")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data_inner.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner_inner.len(), - )); + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) + }) + .collect::< + ::re_types_core::DeserializationResult>>, + >()? + } + .into_iter() + } + .collect::>() + }; + let offsets = arrow_data.offsets(); + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] let data = unsafe { - arrow_data_inner_inner - .get_unchecked(start as usize..end as usize) + arrow_data_inner.get_unchecked(start as usize..end as usize) }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) }) .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) - }) - .collect::>>>()? - } - .into_iter() - } - .collect::>() - }; - let offsets = arrow_data.offsets(); - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = - unsafe { arrow_data_inner.get_unchecked(start as usize..end as usize) }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) - }) - .transpose() - }) - .collect::>>>()? + }) + .collect::< + ::re_types_core::DeserializationResult>>, + >()? + } + .into_iter() } - .into_iter() - } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) - .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() - .with_context("rerun.components.LineStrip3D#points") - .with_context("rerun.components.LineStrip3D")?) + .map(|v| { + v.ok_or_else(::re_types_core::DeserializationError::missing_data) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::<::re_types_core::DeserializationResult>>>() + .with_context("rerun.components.LineStrip3D#points") + .with_context("rerun.components.LineStrip3D")?, + ) } } diff --git a/crates/re_types/src/components/material.rs b/crates/re_types/src/components/material.rs index 1eddedb9ac01..ddf2754a1107 100644 --- a/crates/re_types/src/components/material.rs +++ b/crates/re_types/src/components/material.rs @@ -54,8 +54,8 @@ impl<'a> From<&'a Material> for ::std::borrow::Cow<'a, Material> { } } -impl crate::Loggable for Material { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Material { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -77,13 +77,13 @@ impl crate::Loggable for Material { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -110,19 +110,19 @@ impl crate::Loggable for Material { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::Material::from_arrow_opt(arrow_data) .with_context("rerun.components.Material#material")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Material#material") .with_context("rerun.components.Material")?) } diff --git a/crates/re_types/src/components/media_type.rs b/crates/re_types/src/components/media_type.rs index f9b0e0f5c60f..7b51ceb58280 100644 --- a/crates/re_types/src/components/media_type.rs +++ b/crates/re_types/src/components/media_type.rs @@ -58,8 +58,8 @@ impl<'a> From<&'a MediaType> for ::std::borrow::Cow<'a, MediaType> { } } -impl crate::Loggable for MediaType { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for MediaType { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -76,13 +76,13 @@ impl crate::Loggable for MediaType { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -137,19 +137,19 @@ impl crate::Loggable for MediaType { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -166,7 +166,7 @@ impl crate::Loggable for MediaType { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_buf.len(), )); @@ -180,16 +180,16 @@ impl crate::Loggable for MediaType { }) .map(|res_or_opt| { res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Utf8(crate::ArrowString(v))) + res_or_opt.map(|v| crate::datatypes::Utf8(::re_types_core::ArrowString(v))) }) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.MediaType#value")? .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.MediaType#value") .with_context("rerun.components.MediaType")?) } diff --git a/crates/re_types/src/components/mesh_properties.rs b/crates/re_types/src/components/mesh_properties.rs index 4622f3352918..4547ccca4eaa 100644 --- a/crates/re_types/src/components/mesh_properties.rs +++ b/crates/re_types/src/components/mesh_properties.rs @@ -54,8 +54,8 @@ impl<'a> From<&'a MeshProperties> for ::std::borrow::Cow<'a, MeshProperties> { } } -impl crate::Loggable for MeshProperties { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for MeshProperties { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -82,13 +82,13 @@ impl crate::Loggable for MeshProperties { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -115,19 +115,19 @@ impl crate::Loggable for MeshProperties { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::MeshProperties::from_arrow_opt(arrow_data) .with_context("rerun.components.MeshProperties#props")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.MeshProperties#props") .with_context("rerun.components.MeshProperties")?) } diff --git a/crates/re_types/src/components/out_of_tree_transform3d.rs b/crates/re_types/src/components/out_of_tree_transform3d.rs index ab1551123253..e2d889b00f39 100644 --- a/crates/re_types/src/components/out_of_tree_transform3d.rs +++ b/crates/re_types/src/components/out_of_tree_transform3d.rs @@ -59,8 +59,8 @@ impl<'a> From<&'a OutOfTreeTransform3D> for ::std::borrow::Cow<'a, OutOfTreeTran } } -impl crate::Loggable for OutOfTreeTransform3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for OutOfTreeTransform3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -100,13 +100,13 @@ impl crate::Loggable for OutOfTreeTransform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -133,19 +133,19 @@ impl crate::Loggable for OutOfTreeTransform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::Transform3D::from_arrow_opt(arrow_data) .with_context("rerun.components.OutOfTreeTransform3D#repr")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.OutOfTreeTransform3D#repr") .with_context("rerun.components.OutOfTreeTransform3D")?) } diff --git a/crates/re_types/src/components/pinhole_projection.rs b/crates/re_types/src/components/pinhole_projection.rs index d390370dbd0d..97f9909724e0 100644 --- a/crates/re_types/src/components/pinhole_projection.rs +++ b/crates/re_types/src/components/pinhole_projection.rs @@ -64,8 +64,8 @@ impl<'a> From<&'a PinholeProjection> for ::std::borrow::Cow<'a, PinholeProjectio } } -impl crate::Loggable for PinholeProjection { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for PinholeProjection { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -90,13 +90,13 @@ impl crate::Loggable for PinholeProjection { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -158,19 +158,19 @@ impl crate::Loggable for PinholeProjection { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -196,7 +196,7 @@ impl crate::Loggable for PinholeProjection { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -214,7 +214,7 @@ impl crate::Loggable for PinholeProjection { elem.map(|(start, end)| { debug_assert!(end - start == 9usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -232,13 +232,13 @@ impl crate::Loggable for PinholeProjection { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Mat3x3(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.PinholeProjection#image_from_camera") .with_context("rerun.components.PinholeProjection")?) } @@ -247,16 +247,16 @@ impl crate::Loggable for PinholeProjection { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -265,7 +265,7 @@ impl crate::Loggable for PinholeProjection { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -285,7 +285,7 @@ impl crate::Loggable for PinholeProjection { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/position2d.rs b/crates/re_types/src/components/position2d.rs index 5a3698efaa76..1b0dd92eb4d5 100644 --- a/crates/re_types/src/components/position2d.rs +++ b/crates/re_types/src/components/position2d.rs @@ -55,8 +55,8 @@ impl<'a> From<&'a Position2D> for ::std::borrow::Cow<'a, Position2D> { } } -impl crate::Loggable for Position2D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Position2D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -81,13 +81,13 @@ impl crate::Loggable for Position2D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -149,19 +149,19 @@ impl crate::Loggable for Position2D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -187,7 +187,7 @@ impl crate::Loggable for Position2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -205,7 +205,7 @@ impl crate::Loggable for Position2D { elem.map(|(start, end)| { debug_assert!(end - start == 2usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -223,13 +223,13 @@ impl crate::Loggable for Position2D { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec2D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Position2D#xy") .with_context("rerun.components.Position2D")?) } @@ -238,16 +238,16 @@ impl crate::Loggable for Position2D { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -256,7 +256,7 @@ impl crate::Loggable for Position2D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -276,7 +276,7 @@ impl crate::Loggable for Position2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/position3d.rs b/crates/re_types/src/components/position3d.rs index 4e1bbe20a949..aa5d6797a04c 100644 --- a/crates/re_types/src/components/position3d.rs +++ b/crates/re_types/src/components/position3d.rs @@ -55,8 +55,8 @@ impl<'a> From<&'a Position3D> for ::std::borrow::Cow<'a, Position3D> { } } -impl crate::Loggable for Position3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Position3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -81,13 +81,13 @@ impl crate::Loggable for Position3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -149,19 +149,19 @@ impl crate::Loggable for Position3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -187,7 +187,7 @@ impl crate::Loggable for Position3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -205,7 +205,7 @@ impl crate::Loggable for Position3D { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -223,13 +223,13 @@ impl crate::Loggable for Position3D { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec3D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Position3D#xyz") .with_context("rerun.components.Position3D")?) } @@ -238,16 +238,16 @@ impl crate::Loggable for Position3D { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -256,7 +256,7 @@ impl crate::Loggable for Position3D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -276,7 +276,7 @@ impl crate::Loggable for Position3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/radius.rs b/crates/re_types/src/components/radius.rs index 680d0b8757ea..52152bcc1fc8 100644 --- a/crates/re_types/src/components/radius.rs +++ b/crates/re_types/src/components/radius.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a Radius> for ::std::borrow::Cow<'a, Radius> { } } -impl crate::Loggable for Radius { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Radius { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -65,13 +65,13 @@ impl crate::Loggable for Radius { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -100,18 +100,18 @@ impl crate::Loggable for Radius { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -119,9 +119,9 @@ impl crate::Loggable for Radius { .with_context("rerun.components.Radius#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Radius#value") .with_context("rerun.components.Radius")?) } @@ -130,16 +130,16 @@ impl crate::Loggable for Radius { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -147,7 +147,7 @@ impl crate::Loggable for Radius { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/resolution.rs b/crates/re_types/src/components/resolution.rs index 80a83237054d..3b2d951f38ca 100644 --- a/crates/re_types/src/components/resolution.rs +++ b/crates/re_types/src/components/resolution.rs @@ -56,8 +56,8 @@ impl<'a> From<&'a Resolution> for ::std::borrow::Cow<'a, Resolution> { } } -impl crate::Loggable for Resolution { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Resolution { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -82,13 +82,13 @@ impl crate::Loggable for Resolution { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -150,19 +150,19 @@ impl crate::Loggable for Resolution { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -188,7 +188,7 @@ impl crate::Loggable for Resolution { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -206,7 +206,7 @@ impl crate::Loggable for Resolution { elem.map(|(start, end)| { debug_assert!(end - start == 2usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -224,13 +224,13 @@ impl crate::Loggable for Resolution { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec2D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Resolution#resolution") .with_context("rerun.components.Resolution")?) } @@ -239,16 +239,16 @@ impl crate::Loggable for Resolution { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -257,7 +257,7 @@ impl crate::Loggable for Resolution { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -277,7 +277,7 @@ impl crate::Loggable for Resolution { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/rotation3d.rs b/crates/re_types/src/components/rotation3d.rs index ee3324df220b..ce098d48b3cd 100644 --- a/crates/re_types/src/components/rotation3d.rs +++ b/crates/re_types/src/components/rotation3d.rs @@ -57,8 +57,8 @@ impl<'a> From<&'a Rotation3D> for ::std::borrow::Cow<'a, Rotation3D> { } } -impl crate::Loggable for Rotation3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Rotation3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -98,13 +98,13 @@ impl crate::Loggable for Rotation3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -131,19 +131,19 @@ impl crate::Loggable for Rotation3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::Rotation3D::from_arrow_opt(arrow_data) .with_context("rerun.components.Rotation3D#repr")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Rotation3D#repr") .with_context("rerun.components.Rotation3D")?) } diff --git a/crates/re_types/src/components/scalar.rs b/crates/re_types/src/components/scalar.rs index ce3513fbe761..c26293d19654 100644 --- a/crates/re_types/src/components/scalar.rs +++ b/crates/re_types/src/components/scalar.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a Scalar> for ::std::borrow::Cow<'a, Scalar> { } } -impl crate::Loggable for Scalar { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Scalar { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -67,13 +67,13 @@ impl crate::Loggable for Scalar { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -102,18 +102,18 @@ impl crate::Loggable for Scalar { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float64, arrow_data.data_type().clone(), ) @@ -121,9 +121,9 @@ impl crate::Loggable for Scalar { .with_context("rerun.components.Scalar#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Scalar#value") .with_context("rerun.components.Scalar")?) } @@ -132,16 +132,16 @@ impl crate::Loggable for Scalar { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -149,7 +149,7 @@ impl crate::Loggable for Scalar { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float64, arrow_data.data_type().clone(), ) diff --git a/crates/re_types/src/components/scalar_scattering.rs b/crates/re_types/src/components/scalar_scattering.rs index d432e842cd96..1a38a5fcd645 100644 --- a/crates/re_types/src/components/scalar_scattering.rs +++ b/crates/re_types/src/components/scalar_scattering.rs @@ -46,8 +46,8 @@ impl<'a> From<&'a ScalarScattering> for ::std::borrow::Cow<'a, ScalarScattering> } } -impl crate::Loggable for ScalarScattering { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for ScalarScattering { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -64,13 +64,13 @@ impl crate::Loggable for ScalarScattering { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -99,27 +99,27 @@ impl crate::Loggable for ScalarScattering { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) }) .with_context("rerun.components.ScalarScattering#scattered")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.ScalarScattering#scattered") .with_context("rerun.components.ScalarScattering")?) } diff --git a/crates/re_types/src/components/tensor_data.rs b/crates/re_types/src/components/tensor_data.rs index 6057b4d75bab..75b6c849f9b5 100644 --- a/crates/re_types/src/components/tensor_data.rs +++ b/crates/re_types/src/components/tensor_data.rs @@ -55,8 +55,8 @@ impl<'a> From<&'a TensorData> for ::std::borrow::Cow<'a, TensorData> { } } -impl crate::Loggable for TensorData { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for TensorData { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -91,13 +91,13 @@ impl crate::Loggable for TensorData { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -124,19 +124,19 @@ impl crate::Loggable for TensorData { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::TensorData::from_arrow_opt(arrow_data) .with_context("rerun.components.TensorData#data")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.TensorData#data") .with_context("rerun.components.TensorData")?) } diff --git a/crates/re_types/src/components/text.rs b/crates/re_types/src/components/text.rs index e8932c17f9c4..bc0f5fb86401 100644 --- a/crates/re_types/src/components/text.rs +++ b/crates/re_types/src/components/text.rs @@ -55,8 +55,8 @@ impl<'a> From<&'a Text> for ::std::borrow::Cow<'a, Text> { } } -impl crate::Loggable for Text { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Text { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for Text { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -134,19 +134,19 @@ impl crate::Loggable for Text { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -163,7 +163,7 @@ impl crate::Loggable for Text { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_buf.len(), )); @@ -177,16 +177,16 @@ impl crate::Loggable for Text { }) .map(|res_or_opt| { res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Utf8(crate::ArrowString(v))) + res_or_opt.map(|v| crate::datatypes::Utf8(::re_types_core::ArrowString(v))) }) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Text#value")? .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Text#value") .with_context("rerun.components.Text")?) } diff --git a/crates/re_types/src/components/text_log_level.rs b/crates/re_types/src/components/text_log_level.rs index b7a2cac512e3..1225add9b14c 100644 --- a/crates/re_types/src/components/text_log_level.rs +++ b/crates/re_types/src/components/text_log_level.rs @@ -63,8 +63,8 @@ impl<'a> From<&'a TextLogLevel> for ::std::borrow::Cow<'a, TextLogLevel> { } } -impl crate::Loggable for TextLogLevel { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for TextLogLevel { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -81,13 +81,13 @@ impl crate::Loggable for TextLogLevel { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -142,19 +142,19 @@ impl crate::Loggable for TextLogLevel { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -171,7 +171,7 @@ impl crate::Loggable for TextLogLevel { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_buf.len(), )); @@ -185,16 +185,16 @@ impl crate::Loggable for TextLogLevel { }) .map(|res_or_opt| { res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Utf8(crate::ArrowString(v))) + res_or_opt.map(|v| crate::datatypes::Utf8(::re_types_core::ArrowString(v))) }) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.TextLogLevel#value")? .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.TextLogLevel#value") .with_context("rerun.components.TextLogLevel")?) } diff --git a/crates/re_types/src/components/transform3d.rs b/crates/re_types/src/components/transform3d.rs index 4041c9e48076..d208cab42a02 100644 --- a/crates/re_types/src/components/transform3d.rs +++ b/crates/re_types/src/components/transform3d.rs @@ -57,8 +57,8 @@ impl<'a> From<&'a Transform3D> for ::std::borrow::Cow<'a, Transform3D> { } } -impl crate::Loggable for Transform3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Transform3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -98,13 +98,13 @@ impl crate::Loggable for Transform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -131,19 +131,19 @@ impl crate::Loggable for Transform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(crate::datatypes::Transform3D::from_arrow_opt(arrow_data) .with_context("rerun.components.Transform3D#repr")? .into_iter() - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Transform3D#repr") .with_context("rerun.components.Transform3D")?) } diff --git a/crates/re_types/src/components/vector3d.rs b/crates/re_types/src/components/vector3d.rs index 7c7699351f23..4a6f7be4fdd3 100644 --- a/crates/re_types/src/components/vector3d.rs +++ b/crates/re_types/src/components/vector3d.rs @@ -55,8 +55,8 @@ impl<'a> From<&'a Vector3D> for ::std::borrow::Cow<'a, Vector3D> { } } -impl crate::Loggable for Vector3D { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for Vector3D { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -81,13 +81,13 @@ impl crate::Loggable for Vector3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -149,19 +149,19 @@ impl crate::Loggable for Vector3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -187,7 +187,7 @@ impl crate::Loggable for Vector3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -205,7 +205,7 @@ impl crate::Loggable for Vector3D { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -223,13 +223,13 @@ impl crate::Loggable for Vector3D { .map(|res_or_opt| { res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::datatypes::Vec3D(v))) }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.Vector3D#vector") .with_context("rerun.components.Vector3D")?) } @@ -238,16 +238,16 @@ impl crate::Loggable for Vector3D { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -256,7 +256,7 @@ impl crate::Loggable for Vector3D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -276,7 +276,7 @@ impl crate::Loggable for Vector3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/components/view_coordinates.rs b/crates/re_types/src/components/view_coordinates.rs index 978a6ebb7b2f..b32ddfe8f051 100644 --- a/crates/re_types/src/components/view_coordinates.rs +++ b/crates/re_types/src/components/view_coordinates.rs @@ -65,8 +65,8 @@ impl<'a> From<&'a ViewCoordinates> for ::std::borrow::Cow<'a, ViewCoordinates> { } } -impl crate::Loggable for ViewCoordinates { - type Name = crate::ComponentName; +impl ::re_types_core::Loggable for ViewCoordinates { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -91,13 +91,13 @@ impl crate::Loggable for ViewCoordinates { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -153,19 +153,19 @@ impl crate::Loggable for ViewCoordinates { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -191,7 +191,7 @@ impl crate::Loggable for ViewCoordinates { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt8, arrow_data_inner.data_type().clone(), ) @@ -209,7 +209,7 @@ impl crate::Loggable for ViewCoordinates { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -224,13 +224,13 @@ impl crate::Loggable for ViewCoordinates { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.components.ViewCoordinates#coordinates") .with_context("rerun.components.ViewCoordinates")?) } @@ -239,16 +239,16 @@ impl crate::Loggable for ViewCoordinates { #[inline] fn from_arrow( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult> + ) -> ::re_types_core::DeserializationResult> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; if let Some(validity) = arrow_data.validity() { if validity.unset_bits() != 0 { - return Err(crate::DeserializationError::missing_data()); + return Err(::re_types_core::DeserializationError::missing_data()); } } Ok({ @@ -257,7 +257,7 @@ impl crate::Loggable for ViewCoordinates { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -277,7 +277,7 @@ impl crate::Loggable for ViewCoordinates { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt8, arrow_data_inner.data_type().clone(), ) diff --git a/crates/re_types/src/datatypes/angle.rs b/crates/re_types/src/datatypes/angle.rs index df9e5c47dbd6..c96ddf4244d3 100644 --- a/crates/re_types/src/datatypes/angle.rs +++ b/crates/re_types/src/datatypes/angle.rs @@ -35,8 +35,8 @@ impl<'a> From<&'a Angle> for ::std::borrow::Cow<'a, Angle> { } } -impl crate::Loggable for Angle { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Angle { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -76,13 +76,13 @@ impl crate::Loggable for Angle { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let data: Vec<_> = data .into_iter() @@ -182,19 +182,19 @@ impl crate::Loggable for Angle { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::UnionArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Union( vec![ Field { @@ -231,14 +231,14 @@ impl crate::Loggable for Angle { let arrow_data_offsets = arrow_data .offsets() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( Self::arrow_datatype(), arrow_data.data_type().clone(), ) }) .with_context("rerun.datatypes.Angle")?; if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (0, arrow_data_types.len()), arrow_data_offsets.len(), )) @@ -253,7 +253,7 @@ impl crate::Loggable for Angle { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -272,7 +272,7 @@ impl crate::Loggable for Angle { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -293,46 +293,56 @@ impl crate::Loggable for Angle { Ok(Some(match typ { 1i8 => Angle::Radians({ if offset as usize >= radians.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - radians.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + radians.len(), + ), + ) .with_context("rerun.datatypes.Angle#Radians"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { radians.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Angle#Radians")? }), 2i8 => Angle::Degrees({ if offset as usize >= degrees.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - degrees.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + degrees.len(), + ), + ) .with_context("rerun.datatypes.Angle#Degrees"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { degrees.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Angle#Degrees")? }), _ => { - return Err(crate::DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )) + return Err( + ::re_types_core::DeserializationError::missing_union_arm( + Self::arrow_datatype(), + "", + *typ as _, + ), + ) .with_context("rerun.datatypes.Angle"); } })) } }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.Angle")? } }) diff --git a/crates/re_types/src/datatypes/annotation_info.rs b/crates/re_types/src/datatypes/annotation_info.rs index 1c3124a53a0f..7023000d0c6e 100644 --- a/crates/re_types/src/datatypes/annotation_info.rs +++ b/crates/re_types/src/datatypes/annotation_info.rs @@ -44,8 +44,8 @@ impl<'a> From<&'a AnnotationInfo> for ::std::borrow::Cow<'a, AnnotationInfo> { } } -impl crate::Loggable for AnnotationInfo { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for AnnotationInfo { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -81,13 +81,13 @@ impl crate::Loggable for AnnotationInfo { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -222,19 +222,19 @@ impl crate::Loggable for AnnotationInfo { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "id".to_owned(), @@ -271,10 +271,12 @@ impl crate::Loggable for AnnotationInfo { .collect(); let id = { if !arrays_by_name.contains_key("id") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "id", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "id", + ), + ) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["id"]; @@ -282,7 +284,7 @@ impl crate::Loggable for AnnotationInfo { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -293,10 +295,12 @@ impl crate::Loggable for AnnotationInfo { }; let label = { if !arrays_by_name.contains_key("label") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "label", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "label", + ), + ) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["label"]; @@ -305,7 +309,7 @@ impl crate::Loggable for AnnotationInfo { .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -322,10 +326,12 @@ impl crate::Loggable for AnnotationInfo { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_buf.len(), - )); + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_buf.len(), + ), + ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] @@ -337,20 +343,24 @@ impl crate::Loggable for AnnotationInfo { }) .map(|res_or_opt| { res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Utf8(crate::ArrowString(v))) + res_or_opt.map(|v| { + crate::datatypes::Utf8(::re_types_core::ArrowString(v)) + }) }) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.AnnotationInfo#label")? .into_iter() } }; let color = { if !arrays_by_name.contains_key("color") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "color", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "color", + ), + ) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["color"]; @@ -358,7 +368,7 @@ impl crate::Loggable for AnnotationInfo { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data.data_type().clone(), ) @@ -376,7 +386,7 @@ impl crate::Loggable for AnnotationInfo { opt.map(|(id, label, color)| { Ok(Self { id: id - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.AnnotationInfo#id")?, label, color, @@ -384,7 +394,7 @@ impl crate::Loggable for AnnotationInfo { }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.AnnotationInfo")? } }) diff --git a/crates/re_types/src/datatypes/class_description.rs b/crates/re_types/src/datatypes/class_description.rs index 726d5c60db2b..911ba6ff51eb 100644 --- a/crates/re_types/src/datatypes/class_description.rs +++ b/crates/re_types/src/datatypes/class_description.rs @@ -54,8 +54,8 @@ impl<'a> From<&'a ClassDescription> for ::std::borrow::Cow<'a, ClassDescription> } } -impl crate::Loggable for ClassDescription { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for ClassDescription { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -101,13 +101,13 @@ impl crate::Loggable for ClassDescription { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -265,19 +265,19 @@ impl crate::Loggable for ClassDescription { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "info".to_owned(), @@ -324,10 +324,12 @@ impl crate::Loggable for ClassDescription { .collect(); let info = { if !arrays_by_name.contains_key("info") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "info", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "info", + ), + ) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["info"]; @@ -337,10 +339,12 @@ impl crate::Loggable for ClassDescription { }; let keypoint_annotations = { if !arrays_by_name.contains_key("keypoint_annotations") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint_annotations", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint_annotations", + ), + ) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["keypoint_annotations"]; @@ -349,7 +353,7 @@ impl crate::Loggable for ClassDescription { .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: @@ -368,7 +372,9 @@ impl crate::Loggable for ClassDescription { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::AnnotationInfo::from_arrow_opt(arrow_data_inner) + crate::datatypes::AnnotationInfo::from_arrow_opt( + arrow_data_inner, + ) .with_context( "rerun.datatypes.ClassDescription#keypoint_annotations", )? @@ -377,44 +383,51 @@ impl crate::Loggable for ClassDescription { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let keypoint_connections = { if !arrays_by_name.contains_key("keypoint_connections") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint_connections", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint_connections", + ), + ) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["keypoint_connections"]; @@ -423,7 +436,7 @@ impl crate::Loggable for ClassDescription { .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: ::arrow_datatype( @@ -442,7 +455,9 @@ impl crate::Loggable for ClassDescription { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::KeypointPair::from_arrow_opt(arrow_data_inner) + crate::datatypes::KeypointPair::from_arrow_opt( + arrow_data_inner, + ) .with_context( "rerun.datatypes.ClassDescription#keypoint_connections", )? @@ -451,36 +466,41 @@ impl crate::Loggable for ClassDescription { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; arrow2::bitmap::utils::ZipValidity::new_with_validity( @@ -491,15 +511,15 @@ impl crate::Loggable for ClassDescription { opt.map(|(info, keypoint_annotations, keypoint_connections)| { Ok(Self { info: info - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.ClassDescription#info")?, keypoint_annotations: keypoint_annotations - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context( "rerun.datatypes.ClassDescription#keypoint_annotations", )?, keypoint_connections: keypoint_connections - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context( "rerun.datatypes.ClassDescription#keypoint_connections", )?, @@ -507,7 +527,7 @@ impl crate::Loggable for ClassDescription { }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.ClassDescription")? } }) diff --git a/crates/re_types/src/datatypes/class_description_map_elem.rs b/crates/re_types/src/datatypes/class_description_map_elem.rs index ac1130c631f1..88d81b0f4901 100644 --- a/crates/re_types/src/datatypes/class_description_map_elem.rs +++ b/crates/re_types/src/datatypes/class_description_map_elem.rs @@ -40,8 +40,8 @@ impl<'a> From<&'a ClassDescriptionMapElem> for ::std::borrow::Cow<'a, ClassDescr } } -impl crate::Loggable for ClassDescriptionMapElem { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for ClassDescriptionMapElem { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -71,13 +71,13 @@ impl crate::Loggable for ClassDescriptionMapElem { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -157,19 +157,19 @@ impl crate::Loggable for ClassDescriptionMapElem { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "class_id".to_owned(), @@ -200,10 +200,12 @@ impl crate::Loggable for ClassDescriptionMapElem { .collect(); let class_id = { if !arrays_by_name.contains_key("class_id") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "class_id", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "class_id", + ), + ) .with_context("rerun.datatypes.ClassDescriptionMapElem"); } let arrow_data = &**arrays_by_name["class_id"]; @@ -211,7 +213,7 @@ impl crate::Loggable for ClassDescriptionMapElem { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -223,10 +225,12 @@ impl crate::Loggable for ClassDescriptionMapElem { }; let class_description = { if !arrays_by_name.contains_key("class_description") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "class_description", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "class_description", + ), + ) .with_context("rerun.datatypes.ClassDescriptionMapElem"); } let arrow_data = &**arrays_by_name["class_description"]; @@ -242,10 +246,10 @@ impl crate::Loggable for ClassDescriptionMapElem { opt.map(|(class_id, class_description)| { Ok(Self { class_id: class_id - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.ClassDescriptionMapElem#class_id")?, class_description: class_description - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context( "rerun.datatypes.ClassDescriptionMapElem#class_description", )?, @@ -253,7 +257,7 @@ impl crate::Loggable for ClassDescriptionMapElem { }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.ClassDescriptionMapElem")? } }) diff --git a/crates/re_types/src/datatypes/class_id.rs b/crates/re_types/src/datatypes/class_id.rs index 06163b114ad5..ad0eb8017590 100644 --- a/crates/re_types/src/datatypes/class_id.rs +++ b/crates/re_types/src/datatypes/class_id.rs @@ -62,8 +62,8 @@ impl<'a> From<&'a ClassId> for ::std::borrow::Cow<'a, ClassId> { } } -impl crate::Loggable for ClassId { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for ClassId { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -80,13 +80,13 @@ impl crate::Loggable for ClassId { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -115,18 +115,18 @@ impl crate::Loggable for ClassId { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -134,9 +134,9 @@ impl crate::Loggable for ClassId { .with_context("rerun.datatypes.ClassId#id")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.ClassId#id") .with_context("rerun.datatypes.ClassId")?) } diff --git a/crates/re_types/src/datatypes/float32.rs b/crates/re_types/src/datatypes/float32.rs index e65d9f1d1b3d..0c3f90e7e435 100644 --- a/crates/re_types/src/datatypes/float32.rs +++ b/crates/re_types/src/datatypes/float32.rs @@ -46,8 +46,8 @@ impl<'a> From<&'a Float32> for ::std::borrow::Cow<'a, Float32> { } } -impl crate::Loggable for Float32 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Float32 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -64,13 +64,13 @@ impl crate::Loggable for Float32 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -99,18 +99,18 @@ impl crate::Loggable for Float32 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -118,9 +118,9 @@ impl crate::Loggable for Float32 { .with_context("rerun.datatypes.Float32#value")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Float32#value") .with_context("rerun.datatypes.Float32")?) } diff --git a/crates/re_types/src/datatypes/keypoint_id.rs b/crates/re_types/src/datatypes/keypoint_id.rs index fd77e0ec1bd2..1ad7eda03a0f 100644 --- a/crates/re_types/src/datatypes/keypoint_id.rs +++ b/crates/re_types/src/datatypes/keypoint_id.rs @@ -64,8 +64,8 @@ impl<'a> From<&'a KeypointId> for ::std::borrow::Cow<'a, KeypointId> { } } -impl crate::Loggable for KeypointId { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for KeypointId { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -82,13 +82,13 @@ impl crate::Loggable for KeypointId { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -117,18 +117,18 @@ impl crate::Loggable for KeypointId { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -136,9 +136,9 @@ impl crate::Loggable for KeypointId { .with_context("rerun.datatypes.KeypointId#id")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.KeypointId#id") .with_context("rerun.datatypes.KeypointId")?) } diff --git a/crates/re_types/src/datatypes/keypoint_pair.rs b/crates/re_types/src/datatypes/keypoint_pair.rs index a95d48bb28e3..70a917ea3838 100644 --- a/crates/re_types/src/datatypes/keypoint_pair.rs +++ b/crates/re_types/src/datatypes/keypoint_pair.rs @@ -38,8 +38,8 @@ impl<'a> From<&'a KeypointPair> for ::std::borrow::Cow<'a, KeypointPair> { } } -impl crate::Loggable for KeypointPair { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for KeypointPair { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -69,13 +69,13 @@ impl crate::Loggable for KeypointPair { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -165,19 +165,19 @@ impl crate::Loggable for KeypointPair { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "keypoint0".to_owned(), @@ -208,10 +208,12 @@ impl crate::Loggable for KeypointPair { .collect(); let keypoint0 = { if !arrays_by_name.contains_key("keypoint0") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint0", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint0", + ), + ) .with_context("rerun.datatypes.KeypointPair"); } let arrow_data = &**arrays_by_name["keypoint0"]; @@ -219,7 +221,7 @@ impl crate::Loggable for KeypointPair { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -231,10 +233,12 @@ impl crate::Loggable for KeypointPair { }; let keypoint1 = { if !arrays_by_name.contains_key("keypoint1") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint1", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint1", + ), + ) .with_context("rerun.datatypes.KeypointPair"); } let arrow_data = &**arrays_by_name["keypoint1"]; @@ -242,7 +246,7 @@ impl crate::Loggable for KeypointPair { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt16, arrow_data.data_type().clone(), ) @@ -260,16 +264,16 @@ impl crate::Loggable for KeypointPair { opt.map(|(keypoint0, keypoint1)| { Ok(Self { keypoint0: keypoint0 - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.KeypointPair#keypoint0")?, keypoint1: keypoint1 - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.KeypointPair#keypoint1")?, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.KeypointPair")? } }) diff --git a/crates/re_types/src/datatypes/mat3x3.rs b/crates/re_types/src/datatypes/mat3x3.rs index b9be37a9cd05..ad9ac77671d9 100644 --- a/crates/re_types/src/datatypes/mat3x3.rs +++ b/crates/re_types/src/datatypes/mat3x3.rs @@ -58,8 +58,8 @@ impl<'a> From<&'a Mat3x3> for ::std::borrow::Cow<'a, Mat3x3> { } } -impl crate::Loggable for Mat3x3 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Mat3x3 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -84,13 +84,13 @@ impl crate::Loggable for Mat3x3 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -146,19 +146,19 @@ impl crate::Loggable for Mat3x3 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -184,7 +184,7 @@ impl crate::Loggable for Mat3x3 { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -202,7 +202,7 @@ impl crate::Loggable for Mat3x3 { elem.map(|(start, end)| { debug_assert!(end - start == 9usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -217,13 +217,13 @@ impl crate::Loggable for Mat3x3 { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Mat3x3#flat_columns") .with_context("rerun.datatypes.Mat3x3")?) } diff --git a/crates/re_types/src/datatypes/mat4x4.rs b/crates/re_types/src/datatypes/mat4x4.rs index d44140e7b3e8..1ecba20dd2fb 100644 --- a/crates/re_types/src/datatypes/mat4x4.rs +++ b/crates/re_types/src/datatypes/mat4x4.rs @@ -59,8 +59,8 @@ impl<'a> From<&'a Mat4x4> for ::std::borrow::Cow<'a, Mat4x4> { } } -impl crate::Loggable for Mat4x4 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Mat4x4 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -85,13 +85,13 @@ impl crate::Loggable for Mat4x4 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -147,19 +147,19 @@ impl crate::Loggable for Mat4x4 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -185,7 +185,7 @@ impl crate::Loggable for Mat4x4 { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -203,7 +203,7 @@ impl crate::Loggable for Mat4x4 { elem.map(|(start, end)| { debug_assert!(end - start == 16usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -218,13 +218,13 @@ impl crate::Loggable for Mat4x4 { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Mat4x4#flat_columns") .with_context("rerun.datatypes.Mat4x4")?) } diff --git a/crates/re_types/src/datatypes/material.rs b/crates/re_types/src/datatypes/material.rs index 56a8d563f392..870c7ad9fdcb 100644 --- a/crates/re_types/src/datatypes/material.rs +++ b/crates/re_types/src/datatypes/material.rs @@ -59,8 +59,8 @@ impl<'a> From<&'a Material> for ::std::borrow::Cow<'a, Material> { } } -impl crate::Loggable for Material { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Material { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -82,13 +82,13 @@ impl crate::Loggable for Material { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -147,19 +147,19 @@ impl crate::Loggable for Material { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![Field { name: "albedo_factor".to_owned(), data_type: ::arrow_datatype(), @@ -182,10 +182,12 @@ impl crate::Loggable for Material { .collect(); let albedo_factor = { if !arrays_by_name.contains_key("albedo_factor") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "albedo_factor", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "albedo_factor", + ), + ) .with_context("rerun.datatypes.Material"); } let arrow_data = &**arrays_by_name["albedo_factor"]; @@ -193,7 +195,7 @@ impl crate::Loggable for Material { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data.data_type().clone(), ) @@ -211,7 +213,7 @@ impl crate::Loggable for Material { opt.map(|(albedo_factor)| Ok(Self { albedo_factor })) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.Material")? } }) diff --git a/crates/re_types/src/datatypes/mesh_properties.rs b/crates/re_types/src/datatypes/mesh_properties.rs index a7347c15f42c..e9ea2c258911 100644 --- a/crates/re_types/src/datatypes/mesh_properties.rs +++ b/crates/re_types/src/datatypes/mesh_properties.rs @@ -20,17 +20,17 @@ pub struct MeshProperties { /// A flattened array of vertex indices that describe the mesh's triangles. /// /// Its length must be divisible by 3. - pub indices: Option>, + pub indices: Option<::re_types_core::ArrowBuffer>, } -impl From>> for MeshProperties { +impl From>> for MeshProperties { #[inline] - fn from(indices: Option>) -> Self { + fn from(indices: Option<::re_types_core::ArrowBuffer>) -> Self { Self { indices } } } -impl From for Option> { +impl From for Option<::re_types_core::ArrowBuffer> { #[inline] fn from(value: MeshProperties) -> Self { value.indices @@ -51,8 +51,8 @@ impl<'a> From<&'a MeshProperties> for ::std::borrow::Cow<'a, MeshProperties> { } } -impl crate::Loggable for MeshProperties { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for MeshProperties { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -79,13 +79,13 @@ impl crate::Loggable for MeshProperties { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -165,19 +165,19 @@ impl crate::Loggable for MeshProperties { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![Field { name: "indices".to_owned(), data_type: DataType::List(Box::new(Field { @@ -205,10 +205,12 @@ impl crate::Loggable for MeshProperties { .collect(); let indices = { if !arrays_by_name.contains_key("indices") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "indices", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "indices", + ), + ) .with_context("rerun.datatypes.MeshProperties"); } let arrow_data = &**arrays_by_name["indices"]; @@ -217,7 +219,7 @@ impl crate::Loggable for MeshProperties { .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt32, @@ -236,45 +238,48 @@ impl crate::Loggable for MeshProperties { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.MeshProperties#indices")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; arrow2::bitmap::utils::ZipValidity::new_with_validity( @@ -282,7 +287,7 @@ impl crate::Loggable for MeshProperties { arrow_data.validity(), ) .map(|opt| opt.map(|(indices)| Ok(Self { indices })).transpose()) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.MeshProperties")? } }) diff --git a/crates/re_types/src/datatypes/quaternion.rs b/crates/re_types/src/datatypes/quaternion.rs index 19811b94bc39..23eae8930720 100644 --- a/crates/re_types/src/datatypes/quaternion.rs +++ b/crates/re_types/src/datatypes/quaternion.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a Quaternion> for ::std::borrow::Cow<'a, Quaternion> { } } -impl crate::Loggable for Quaternion { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Quaternion { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -75,13 +75,13 @@ impl crate::Loggable for Quaternion { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -137,19 +137,19 @@ impl crate::Loggable for Quaternion { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -175,7 +175,7 @@ impl crate::Loggable for Quaternion { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -193,7 +193,7 @@ impl crate::Loggable for Quaternion { elem.map(|(start, end)| { debug_assert!(end - start == 4usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -208,13 +208,13 @@ impl crate::Loggable for Quaternion { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Quaternion#xyzw") .with_context("rerun.datatypes.Quaternion")?) } diff --git a/crates/re_types/src/datatypes/rgba32.rs b/crates/re_types/src/datatypes/rgba32.rs index dbde62afb44f..ecd0a600a58a 100644 --- a/crates/re_types/src/datatypes/rgba32.rs +++ b/crates/re_types/src/datatypes/rgba32.rs @@ -52,8 +52,8 @@ impl<'a> From<&'a Rgba32> for ::std::borrow::Cow<'a, Rgba32> { } } -impl crate::Loggable for Rgba32 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Rgba32 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -70,13 +70,13 @@ impl crate::Loggable for Rgba32 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -105,18 +105,18 @@ impl crate::Loggable for Rgba32 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok(arrow_data .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data.data_type().clone(), ) @@ -124,9 +124,9 @@ impl crate::Loggable for Rgba32 { .with_context("rerun.datatypes.Rgba32#rgba")? .into_iter() .map(|opt| opt.copied()) - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Rgba32#rgba") .with_context("rerun.datatypes.Rgba32")?) } diff --git a/crates/re_types/src/datatypes/rotation3d.rs b/crates/re_types/src/datatypes/rotation3d.rs index 77778362e0cc..dd9c484b20d2 100644 --- a/crates/re_types/src/datatypes/rotation3d.rs +++ b/crates/re_types/src/datatypes/rotation3d.rs @@ -38,8 +38,8 @@ impl<'a> From<&'a Rotation3D> for ::std::borrow::Cow<'a, Rotation3D> { } } -impl crate::Loggable for Rotation3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Rotation3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -79,13 +79,13 @@ impl crate::Loggable for Rotation3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let data: Vec<_> = data .into_iter() @@ -228,19 +228,19 @@ impl crate::Loggable for Rotation3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::UnionArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Union( vec![ Field { @@ -278,14 +278,14 @@ impl crate::Loggable for Rotation3D { let arrow_data_offsets = arrow_data .offsets() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( Self::arrow_datatype(), arrow_data.data_type().clone(), ) }) .with_context("rerun.datatypes.Rotation3D")?; if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (0, arrow_data_types.len()), arrow_data_offsets.len(), )) @@ -300,20 +300,18 @@ impl crate::Loggable for Rotation3D { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::FixedSizeList( - Box::new(Field { - name: "item".to_owned(), - data_type: DataType::Float32, - is_nullable: false, - metadata: [].into(), - }), - 4usize, - ), - arrow_data.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::FixedSizeList( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }), + 4usize, + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.Rotation3D#Quaternion")?; if arrow_data.is_empty() { Vec::new() @@ -326,51 +324,58 @@ impl crate::Loggable for Rotation3D { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.Rotation3D#Quaternion")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 4usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 4usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Quaternion(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Quaternion(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let axis_angle = { if 2usize >= arrow_data_arrays.len() { @@ -393,46 +398,56 @@ impl crate::Loggable for Rotation3D { Ok(Some(match typ { 1i8 => Rotation3D::Quaternion({ if offset as usize >= quaternion.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - quaternion.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + quaternion.len(), + ), + ) .with_context("rerun.datatypes.Rotation3D#Quaternion"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { quaternion.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Rotation3D#Quaternion")? }), 2i8 => Rotation3D::AxisAngle({ if offset as usize >= axis_angle.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - axis_angle.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + axis_angle.len(), + ), + ) .with_context("rerun.datatypes.Rotation3D#AxisAngle"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { axis_angle.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Rotation3D#AxisAngle")? }), _ => { - return Err(crate::DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )) + return Err( + ::re_types_core::DeserializationError::missing_union_arm( + Self::arrow_datatype(), + "", + *typ as _, + ), + ) .with_context("rerun.datatypes.Rotation3D"); } })) } }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.Rotation3D")? } }) diff --git a/crates/re_types/src/datatypes/rotation_axis_angle.rs b/crates/re_types/src/datatypes/rotation_axis_angle.rs index 6c96d1c469d6..3c7b7d8d6474 100644 --- a/crates/re_types/src/datatypes/rotation_axis_angle.rs +++ b/crates/re_types/src/datatypes/rotation_axis_angle.rs @@ -42,8 +42,8 @@ impl<'a> From<&'a RotationAxisAngle> for ::std::borrow::Cow<'a, RotationAxisAngl } } -impl crate::Loggable for RotationAxisAngle { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for RotationAxisAngle { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for RotationAxisAngle { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -188,19 +188,19 @@ impl crate::Loggable for RotationAxisAngle { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "axis".to_owned(), @@ -231,10 +231,12 @@ impl crate::Loggable for RotationAxisAngle { .collect(); let axis = { if !arrays_by_name.contains_key("axis") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "axis", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "axis", + ), + ) .with_context("rerun.datatypes.RotationAxisAngle"); } let arrow_data = &**arrays_by_name["axis"]; @@ -243,7 +245,7 @@ impl crate::Loggable for RotationAxisAngle { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -268,57 +270,66 @@ impl crate::Loggable for RotationAxisAngle { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.RotationAxisAngle#axis")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let angle = { if !arrays_by_name.contains_key("angle") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "angle", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "angle", + ), + ) .with_context("rerun.datatypes.RotationAxisAngle"); } let arrow_data = &**arrays_by_name["angle"]; @@ -334,16 +345,16 @@ impl crate::Loggable for RotationAxisAngle { opt.map(|(axis, angle)| { Ok(Self { axis: axis - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.RotationAxisAngle#axis")?, angle: angle - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.RotationAxisAngle#angle")?, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.RotationAxisAngle")? } }) diff --git a/crates/re_types/src/datatypes/scale3d.rs b/crates/re_types/src/datatypes/scale3d.rs index 5308b50cb22e..e311fc1b04f6 100644 --- a/crates/re_types/src/datatypes/scale3d.rs +++ b/crates/re_types/src/datatypes/scale3d.rs @@ -38,8 +38,8 @@ impl<'a> From<&'a Scale3D> for ::std::borrow::Cow<'a, Scale3D> { } } -impl crate::Loggable for Scale3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Scale3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -79,13 +79,13 @@ impl crate::Loggable for Scale3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let data: Vec<_> = data .into_iter() @@ -226,19 +226,19 @@ impl crate::Loggable for Scale3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::UnionArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Union( vec![ Field { @@ -275,14 +275,14 @@ impl crate::Loggable for Scale3D { let arrow_data_offsets = arrow_data .offsets() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( Self::arrow_datatype(), arrow_data.data_type().clone(), ) }) .with_context("rerun.datatypes.Scale3D")?; if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (0, arrow_data_types.len()), arrow_data_offsets.len(), )) @@ -297,20 +297,18 @@ impl crate::Loggable for Scale3D { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::FixedSizeList( - Box::new(Field { - name: "item".to_owned(), - data_type: DataType::Float32, - is_nullable: false, - metadata: [].into(), - }), - 3usize, - ), - arrow_data.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::FixedSizeList( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }), + 3usize, + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.Scale3D#ThreeD")?; if arrow_data.is_empty() { Vec::new() @@ -323,51 +321,58 @@ impl crate::Loggable for Scale3D { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.Scale3D#ThreeD")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let uniform = { if 2usize >= arrow_data_arrays.len() { @@ -378,7 +383,7 @@ impl crate::Loggable for Scale3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data.data_type().clone(), ) @@ -399,46 +404,56 @@ impl crate::Loggable for Scale3D { Ok(Some(match typ { 1i8 => Scale3D::ThreeD({ if offset as usize >= three_d.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - three_d.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + three_d.len(), + ), + ) .with_context("rerun.datatypes.Scale3D#ThreeD"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { three_d.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Scale3D#ThreeD")? }), 2i8 => Scale3D::Uniform({ if offset as usize >= uniform.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - uniform.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + uniform.len(), + ), + ) .with_context("rerun.datatypes.Scale3D#Uniform"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { uniform.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.Scale3D#Uniform")? }), _ => { - return Err(crate::DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )) + return Err( + ::re_types_core::DeserializationError::missing_union_arm( + Self::arrow_datatype(), + "", + *typ as _, + ), + ) .with_context("rerun.datatypes.Scale3D"); } })) } }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.Scale3D")? } }) diff --git a/crates/re_types/src/datatypes/tensor_buffer.rs b/crates/re_types/src/datatypes/tensor_buffer.rs index 9d0dd2417a29..972c091f76d4 100644 --- a/crates/re_types/src/datatypes/tensor_buffer.rs +++ b/crates/re_types/src/datatypes/tensor_buffer.rs @@ -19,18 +19,18 @@ /// Tensor elements are stored in a contiguous buffer of a single type. #[derive(Clone, PartialEq)] pub enum TensorBuffer { - U8(crate::ArrowBuffer), - U16(crate::ArrowBuffer), - U32(crate::ArrowBuffer), - U64(crate::ArrowBuffer), - I8(crate::ArrowBuffer), - I16(crate::ArrowBuffer), - I32(crate::ArrowBuffer), - I64(crate::ArrowBuffer), - F16(crate::ArrowBuffer), - F32(crate::ArrowBuffer), - F64(crate::ArrowBuffer), - Jpeg(crate::ArrowBuffer), + U8(::re_types_core::ArrowBuffer), + U16(::re_types_core::ArrowBuffer), + U32(::re_types_core::ArrowBuffer), + U64(::re_types_core::ArrowBuffer), + I8(::re_types_core::ArrowBuffer), + I16(::re_types_core::ArrowBuffer), + I32(::re_types_core::ArrowBuffer), + I64(::re_types_core::ArrowBuffer), + F16(::re_types_core::ArrowBuffer), + F32(::re_types_core::ArrowBuffer), + F64(::re_types_core::ArrowBuffer), + Jpeg(::re_types_core::ArrowBuffer), } impl<'a> From for ::std::borrow::Cow<'a, TensorBuffer> { @@ -47,8 +47,8 @@ impl<'a> From<&'a TensorBuffer> for ::std::borrow::Cow<'a, TensorBuffer> { } } -impl crate::Loggable for TensorBuffer { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for TensorBuffer { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -210,13 +210,13 @@ impl crate::Loggable for TensorBuffer { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let data: Vec<_> = data .into_iter() @@ -984,19 +984,19 @@ impl crate::Loggable for TensorBuffer { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::UnionArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Union( vec![ Field { @@ -1156,14 +1156,14 @@ impl crate::Loggable for TensorBuffer { let arrow_data_offsets = arrow_data .offsets() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( Self::arrow_datatype(), arrow_data.data_type().clone(), ) }) .with_context("rerun.datatypes.TensorBuffer")?; if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (0, arrow_data_types.len()), arrow_data_offsets.len(), )) @@ -1178,17 +1178,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt8, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U8")?; if arrow_data.is_empty() { Vec::new() @@ -1198,47 +1198,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt8, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt8, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U8")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u16 = { if 2usize >= arrow_data_arrays.len() { @@ -1249,17 +1252,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt16, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U16")?; if arrow_data.is_empty() { Vec::new() @@ -1269,47 +1272,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt16, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt16, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u32 = { if 3usize >= arrow_data_arrays.len() { @@ -1320,17 +1326,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt32, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U32")?; if arrow_data.is_empty() { Vec::new() @@ -1340,47 +1346,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u64 = { if 4usize >= arrow_data_arrays.len() { @@ -1391,17 +1400,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt64, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U64")?; if arrow_data.is_empty() { Vec::new() @@ -1411,47 +1420,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt64, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt64, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#U64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i8 = { if 5usize >= arrow_data_arrays.len() { @@ -1462,17 +1474,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Int8, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I8")?; if arrow_data.is_empty() { Vec::new() @@ -1482,47 +1494,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Int8, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int8, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I8")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i16 = { if 6usize >= arrow_data_arrays.len() { @@ -1533,17 +1548,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Int16, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I16")?; if arrow_data.is_empty() { Vec::new() @@ -1553,47 +1568,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Int16, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int16, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i32 = { if 7usize >= arrow_data_arrays.len() { @@ -1604,17 +1622,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Int32, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I32")?; if arrow_data.is_empty() { Vec::new() @@ -1624,47 +1642,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Int32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i64 = { if 8usize >= arrow_data_arrays.len() { @@ -1675,17 +1696,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Int64, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I64")?; if arrow_data.is_empty() { Vec::new() @@ -1695,47 +1716,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Int64, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int64, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#I64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f16 = { if 9usize >= arrow_data_arrays.len() { @@ -1746,17 +1770,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Float16, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F16")?; if arrow_data.is_empty() { Vec::new() @@ -1766,47 +1790,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float16, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float16, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f32 = { if 10usize >= arrow_data_arrays.len() { @@ -1817,17 +1844,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Float32, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F32")?; if arrow_data.is_empty() { Vec::new() @@ -1837,47 +1864,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f64 = { if 11usize >= arrow_data_arrays.len() { @@ -1888,17 +1918,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::Float64, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F64")?; if arrow_data.is_empty() { Vec::new() @@ -1908,47 +1938,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float64, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float64, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#F64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let jpeg = { if 12usize >= arrow_data_arrays.len() { @@ -1959,17 +1992,17 @@ impl crate::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::List(Box::new(Field { + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List( + Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt8, is_nullable: false, metadata: [].into(), - })), - arrow_data.data_type().clone(), - ) - }) + }), + ), + arrow_data.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#JPEG")?; if arrow_data.is_empty() { Vec::new() @@ -1979,47 +2012,50 @@ impl crate::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::UInt8, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt8, + arrow_data_inner.data_type().clone(), + )) .with_context("rerun.datatypes.TensorBuffer#JPEG")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = crate::ArrowBuffer::from(data); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; arrow_data_types .iter() @@ -2032,196 +2068,246 @@ impl crate::Loggable for TensorBuffer { Ok(Some(match typ { 1i8 => TensorBuffer::U8({ if offset as usize >= u8.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - u8.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + u8.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#U8"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { u8.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#U8")? }), 2i8 => TensorBuffer::U16({ if offset as usize >= u16.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - u16.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + u16.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#U16"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { u16.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#U16")? }), 3i8 => TensorBuffer::U32({ if offset as usize >= u32.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - u32.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + u32.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#U32"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { u32.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#U32")? }), 4i8 => TensorBuffer::U64({ if offset as usize >= u64.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - u64.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + u64.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#U64"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { u64.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#U64")? }), 5i8 => TensorBuffer::I8({ if offset as usize >= i8.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - i8.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + i8.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#I8"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { i8.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#I8")? }), 6i8 => TensorBuffer::I16({ if offset as usize >= i16.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - i16.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + i16.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#I16"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { i16.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#I16")? }), 7i8 => TensorBuffer::I32({ if offset as usize >= i32.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - i32.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + i32.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#I32"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { i32.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#I32")? }), 8i8 => TensorBuffer::I64({ if offset as usize >= i64.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - i64.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + i64.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#I64"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { i64.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#I64")? }), 9i8 => TensorBuffer::F16({ if offset as usize >= f16.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - f16.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + f16.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#F16"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { f16.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#F16")? }), 10i8 => TensorBuffer::F32({ if offset as usize >= f32.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - f32.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + f32.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#F32"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { f32.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#F32")? }), 11i8 => TensorBuffer::F64({ if offset as usize >= f64.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - f64.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + f64.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#F64"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { f64.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#F64")? }), 12i8 => TensorBuffer::Jpeg({ if offset as usize >= jpeg.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - jpeg.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + jpeg.len(), + ), + ) .with_context("rerun.datatypes.TensorBuffer#JPEG"); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { jpeg.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context("rerun.datatypes.TensorBuffer#JPEG")? }), _ => { - return Err(crate::DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )) + return Err( + ::re_types_core::DeserializationError::missing_union_arm( + Self::arrow_datatype(), + "", + *typ as _, + ), + ) .with_context("rerun.datatypes.TensorBuffer"); } })) } }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.TensorBuffer")? } }) diff --git a/crates/re_types/src/datatypes/tensor_data.rs b/crates/re_types/src/datatypes/tensor_data.rs index 81aa9d237bed..d596ee962228 100644 --- a/crates/re_types/src/datatypes/tensor_data.rs +++ b/crates/re_types/src/datatypes/tensor_data.rs @@ -42,8 +42,8 @@ impl<'a> From<&'a TensorData> for ::std::borrow::Cow<'a, TensorData> { } } -impl crate::Loggable for TensorData { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for TensorData { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -78,13 +78,13 @@ impl crate::Loggable for TensorData { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -182,19 +182,19 @@ impl crate::Loggable for TensorData { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "shape".to_owned(), @@ -231,10 +231,12 @@ impl crate::Loggable for TensorData { .collect(); let shape = { if !arrays_by_name.contains_key("shape") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "shape", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "shape", + ), + ) .with_context("rerun.datatypes.TensorData"); } let arrow_data = &**arrays_by_name["shape"]; @@ -243,7 +245,7 @@ impl crate::Loggable for TensorData { .as_any() .downcast_ref::<::arrow2::array::ListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::List(Box::new(Field { name: "item".to_owned(), data_type: @@ -260,51 +262,60 @@ impl crate::Loggable for TensorData { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::TensorDimension::from_arrow_opt(arrow_data_inner) + crate::datatypes::TensorDimension::from_arrow_opt( + arrow_data_inner, + ) .with_context("rerun.datatypes.TensorData#shape")? .into_iter() .collect::>() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) + }) + .transpose() }) - .transpose() - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let buffer = { if !arrays_by_name.contains_key("buffer") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "buffer", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "buffer", + ), + ) .with_context("rerun.datatypes.TensorData"); } let arrow_data = &**arrays_by_name["buffer"]; @@ -320,16 +331,16 @@ impl crate::Loggable for TensorData { opt.map(|(shape, buffer)| { Ok(Self { shape: shape - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.TensorData#shape")?, buffer: buffer - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.TensorData#buffer")?, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.TensorData")? } }) diff --git a/crates/re_types/src/datatypes/tensor_dimension.rs b/crates/re_types/src/datatypes/tensor_dimension.rs index 24b7ff80aa42..82574542a4f2 100644 --- a/crates/re_types/src/datatypes/tensor_dimension.rs +++ b/crates/re_types/src/datatypes/tensor_dimension.rs @@ -21,7 +21,7 @@ pub struct TensorDimension { pub size: u64, /// The name of this dimension, e.g. "width", "height", "channel", "batch', …. - pub name: Option, + pub name: Option<::re_types_core::ArrowString>, } impl<'a> From for ::std::borrow::Cow<'a, TensorDimension> { @@ -38,8 +38,8 @@ impl<'a> From<&'a TensorDimension> for ::std::borrow::Cow<'a, TensorDimension> { } } -impl crate::Loggable for TensorDimension { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for TensorDimension { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -69,13 +69,13 @@ impl crate::Loggable for TensorDimension { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -163,19 +163,19 @@ impl crate::Loggable for TensorDimension { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "size".to_owned(), @@ -206,10 +206,12 @@ impl crate::Loggable for TensorDimension { .collect(); let size = { if !arrays_by_name.contains_key("size") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "size", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "size", + ), + ) .with_context("rerun.datatypes.TensorDimension"); } let arrow_data = &**arrays_by_name["size"]; @@ -217,7 +219,7 @@ impl crate::Loggable for TensorDimension { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt64, arrow_data.data_type().clone(), ) @@ -228,10 +230,12 @@ impl crate::Loggable for TensorDimension { }; let name = { if !arrays_by_name.contains_key("name") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "name", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "name", + ), + ) .with_context("rerun.datatypes.TensorDimension"); } let arrow_data = &**arrays_by_name["name"]; @@ -240,7 +244,7 @@ impl crate::Loggable for TensorDimension { .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -257,10 +261,12 @@ impl crate::Loggable for TensorDimension { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_buf.len(), - )); + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_buf.len(), + ), + ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] @@ -271,9 +277,11 @@ impl crate::Loggable for TensorDimension { .transpose() }) .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::ArrowString(v))) + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| ::re_types_core::ArrowString(v)) + }) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.TensorDimension#name")? .into_iter() } @@ -286,14 +294,14 @@ impl crate::Loggable for TensorDimension { opt.map(|(size, name)| { Ok(Self { size: size - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.TensorDimension#size")?, name, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.TensorDimension")? } }) diff --git a/crates/re_types/src/datatypes/transform3d.rs b/crates/re_types/src/datatypes/transform3d.rs index 3b58456e671f..be4b87e01567 100644 --- a/crates/re_types/src/datatypes/transform3d.rs +++ b/crates/re_types/src/datatypes/transform3d.rs @@ -38,8 +38,8 @@ impl<'a> From<&'a Transform3D> for ::std::borrow::Cow<'a, Transform3D> { } } -impl crate::Loggable for Transform3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Transform3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -79,13 +79,13 @@ impl crate::Loggable for Transform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let data: Vec<_> = data .into_iter() @@ -197,19 +197,19 @@ impl crate::Loggable for Transform3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::UnionArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Union( vec![ Field { name : "_null_markers".to_owned(), data_type : @@ -237,14 +237,14 @@ impl crate::Loggable for Transform3D { let arrow_data_offsets = arrow_data .offsets() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( Self::arrow_datatype(), arrow_data.data_type().clone(), ) }) .with_context("rerun.datatypes.Transform3D")?; if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (0, arrow_data_types.len()), arrow_data_offsets.len(), )) @@ -281,10 +281,12 @@ impl crate::Loggable for Transform3D { Ok(Some(match typ { 1i8 => Transform3D::TranslationAndMat3x3({ if offset as usize >= translation_and_mat3x3.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - translation_and_mat3x3.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + translation_and_mat3x3.len(), + ), + ) .with_context( "rerun.datatypes.Transform3D#TranslationAndMat3x3", ); @@ -293,17 +295,21 @@ impl crate::Loggable for Transform3D { #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { translation_and_mat3x3.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context( "rerun.datatypes.Transform3D#TranslationAndMat3x3", )? }), 2i8 => Transform3D::TranslationRotationScale({ if offset as usize >= translation_rotation_scale.len() { - return Err(crate::DeserializationError::offset_oob( - offset as _, - translation_rotation_scale.len(), - )) + return Err( + ::re_types_core::DeserializationError::offset_oob( + offset as _, + translation_rotation_scale.len(), + ), + ) .with_context( "rerun.datatypes.Transform3D#TranslationRotationScale", ); @@ -314,23 +320,27 @@ impl crate::Loggable for Transform3D { translation_rotation_scale.get_unchecked(offset as usize) } .clone() - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else( + ::re_types_core::DeserializationError::missing_data, + ) .with_context( "rerun.datatypes.Transform3D#TranslationRotationScale", )? }), _ => { - return Err(crate::DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )) + return Err( + ::re_types_core::DeserializationError::missing_union_arm( + Self::arrow_datatype(), + "", + *typ as _, + ), + ) .with_context("rerun.datatypes.Transform3D"); } })) } }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.Transform3D")? } }) diff --git a/crates/re_types/src/datatypes/translation_and_mat3x3.rs b/crates/re_types/src/datatypes/translation_and_mat3x3.rs index 0a4c6285410e..81b0f891ac01 100644 --- a/crates/re_types/src/datatypes/translation_and_mat3x3.rs +++ b/crates/re_types/src/datatypes/translation_and_mat3x3.rs @@ -46,8 +46,8 @@ impl<'a> From<&'a TranslationAndMat3x3> for ::std::borrow::Cow<'a, TranslationAn } } -impl crate::Loggable for TranslationAndMat3x3 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for TranslationAndMat3x3 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -83,13 +83,13 @@ impl crate::Loggable for TranslationAndMat3x3 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -272,19 +272,19 @@ impl crate::Loggable for TranslationAndMat3x3 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "translation".to_owned(), @@ -321,10 +321,12 @@ impl crate::Loggable for TranslationAndMat3x3 { .collect(); let translation = { if !arrays_by_name.contains_key("translation") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "translation", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "translation", + ), + ) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["translation"]; @@ -333,7 +335,7 @@ impl crate::Loggable for TranslationAndMat3x3 { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -358,12 +360,10 @@ impl crate::Loggable for TranslationAndMat3x3 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) .with_context( "rerun.datatypes.TranslationAndMat3x3#translation", )? @@ -372,45 +372,56 @@ impl crate::Loggable for TranslationAndMat3x3 { .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let mat3x3 = { if !arrays_by_name.contains_key("mat3x3") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "mat3x3", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "mat3x3", + ), + ) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["mat3x3"]; @@ -419,7 +430,7 @@ impl crate::Loggable for TranslationAndMat3x3 { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -444,57 +455,68 @@ impl crate::Loggable for TranslationAndMat3x3 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - ) - }) - .with_context("rerun.datatypes.TranslationAndMat3x3#mat3x3")? + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + )) + .with_context( + "rerun.datatypes.TranslationAndMat3x3#mat3x3", + )? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 9usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 9usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Mat3x3(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Mat3x3(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let from_parent = { if !arrays_by_name.contains_key("from_parent") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "from_parent", + ), + ) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["from_parent"]; @@ -502,7 +524,7 @@ impl crate::Loggable for TranslationAndMat3x3 { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) @@ -520,13 +542,13 @@ impl crate::Loggable for TranslationAndMat3x3 { translation, mat3x3, from_parent: from_parent - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context("rerun.datatypes.TranslationAndMat3x3#from_parent")?, }) }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.TranslationAndMat3x3")? } }) diff --git a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs index 9487ebb99fd8..02b71db07d38 100644 --- a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs +++ b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs @@ -49,8 +49,8 @@ impl<'a> From<&'a TranslationRotationScale3D> } } -impl crate::Loggable for TranslationRotationScale3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for TranslationRotationScale3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -92,13 +92,13 @@ impl crate::Loggable for TranslationRotationScale3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data): (Vec<_>, Vec<_>) = data .into_iter() @@ -261,19 +261,19 @@ impl crate::Loggable for TranslationRotationScale3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::StructArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Struct(vec![ Field { name: "translation".to_owned(), @@ -316,10 +316,12 @@ impl crate::Loggable for TranslationRotationScale3D { .collect(); let translation = { if !arrays_by_name.contains_key("translation") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "translation", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "translation", + ), + ) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["translation"]; @@ -328,7 +330,7 @@ impl crate::Loggable for TranslationRotationScale3D { .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -350,13 +352,12 @@ impl crate::Loggable for TranslationRotationScale3D { let offsets = (0..) .step_by(3usize) .zip((3usize..).step_by(3usize).take(arrow_data.len())); - let arrow_data_inner = - { - let arrow_data_inner = &**arrow_data.values(); - arrow_data_inner + let arrow_data_inner = { + let arrow_data_inner = &**arrow_data.values(); + arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| crate::DeserializationError::datatype_mismatch( + .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), )) @@ -366,47 +367,58 @@ impl crate::Loggable for TranslationRotationScale3D { .into_iter() .map(|opt| opt.copied()) .collect::>() - }; + }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem + .map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) + }) + .transpose() }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + .map(|res_or_opt| { + res_or_opt + .map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) }) - }) - .collect::>>>()? + .collect::< + ::re_types_core::DeserializationResult>>, + >()? } - .into_iter() + .into_iter() } }; let rotation = { if !arrays_by_name.contains_key("rotation") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "rotation", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "rotation", + ), + ) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["rotation"]; @@ -416,10 +428,12 @@ impl crate::Loggable for TranslationRotationScale3D { }; let scale = { if !arrays_by_name.contains_key("scale") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "scale", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "scale", + ), + ) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["scale"]; @@ -429,10 +443,12 @@ impl crate::Loggable for TranslationRotationScale3D { }; let from_parent = { if !arrays_by_name.contains_key("from_parent") { - return Err(crate::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - )) + return Err( + ::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "from_parent", + ), + ) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["from_parent"]; @@ -440,7 +456,7 @@ impl crate::Loggable for TranslationRotationScale3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Boolean, arrow_data.data_type().clone(), ) @@ -459,7 +475,7 @@ impl crate::Loggable for TranslationRotationScale3D { rotation, scale, from_parent: from_parent - .ok_or_else(crate::DeserializationError::missing_data) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context( "rerun.datatypes.TranslationRotationScale3D#from_parent", )?, @@ -467,7 +483,7 @@ impl crate::Loggable for TranslationRotationScale3D { }) .transpose() }) - .collect::>>() + .collect::<::re_types_core::DeserializationResult>>() .with_context("rerun.datatypes.TranslationRotationScale3D")? } }) diff --git a/crates/re_types/src/datatypes/utf8.rs b/crates/re_types/src/datatypes/utf8.rs index 78e87c8ded70..5ff18358af4d 100644 --- a/crates/re_types/src/datatypes/utf8.rs +++ b/crates/re_types/src/datatypes/utf8.rs @@ -17,16 +17,16 @@ /// **Datatype**: A string of text, encoded as UTF-8. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] -pub struct Utf8(pub crate::ArrowString); +pub struct Utf8(pub ::re_types_core::ArrowString); -impl From for Utf8 { +impl From<::re_types_core::ArrowString> for Utf8 { #[inline] - fn from(value: crate::ArrowString) -> Self { + fn from(value: ::re_types_core::ArrowString) -> Self { Self(value) } } -impl From for crate::ArrowString { +impl From for ::re_types_core::ArrowString { #[inline] fn from(value: Utf8) -> Self { value.0 @@ -47,8 +47,8 @@ impl<'a> From<&'a Utf8> for ::std::borrow::Cow<'a, Utf8> { } } -impl crate::Loggable for Utf8 { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Utf8 { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -65,13 +65,13 @@ impl crate::Loggable for Utf8 { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -116,19 +116,19 @@ impl crate::Loggable for Utf8 { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::Utf8Array>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Utf8, arrow_data.data_type().clone(), ) @@ -145,7 +145,7 @@ impl crate::Loggable for Utf8 { let start = *start as usize; let end = start + len; if end as usize > arrow_data_buf.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_buf.len(), )); @@ -158,15 +158,15 @@ impl crate::Loggable for Utf8 { .transpose() }) .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::ArrowString(v))) + res_or_opt.map(|res_or_opt| res_or_opt.map(|v| ::re_types_core::ArrowString(v))) }) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Utf8#value")? .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Utf8#value") .with_context("rerun.datatypes.Utf8")?) } diff --git a/crates/re_types/src/datatypes/uvec2d.rs b/crates/re_types/src/datatypes/uvec2d.rs index 077f9d410feb..b8bb1ddb5ba1 100644 --- a/crates/re_types/src/datatypes/uvec2d.rs +++ b/crates/re_types/src/datatypes/uvec2d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a UVec2D> for ::std::borrow::Cow<'a, UVec2D> { } } -impl crate::Loggable for UVec2D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for UVec2D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for UVec2D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for UVec2D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for UVec2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for UVec2D { elem.map(|(start, end)| { debug_assert!(end - start == 2usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for UVec2D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.UVec2D#xy") .with_context("rerun.datatypes.UVec2D")?) } diff --git a/crates/re_types/src/datatypes/uvec3d.rs b/crates/re_types/src/datatypes/uvec3d.rs index b67c8f29509c..fe6e21503c35 100644 --- a/crates/re_types/src/datatypes/uvec3d.rs +++ b/crates/re_types/src/datatypes/uvec3d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a UVec3D> for ::std::borrow::Cow<'a, UVec3D> { } } -impl crate::Loggable for UVec3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for UVec3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for UVec3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for UVec3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for UVec3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for UVec3D { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for UVec3D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.UVec3D#xyz") .with_context("rerun.datatypes.UVec3D")?) } diff --git a/crates/re_types/src/datatypes/uvec4d.rs b/crates/re_types/src/datatypes/uvec4d.rs index 99b2b2cf7442..47053702f0fd 100644 --- a/crates/re_types/src/datatypes/uvec4d.rs +++ b/crates/re_types/src/datatypes/uvec4d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a UVec4D> for ::std::borrow::Cow<'a, UVec4D> { } } -impl crate::Loggable for UVec4D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for UVec4D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for UVec4D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for UVec4D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for UVec4D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::UInt32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for UVec4D { elem.map(|(start, end)| { debug_assert!(end - start == 4usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for UVec4D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.UVec4D#xyzw") .with_context("rerun.datatypes.UVec4D")?) } diff --git a/crates/re_types/src/datatypes/vec2d.rs b/crates/re_types/src/datatypes/vec2d.rs index b9acd02781df..9886313e67fc 100644 --- a/crates/re_types/src/datatypes/vec2d.rs +++ b/crates/re_types/src/datatypes/vec2d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a Vec2D> for ::std::borrow::Cow<'a, Vec2D> { } } -impl crate::Loggable for Vec2D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Vec2D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for Vec2D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for Vec2D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for Vec2D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for Vec2D { elem.map(|(start, end)| { debug_assert!(end - start == 2usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for Vec2D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Vec2D#xy") .with_context("rerun.datatypes.Vec2D")?) } diff --git a/crates/re_types/src/datatypes/vec3d.rs b/crates/re_types/src/datatypes/vec3d.rs index 22ad16bf6b3d..65215af189b6 100644 --- a/crates/re_types/src/datatypes/vec3d.rs +++ b/crates/re_types/src/datatypes/vec3d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a Vec3D> for ::std::borrow::Cow<'a, Vec3D> { } } -impl crate::Loggable for Vec3D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Vec3D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for Vec3D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for Vec3D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for Vec3D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for Vec3D { elem.map(|(start, end)| { debug_assert!(end - start == 3usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for Vec3D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Vec3D#xyz") .with_context("rerun.datatypes.Vec3D")?) } diff --git a/crates/re_types/src/datatypes/vec4d.rs b/crates/re_types/src/datatypes/vec4d.rs index b13e08b361fd..50844b27c287 100644 --- a/crates/re_types/src/datatypes/vec4d.rs +++ b/crates/re_types/src/datatypes/vec4d.rs @@ -47,8 +47,8 @@ impl<'a> From<&'a Vec4D> for ::std::borrow::Cow<'a, Vec4D> { } } -impl crate::Loggable for Vec4D { - type Name = crate::DatatypeName; +impl ::re_types_core::Loggable for Vec4D { + type Name = ::re_types_core::DatatypeName; #[inline] fn name() -> Self::Name { @@ -73,13 +73,13 @@ impl crate::Loggable for Vec4D { #[allow(unused_imports, clippy::wildcard_imports)] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> crate::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data .into_iter() @@ -135,19 +135,19 @@ impl crate::Loggable for Vec4D { #[allow(unused_imports, clippy::wildcard_imports)] fn from_arrow_opt( arrow_data: &dyn ::arrow2::array::Array, - ) -> crate::DeserializationResult>> + ) -> ::re_types_core::DeserializationResult>> where Self: Sized, { re_tracing::profile_function!(); - use crate::{Loggable as _, ResultExt as _}; use ::arrow2::{array::*, buffer::*, datatypes::*}; + use ::re_types_core::{Loggable as _, ResultExt as _}; Ok({ let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -173,7 +173,7 @@ impl crate::Loggable for Vec4D { .as_any() .downcast_ref::() .ok_or_else(|| { - crate::DeserializationError::datatype_mismatch( + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner.data_type().clone(), ) @@ -191,7 +191,7 @@ impl crate::Loggable for Vec4D { elem.map(|(start, end)| { debug_assert!(end - start == 4usize); if end as usize > arrow_data_inner.len() { - return Err(crate::DeserializationError::offset_slice_oob( + return Err(::re_types_core::DeserializationError::offset_slice_oob( (start, end), arrow_data_inner.len(), )); @@ -206,13 +206,13 @@ impl crate::Loggable for Vec4D { }) .transpose() }) - .collect::>>>()? + .collect::<::re_types_core::DeserializationResult>>>()? } .into_iter() } - .map(|v| v.ok_or_else(crate::DeserializationError::missing_data)) + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) .map(|res| res.map(|v| Some(Self(v)))) - .collect::>>>() + .collect::<::re_types_core::DeserializationResult>>>() .with_context("rerun.datatypes.Vec4D#xyzw") .with_context("rerun.datatypes.Vec4D")?) } diff --git a/crates/re_types/src/lib.rs b/crates/re_types/src/lib.rs index 2b825559be63..20266762c6b5 100644 --- a/crates/re_types/src/lib.rs +++ b/crates/re_types/src/lib.rs @@ -3,17 +3,6 @@ //! This crate contains both the IDL definitions for Rerun types (flatbuffers) as well as the code //! generated from those using `re_types_builder`. //! -//! The [`Archetype`] trait is the core of this crate and is a good starting point to get familiar -//! with the code. -//! An archetype is a logical collection of [`Component`]s that play well with each other. -//! -//! Rerun (and the underlying Arrow data framework) is designed to work with large arrays of -//! [`Component`]s, as opposed to single instances. -//! When multiple instances of a [`Component`] are put together in an array, they yield a -//! [`ComponentBatch`]: the atomic unit of (de)serialization. -//! -//! Internally, [`Component`]s are implemented using many different [`Datatype`]s. -//! //! All builtin archetypes, components and datatypes can be found in their respective top-level //! modules. //! @@ -184,76 +173,6 @@ // --- -/// Describes the interface for interpreting an object as a bundle of [`Component`]s. -/// -/// ## Custom bundles -/// -/// While, in most cases, component bundles are code generated from our [IDL definitions], -/// it is possible to manually extend existing bundles, or even implement fully custom ones. -/// -/// All [`AsComponents`] methods are optional to implement, with the exception of -/// [`AsComponents::as_component_batches`], which describes how the bundle can be interpreted -/// as a set of [`ComponentBatch`]es: arrays of components that are ready to be serialized. -/// -/// Have a look at our [Custom Data] example to learn more about handwritten bundles. -/// -/// [IDL definitions]: https://github.com/rerun-io/rerun/tree/latest/crates/re_types/definitions/rerun -/// [Custom Data]: https://github.com/rerun-io/rerun/blob/latest/examples/rust/custom_data/src/main.rs -pub trait AsComponents { - /// Exposes the object's contents as a set of [`ComponentBatch`]s. - /// - /// This is the main mechanism for easily extending builtin archetypes or even writing - /// fully custom ones. - /// Have a look at our [Custom Data] example to learn more about extending archetypes. - /// - /// [Custom Data]: https://github.com/rerun-io/rerun/blob/latest/examples/rust/custom_data/src/main.rs - // - // NOTE: Don't bother returning a CoW here: we need to dynamically discard optional components - // depending on their presence (or lack thereof) at runtime anyway. - fn as_component_batches(&self) -> Vec>; - - /// The number of instances in each batch. - /// - /// If not implemented, the number of instances will be determined by the longest - /// batch in the bundle. - /// - /// Each batch returned by `as_component_batches` should have this number of elements, - /// or 1 in the case it is a splat, or 0 in the case that component is being cleared. - #[inline] - fn num_instances(&self) -> usize { - self.as_component_batches() - .into_iter() - .map(|comp_batch| comp_batch.as_ref().num_instances()) - .max() - .unwrap_or(0) - } - - // --- - - /// Serializes all non-null [`Component`]s of this bundle into Arrow arrays. - /// - /// The default implementation will simply serialize the result of [`Self::as_component_batches`] - /// as-is, which is what you want in 99.9% of cases. - #[inline] - fn to_arrow( - &self, - ) -> SerializationResult)>> - { - self.as_component_batches() - .into_iter() - .map(|comp_batch| { - comp_batch - .as_ref() - .to_arrow() - .map(|array| (comp_batch.as_ref().arrow_field(), array)) - .with_context(comp_batch.as_ref().name()) - }) - .collect() - } -} - -// --- - /// Number of decimals shown for all vector display methods. pub const DISPLAY_PRECISION: usize = 3; @@ -294,38 +213,22 @@ pub mod datatypes; /// Unstable. Used for the ongoing blueprint experimentations. pub mod blueprint; -mod archetype; -mod loggable; -mod loggable_batch; -mod result; -mod size_bytes; - -pub use self::archetype::{ - Archetype, ArchetypeName, GenericIndicatorComponent, NamedIndicatorComponent, -}; -pub use self::loggable::{ - Component, ComponentName, ComponentNameSet, Datatype, DatatypeName, Loggable, -}; -pub use self::loggable_batch::{ - ComponentBatch, DatatypeBatch, LoggableBatch, MaybeOwnedComponentBatch, -}; -pub use self::result::{ - DeserializationError, DeserializationResult, ResultExt, SerializationError, - SerializationResult, _Backtrace, -}; -pub use self::size_bytes::SizeBytes; - #[cfg(feature = "datagen")] pub mod datagen; // --- -mod arrow_buffer; -mod arrow_string; -pub use self::arrow_buffer::ArrowBuffer; -pub use self::arrow_string::ArrowString; +// One almost never uses `re_types` without `re_types_core`, so we reexport these core types +// for convenience. +// The opposite is not true, though: make sure you're not depending on `re_types` if all you need +// in `re_types_core` in order to prevent some nasty dep cycles! +pub use re_types_core::*; + +// --- pub mod external { + pub use re_types_core; + pub use anyhow; pub use arrow2; pub use uuid; diff --git a/crates/re_types/src/loggable.rs b/crates/re_types/src/loggable.rs deleted file mode 100644 index 43531766787d..000000000000 --- a/crates/re_types/src/loggable.rs +++ /dev/null @@ -1,245 +0,0 @@ -use crate::{result::_Backtrace, DeserializationResult, ResultExt as _, SerializationResult}; - -#[allow(unused_imports)] // used in docstrings -use crate::{Archetype, ComponentBatch, DatatypeBatch, LoggableBatch}; - -// --- - -/// A [`Loggable`] represents a single instance in an array of loggable data. -/// -/// Internally, Arrow, and by extension Rerun, only deal with arrays of data. -/// We refer to individual entries in these arrays as instances. -/// -/// [`Datatype`] and [`Component`] are specialization of the [`Loggable`] trait that are -/// automatically implemented based on the type used for [`Loggable::Name`]. -/// -/// Implementing the [`Loggable`] trait (and by extension [`Datatype`]/[`Component`]) -/// automatically derives the [`LoggableBatch`] implementation (and by extension -/// [`DatatypeBatch`]/[`ComponentBatch`]), which makes it possible to work with lists' worth of data -/// in a generic fashion. -pub trait Loggable: Clone + Sized { - type Name: std::fmt::Display; - - /// The fully-qualified name of this loggable, e.g. `rerun.datatypes.Vec2D`. - fn name() -> Self::Name; - - /// The underlying [`arrow2::datatypes::DataType`], excluding datatype extensions. - fn arrow_datatype() -> arrow2::datatypes::DataType; - - /// Given an iterator of options of owned or reference values to the current - /// [`Loggable`], serializes them into an Arrow array. - /// The Arrow array's datatype will match [`Loggable::arrow_field`]. - /// - /// When using Rerun's builtin components & datatypes, this can only fail if the data - /// exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, - /// 2^63 for large arrays). - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: 'a; - - // --- Optional metadata methods --- - - /// The underlying [`arrow2::datatypes::DataType`], including datatype extensions. - /// - /// The default implementation will simply wrap [`Self::arrow_datatype`] in an extension called - /// [`Self::name`], which is what you want in most cases. - #[inline] - fn extended_arrow_datatype() -> arrow2::datatypes::DataType { - arrow2::datatypes::DataType::Extension( - Self::name().to_string(), - Box::new(Self::arrow_datatype()), - None, - ) - } - - /// The underlying [`arrow2::datatypes::Field`], including datatype extensions. - /// - /// The default implementation will simply wrap [`Self::extended_arrow_datatype`] in a - /// [`arrow2::datatypes::Field`], which is what you want in most cases (e.g. because you want - /// to declare the field as nullable). - #[inline] - fn arrow_field() -> arrow2::datatypes::Field { - arrow2::datatypes::Field::new( - Self::name().to_string(), - Self::extended_arrow_datatype(), - false, - ) - } - - // --- Optional serialization methods --- - - /// Given an iterator of owned or reference values to the current [`Loggable`], serializes - /// them into an Arrow array. - /// The Arrow array's datatype will match [`Loggable::arrow_field`]. - /// - /// When using Rerun's builtin components & datatypes, this can only fail if the data - /// exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, - /// 2^63 for large arrays). - #[inline] - fn to_arrow<'a>( - data: impl IntoIterator>>, - ) -> SerializationResult> - where - Self: 'a, - { - re_tracing::profile_function!(); - Self::to_arrow_opt(data.into_iter().map(Some)) - } - - // --- Optional deserialization methods --- - - /// Given an Arrow array, deserializes it into a collection of [`Loggable`]s. - /// - /// This will _never_ fail if the Arrow array's datatype matches the one returned by - /// [`Loggable::arrow_field`]. - #[inline] - fn from_arrow(data: &dyn ::arrow2::array::Array) -> DeserializationResult> { - re_tracing::profile_function!(); - Self::from_arrow_opt(data)? - .into_iter() - .map(|opt| { - opt.ok_or_else(|| crate::DeserializationError::MissingData { - backtrace: _Backtrace::new_unresolved(), - }) - }) - .collect::>>() - .with_context(Self::name().to_string()) - } - - /// Given an Arrow array, deserializes it into a collection of optional [`Loggable`]s. - /// - /// This will _never_ fail if the Arrow array's datatype matches the one returned by - /// [`Loggable::arrow_field`]. - fn from_arrow_opt( - data: &dyn ::arrow2::array::Array, - ) -> DeserializationResult>> { - _ = data; // NOTE: do this here to avoid breaking users' autocomplete snippets - Err(crate::DeserializationError::NotImplemented { - fqname: Self::name().to_string(), - backtrace: _Backtrace::new_unresolved(), - }) - } -} - -/// A [`Datatype`] describes plain old data that can be used by any number of [`Component`]s. -/// -/// Any [`Loggable`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically implements -/// [`Datatype`]. -pub trait Datatype: Loggable {} - -impl> Datatype for L {} - -/// A [`Component`] describes semantic data that can be used by any number of [`Archetype`]s. -/// -/// Any [`Loggable`] with a [`Loggable::Name`] set to [`ComponentName`] automatically implements -/// [`Component`]. -pub trait Component: Loggable {} - -impl> Component for L {} - -// --- - -pub type ComponentNameSet = std::collections::BTreeSet; - -re_string_interner::declare_new_type!( - /// The fully-qualified name of a [`Component`], e.g. `rerun.components.Position2D`. - pub struct ComponentName; -); - -impl ComponentName { - /// Returns the fully-qualified name, e.g. `rerun.components.Position2D`. - /// - /// This is the default `Display` implementation for [`ComponentName`]. - #[inline] - pub fn full_name(&self) -> &'static str { - self.0.as_str() - } - - /// Returns the unqualified name, e.g. `Position2D`. - /// - /// Used for most UI elements. - /// - /// ``` - /// # use re_types::ComponentName; - /// assert_eq!(ComponentName::from("rerun.components.Position2D").short_name(), "Position2D"); - /// ``` - #[inline] - pub fn short_name(&self) -> &'static str { - let full_name = self.0.as_str(); - if let Some(short_name) = full_name.strip_prefix("rerun.components.") { - short_name - } else if let Some(short_name) = full_name.strip_prefix("rerun.") { - short_name - } else { - full_name - } - } - - /// Is this an indicator component for an archetype? - pub fn is_indicator_component(&self) -> bool { - self.starts_with("rerun.components.") && self.ends_with("Indicator") - } - - /// If this is an indicator component, for which archetype? - pub fn indicator_component_archetype(&self) -> Option { - if let Some(name) = self.strip_prefix("rerun.components.") { - if let Some(name) = name.strip_suffix("Indicator") { - return Some(name.to_owned()); - } - } - None - } -} - -// --- - -impl crate::SizeBytes for ComponentName { - #[inline] - fn heap_size_bytes(&self) -> u64 { - 0 - } -} - -re_string_interner::declare_new_type!( - /// The fully-qualified name of a [`Datatype`], e.g. `rerun.datatypes.Vec2D`. - pub struct DatatypeName; -); - -impl DatatypeName { - /// Returns the fully-qualified name, e.g. `rerun.datatypes.Vec2D`. - /// - /// This is the default `Display` implementation for [`DatatypeName`]. - #[inline] - pub fn full_name(&self) -> &'static str { - self.0.as_str() - } - - /// Returns the unqualified name, e.g. `Vec2D`. - /// - /// Used for most UI elements. - /// - /// ``` - /// # use re_types::DatatypeName; - /// assert_eq!(DatatypeName::from("rerun.datatypes.Vec2D").short_name(), "Vec2D"); - /// ``` - #[inline] - pub fn short_name(&self) -> &'static str { - let full_name = self.0.as_str(); - if let Some(short_name) = full_name.strip_prefix("rerun.datatypes.") { - short_name - } else if let Some(short_name) = full_name.strip_prefix("rerun.") { - short_name - } else { - full_name - } - } -} - -impl crate::SizeBytes for DatatypeName { - #[inline] - fn heap_size_bytes(&self) -> u64 { - 0 - } -} diff --git a/crates/re_types/src/loggable_batch.rs b/crates/re_types/src/loggable_batch.rs deleted file mode 100644 index 9708e25e1f97..000000000000 --- a/crates/re_types/src/loggable_batch.rs +++ /dev/null @@ -1,372 +0,0 @@ -use crate::{Component, ComponentName, Datatype, DatatypeName, Loggable, SerializationResult}; - -#[allow(unused_imports)] // used in docstrings -use crate::Archetype; - -// --- - -/// A [`LoggableBatch`] represents an array's worth of [`Loggable`] instances, ready to be -/// serialized. -/// -/// [`LoggableBatch`] is carefully designed to be erasable ("object-safe"), so that it is possible -/// to build heterogeneous collections of [`LoggableBatch`]s (e.g. `Vec`). -/// This erasability is what makes extending [`Archetype`]s possible with little effort. -/// -/// You should almost never need to implement [`LoggableBatch`] manually, as it is already -/// blanket implemented for most common use cases (arrays/vectors/slices of loggables, etc). -pub trait LoggableBatch { - type Name; - - // NOTE: It'd be tempting to have the following associated type, but that'd be - // counterproductive, the whole point of this is to allow for heterogeneous collections! - // type Loggable: Loggable; - - /// The fully-qualified name of this batch, e.g. `rerun.datatypes.Vec2D`. - fn name(&self) -> Self::Name; - - /// The number of component instances stored into this batch. - fn num_instances(&self) -> usize; - - /// The underlying [`arrow2::datatypes::Field`], including datatype extensions. - fn arrow_field(&self) -> arrow2::datatypes::Field; - - /// Serializes the batch into an Arrow array. - fn to_arrow(&self) -> SerializationResult>; -} - -/// A [`DatatypeBatch`] represents an array's worth of [`Datatype`] instances. -/// -/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically -/// implements [`DatatypeBatch`]. -pub trait DatatypeBatch: LoggableBatch {} - -/// A [`ComponentBatch`] represents an array's worth of [`Component`] instances. -/// -/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`ComponentName`] automatically -/// implements [`ComponentBatch`]. -pub trait ComponentBatch: LoggableBatch {} - -/// Holds either an owned [`ComponentBatch`] that lives on heap, or a reference to one. -/// -/// This doesn't use [`std::borrow::Cow`] on purpose: `Cow` requires `Clone`, which would break -/// object-safety, which would prevent us from erasing [`ComponentBatch`]s in the first place. -pub enum MaybeOwnedComponentBatch<'a> { - Owned(Box), - Ref(&'a dyn ComponentBatch), -} - -impl<'a> From<&'a dyn ComponentBatch> for MaybeOwnedComponentBatch<'a> { - #[inline] - fn from(comp_batch: &'a dyn ComponentBatch) -> Self { - Self::Ref(comp_batch) - } -} - -impl From> for MaybeOwnedComponentBatch<'_> { - #[inline] - fn from(comp_batch: Box) -> Self { - Self::Owned(comp_batch) - } -} - -impl<'a> AsRef for MaybeOwnedComponentBatch<'a> { - fn as_ref(&self) -> &(dyn ComponentBatch + 'a) { - match self { - MaybeOwnedComponentBatch::Owned(this) => &**this, - MaybeOwnedComponentBatch::Ref(this) => *this, - } - } -} - -impl<'a> std::ops::Deref for MaybeOwnedComponentBatch<'a> { - type Target = dyn ComponentBatch + 'a; - - fn deref(&self) -> &(dyn ComponentBatch + 'a) { - match self { - MaybeOwnedComponentBatch::Owned(this) => &**this, - MaybeOwnedComponentBatch::Ref(this) => *this, - } - } -} - -// --- Unary --- - -impl LoggableBatch for L { - type Name = L::Name; - - #[inline] - fn name(&self) -> Self::Name { - L::name() - } - - #[inline] - fn num_instances(&self) -> usize { - 1 - } - - #[inline] - fn arrow_field(&self) -> arrow2::datatypes::Field { - L::arrow_field() - } - - #[inline] - fn to_arrow(&self) -> SerializationResult> { - L::to_arrow([std::borrow::Cow::Borrowed(self)]) - } -} - -impl DatatypeBatch for D {} - -impl ComponentBatch for C {} - -// --- Vec --- - -impl LoggableBatch for Vec { - type Name = L::Name; - - #[inline] - fn name(&self) -> Self::Name { - L::name() - } - - #[inline] - fn num_instances(&self) -> usize { - self.len() - } - - #[inline] - fn arrow_field(&self) -> arrow2::datatypes::Field { - L::arrow_field() - } - - #[inline] - fn to_arrow(&self) -> SerializationResult> { - L::to_arrow(self.iter().map(|v| std::borrow::Cow::Borrowed(v))) - } -} - -impl DatatypeBatch for Vec {} - -impl ComponentBatch for Vec {} - -// --- Vec { .next() .ok_or_else(|| DeserializationError::MissingComponent { component: C::name(), - backtrace: re_types::_Backtrace::new_unresolved(), + backtrace: re_types_core::_Backtrace::new_unresolved(), })?; let count = 1 + iter.count(); if count != 1 { diff --git a/crates/re_query/src/dataframe_util.rs b/crates/re_query/src/dataframe_util.rs index dd1d32e650ab..1c0249fb8c30 100644 --- a/crates/re_query/src/dataframe_util.rs +++ b/crates/re_query/src/dataframe_util.rs @@ -4,7 +4,8 @@ use arrow2::{ }; use polars_core::prelude::*; use re_arrow_store::ArrayExt; -use re_types::{components::InstanceKey, Archetype, Component, Loggable}; +use re_types_core::{Archetype, Component, Loggable}; +use re_types::components::InstanceKey; use crate::{ArchetypeView, ComponentWithInstances, QueryError}; @@ -58,7 +59,7 @@ pub fn iter_column<'a, C: Component + 'a>( pub fn df_builder1<'a, C0>(c0: &'a [Option]) -> crate::Result where - C0: re_types::Component + Clone + 'a, + C0: re_types_core::Component + Clone + 'a, &'a C0: Into<::std::borrow::Cow<'a, C0>>, { let array0 = C0::to_arrow_opt(c0.iter().map(|c| c.as_ref()))?; @@ -73,8 +74,8 @@ pub fn df_builder2<'a, C0, C1>( c1: &'a [Option], ) -> crate::Result where - C0: re_types::Component + Clone + 'a, - C1: re_types::Component + Clone + 'a, + C0: re_types_core::Component + Clone + 'a, + C1: re_types_core::Component + Clone + 'a, &'a C0: Into<::std::borrow::Cow<'a, C0>>, &'a C1: Into<::std::borrow::Cow<'a, C1>>, { @@ -93,9 +94,9 @@ pub fn df_builder3<'a, C0, C1, C2>( c2: &'a [Option], ) -> crate::Result where - C0: re_types::Component + Clone + 'a, - C1: re_types::Component + Clone + 'a, - C2: re_types::Component + Clone + 'a, + C0: re_types_core::Component + Clone + 'a, + C1: re_types_core::Component + Clone + 'a, + C2: re_types_core::Component + Clone + 'a, &'a C0: Into<::std::borrow::Cow<'a, C0>>, &'a C1: Into<::std::borrow::Cow<'a, C1>>, &'a C2: Into<::std::borrow::Cow<'a, C2>>, @@ -134,7 +135,10 @@ impl ComponentWithInstances { } impl ArchetypeView { - pub fn as_df1<'a, C1: re_types::Component + Clone + Into<::std::borrow::Cow<'a, C1>> + 'a>( + pub fn as_df1< + 'a, + C1: re_types_core::Component + Clone + Into<::std::borrow::Cow<'a, C1>> + 'a, + >( &self, ) -> crate::Result { let array0 = InstanceKey::to_arrow(self.iter_instance_keys())?; @@ -151,8 +155,8 @@ impl ArchetypeView { pub fn as_df2< 'a, - C1: re_types::Component + Clone + Into<::std::borrow::Cow<'a, C1>> + 'a, - C2: re_types::Component + Clone + Into<::std::borrow::Cow<'a, C2>> + 'a, + C1: re_types_core::Component + Clone + Into<::std::borrow::Cow<'a, C1>> + 'a, + C2: re_types_core::Component + Clone + Into<::std::borrow::Cow<'a, C2>> + 'a, >( &self, ) -> crate::Result { diff --git a/crates/re_query/src/lib.rs b/crates/re_query/src/lib.rs index 00c0c5dfeb3f..c13392bb41dc 100644 --- a/crates/re_query/src/lib.rs +++ b/crates/re_query/src/lib.rs @@ -29,28 +29,28 @@ pub enum QueryError { BadAccess, #[error("Could not find primary component: {0}")] - PrimaryNotFound(re_types::ComponentName), + PrimaryNotFound(re_types_core::ComponentName), #[error("Could not find required component: {0}")] - RequiredComponentNotFound(re_log_types::ComponentName), + RequiredComponentNotFound(re_types_core::ComponentName), #[error("Could not find component")] ComponentNotFound, #[error("Tried to access component of type '{actual:?}' using component '{requested:?}'")] TypeMismatch { - actual: re_types::ComponentName, - requested: re_types::ComponentName, + actual: re_types_core::ComponentName, + requested: re_types_core::ComponentName, }, #[error("Error with one or more the underlying data cells: {0}")] DataCell(#[from] re_log_types::DataCellError), #[error("Error deserializing: {0}")] - DeserializationError(#[from] re_types::DeserializationError), + DeserializationError(#[from] re_types_core::DeserializationError), #[error("Error serializing: {0}")] - SerializationError(#[from] re_types::SerializationError), + SerializationError(#[from] re_types_core::SerializationError), #[error("Error converting arrow data: {0}")] ArrowError(#[from] arrow2::error::Error), diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 441e32805dc6..73b7df8e4452 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -1,6 +1,7 @@ use re_arrow_store::{DataStore, LatestAtQuery}; use re_log_types::{DataRow, EntityPath, RowId}; -use re_types::{components::InstanceKey, Archetype, ComponentName, Loggable}; +use re_types_core::{Archetype, ComponentName, Loggable}; +use re_types::components::InstanceKey; use crate::{ArchetypeView, ComponentWithInstances, QueryError}; @@ -76,7 +77,7 @@ pub fn get_component_with_instances( /// ``` /// # use re_arrow_store::LatestAtQuery; /// # use re_log_types::Timeline; -/// # use re_types::Component; +/// # use re_types_core::Component; /// # use re_types::components::{Position2D, Color}; /// # use re_types::archetypes::Points2D; /// # let store = re_query::__populate_example_store(); diff --git a/crates/re_query/src/range.rs b/crates/re_query/src/range.rs index 8e098e7fa8ec..859528e4b943 100644 --- a/crates/re_query/src/range.rs +++ b/crates/re_query/src/range.rs @@ -1,7 +1,7 @@ use itertools::Itertools as _; use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery, TimeInt}; use re_log_types::EntityPath; -use re_types::{Archetype, ComponentName}; +use re_types_core::{Archetype, ComponentName}; use crate::{get_component_with_instances, ArchetypeView, ComponentWithInstances}; diff --git a/crates/re_query/src/util.rs b/crates/re_query/src/util.rs index 350f0a87c4ce..1d1da7a755c8 100644 --- a/crates/re_query/src/util.rs +++ b/crates/re_query/src/util.rs @@ -1,7 +1,7 @@ use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery, TimeInt, TimeRange, Timeline}; use re_data_store::ExtraQueryHistory; use re_log_types::EntityPath; -use re_types::Archetype; +use re_types_core::Archetype; use crate::{query_archetype, range::range_archetype, ArchetypeView}; diff --git a/crates/re_query/tests/archetype_query_tests.rs b/crates/re_query/tests/archetype_query_tests.rs index f2e6ba7a9629..071da99306f6 100644 --- a/crates/re_query/tests/archetype_query_tests.rs +++ b/crates/re_query/tests/archetype_query_tests.rs @@ -3,10 +3,10 @@ mod common; use re_arrow_store::DataStore; use re_log_types::{build_frame_nr, DataRow, RowId}; use re_query::query_archetype; +use re_types_core::Loggable as _; use re_types::{ archetypes::Points2D, components::{Color, InstanceKey, Position2D}, - Loggable, }; #[test] diff --git a/crates/re_query/tests/archetype_range_tests.rs b/crates/re_query/tests/archetype_range_tests.rs index ed7195a61dcd..65be8e347074 100644 --- a/crates/re_query/tests/archetype_range_tests.rs +++ b/crates/re_query/tests/archetype_range_tests.rs @@ -3,10 +3,10 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; use re_log_types::{build_frame_nr, DataRow, EntityPath, RowId}; use re_query::range_archetype; +use re_types_core::Loggable as _; use re_types::{ archetypes::Points2D, components::{Color, InstanceKey, Position2D}, - Loggable as _, }; #[test] From 6639240372abc2ba82e615068fbced7dde67d02e Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 17:59:03 +0200 Subject: [PATCH 06/13] re_sdk: expose from re_types_core directly for the sake of explicitness --- crates/re_sdk/Cargo.toml | 1 + crates/re_sdk/src/lib.rs | 10 +++++----- crates/re_sdk/src/recording_stream.rs | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/re_sdk/Cargo.toml b/crates/re_sdk/Cargo.toml index e17820fca6bd..b8f9d5765585 100644 --- a/crates/re_sdk/Cargo.toml +++ b/crates/re_sdk/Cargo.toml @@ -61,6 +61,7 @@ re_log_types.workspace = true re_log.workspace = true re_memory.workspace = true re_sdk_comms = { workspace = true, features = ["client"] } +re_types_core.workspace = true re_types = { workspace = true, features = ["ecolor", "glam"] } ahash.workspace = true diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index c5bfafe827b7..afa2dab455ad 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -90,12 +90,12 @@ pub mod coordinates { pub use re_types::view_coordinates::{Axis3, Handedness, Sign, SignedAxis3}; } -pub use re_types::{ - archetypes, components, datatypes, Archetype, ArchetypeName, AsComponents, Component, - ComponentBatch, ComponentName, Datatype, DatatypeBatch, DatatypeName, - GenericIndicatorComponent, Loggable, LoggableBatch, MaybeOwnedComponentBatch, - NamedIndicatorComponent, +pub use re_types_core::{ + Archetype, ArchetypeName, AsComponents, Component, ComponentBatch, ComponentName, Datatype, + DatatypeBatch, DatatypeName, GenericIndicatorComponent, Loggable, LoggableBatch, + MaybeOwnedComponentBatch, NamedIndicatorComponent, }; +pub use re_types::{archetypes, components, datatypes}; mod prelude { // Import all archetypes into the global namespace to minimize diff --git a/crates/re_sdk/src/recording_stream.rs b/crates/re_sdk/src/recording_stream.rs index 7fd190910f7c..2c4eaf25b1ec 100644 --- a/crates/re_sdk/src/recording_stream.rs +++ b/crates/re_sdk/src/recording_stream.rs @@ -9,7 +9,8 @@ use re_log_types::{ DataTableBatcherConfig, DataTableBatcherError, EntityPath, LogMsg, RowId, StoreId, StoreInfo, StoreKind, StoreSource, Time, TimeInt, TimePoint, TimeType, Timeline, TimelineName, }; -use re_types::{components::InstanceKey, AsComponents, ComponentBatch, SerializationError}; +use re_types_core::{AsComponents, ComponentBatch, SerializationError}; +use re_types::components::InstanceKey; #[cfg(feature = "web_viewer")] use re_web_viewer_server::WebViewerServerPort; From f127f2a4420a9187310dacfbdc637360bb3b3f6d Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 18:02:08 +0200 Subject: [PATCH 07/13] misc fixes --- Cargo.lock | 1 - crates/re_data_ui/src/component_ui_registry.rs | 2 +- crates/re_log_encoding/Cargo.toml | 6 +++--- crates/re_sdk_comms/Cargo.toml | 6 +++--- crates/re_string_interner/Cargo.toml | 8 ++++++-- crates/re_string_interner/src/lib.rs | 8 +++++++- crates/re_viewer/Cargo.toml | 1 - examples/rust/extend_viewer_ui/src/main.rs | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c9fa10fc9cb..e6e8149f7ffd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4222,7 +4222,6 @@ dependencies = [ "re_renderer", "re_tracing", "re_types", - "re_types_core", "re_ui", "re_viewer_context", "rfd", diff --git a/crates/re_data_ui/src/component_ui_registry.rs b/crates/re_data_ui/src/component_ui_registry.rs index 0fe125351c3b..307f0b9ceca9 100644 --- a/crates/re_data_ui/src/component_ui_registry.rs +++ b/crates/re_data_ui/src/component_ui_registry.rs @@ -70,7 +70,7 @@ fn fallback_component_ui( } fn arrow_ui(ui: &mut egui::Ui, verbosity: UiVerbosity, array: &dyn arrow2::array::Array) { - use re_log_types::SizeBytes as _; + use re_types::SizeBytes as _; // Special-treat text. // Note: we match on the raw data here, so this works for any component containing text. diff --git a/crates/re_log_encoding/Cargo.toml b/crates/re_log_encoding/Cargo.toml index 9759876ca4be..f12118f83506 100644 --- a/crates/re_log_encoding/Cargo.toml +++ b/crates/re_log_encoding/Cargo.toml @@ -42,7 +42,7 @@ thiserror.workspace = true web-time.workspace = true # Optional external dependencies: -rmp-serde = { version = "1", optional = true } +rmp-serde = { workspace = true, optional = true } lz4_flex = { version = "0.10", optional = true } # Web dependencies: @@ -53,11 +53,11 @@ wasm-bindgen-futures = "0.4" web-sys = { version = "0.3.52", features = ["Window"] } [dev-dependencies] -re_types = { workspace = true, features = ["datagen"] } +re_types = { workspace = true, features = ["datagen", "serde"] } criterion = "0.5" mimalloc.workspace = true -serde_test = { version = "1" } +serde_test.workspace = true [lib] bench = false diff --git a/crates/re_sdk_comms/Cargo.toml b/crates/re_sdk_comms/Cargo.toml index 9289d41c2fb0..d50bd7b4fc99 100644 --- a/crates/re_sdk_comms/Cargo.toml +++ b/crates/re_sdk_comms/Cargo.toml @@ -18,10 +18,10 @@ all-features = true [features] ## Enable the client (SDK-side). -client = [] +client = ["re_log_encoding/encoder"] ## Enable the server. -server = [] +server = ["re_log_encoding/decoder"] [dependencies] @@ -35,4 +35,4 @@ crossbeam.workspace = true document-features.workspace = true rand = { workspace = true, features = ["std", "std_rng", "small_rng"] } thiserror.workspace = true -tokio = { workspace = true, features = ["io-util", "net"] } +tokio = { workspace = true, features = ["io-util", "net", "rt"] } diff --git a/crates/re_string_interner/Cargo.toml b/crates/re_string_interner/Cargo.toml index 66b5633571d0..49cf49a90b5e 100644 --- a/crates/re_string_interner/Cargo.toml +++ b/crates/re_string_interner/Cargo.toml @@ -16,11 +16,15 @@ version.workspace = true all-features = true +[features] +serde = ["dep:serde"] + + [dependencies] ahash.workspace = true nohash-hasher = "0.2" once_cell.workspace = true parking_lot.workspace = true -# Optional dependencies: -serde = { version = "1", optional = true } +# Optional dependencies +serde = { workspace = true, optional = true } diff --git a/crates/re_string_interner/src/lib.rs b/crates/re_string_interner/src/lib.rs index 7ccf97af9ebb..dd6188a7b3ec 100644 --- a/crates/re_string_interner/src/lib.rs +++ b/crates/re_string_interner/src/lib.rs @@ -10,6 +10,9 @@ pub mod external { pub use nohash_hasher; + + #[cfg(feature = "serde")] + pub use serde; } /// Fast but high quality string hash @@ -200,7 +203,10 @@ macro_rules! declare_new_type { ) => { $(#[$meta])* #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] - #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] + #[cfg_attr( + feature = "serde", + derive(serde::Deserialize, serde::Serialize), + )] pub struct $StructName($crate::InternedString); impl $StructName { diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index abd49322f4ac..497b1a7b3812 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -72,7 +72,6 @@ re_analytics = { workspace = true, optional = true } # External ahash.workspace = true anyhow.workspace = true -arrow2.workspace = true bytemuck.workspace = true cfg-if.workspace = true eframe = { workspace = true, default-features = false, features = [ diff --git a/examples/rust/extend_viewer_ui/src/main.rs b/examples/rust/extend_viewer_ui/src/main.rs index 4e1863aab20c..4743535b6ce6 100644 --- a/examples/rust/extend_viewer_ui/src/main.rs +++ b/examples/rust/extend_viewer_ui/src/main.rs @@ -180,7 +180,7 @@ fn component_ui( } fn format_arrow(value: &dyn arrow2::array::Array) -> String { - use re_log_types::SizeBytes as _; + use re_types::SizeBytes as _; let bytes = value.total_size_bytes(); if bytes < 256 { From 03bc11c7ac0ecf758155c35601994310f4dedf1e Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 18:05:28 +0200 Subject: [PATCH 08/13] prepare re_log_types for an re_types-free life --- crates/re_log_types/Cargo.toml | 6 +++-- crates/re_log_types/src/data_cell.rs | 18 ++++++++------- crates/re_log_types/src/data_row.rs | 7 +++--- crates/re_log_types/src/data_table.rs | 12 +++++----- crates/re_log_types/src/data_table_batcher.rs | 4 +++- crates/re_log_types/src/lib.rs | 23 ++++++++++--------- crates/re_log_types/src/load_file.rs | 9 ++++---- .../re_log_types/src/path/component_path.rs | 9 ++++++-- crates/re_log_types/src/path/data_path.rs | 3 ++- crates/re_log_types/src/path/entity_path.rs | 4 +++- crates/re_log_types/src/path/parse_path.rs | 3 ++- crates/re_log_types/src/time_point/mod.rs | 9 +++++--- .../re_log_types/src/time_point/timeline.rs | 9 +++++--- crates/re_log_types/src/time_range.rs | 4 ++-- 14 files changed, 72 insertions(+), 48 deletions(-) diff --git a/crates/re_log_types/Cargo.toml b/crates/re_log_types/Cargo.toml index e8a658a628fd..5c177b7ac111 100644 --- a/crates/re_log_types/Cargo.toml +++ b/crates/re_log_types/Cargo.toml @@ -26,6 +26,7 @@ serde = [ "dep:serde_bytes", "re_string_interner/serde", "re_tuid/serde", + "re_types_core/serde", "re_types/serde", ] @@ -38,6 +39,7 @@ re_log.workspace = true re_string_interner.workspace = true re_tracing.workspace = true re_tuid = { workspace = true, features = ["arrow"] } +re_types_core.workspace = true re_types = { workspace = true, features = ["image"] } # External @@ -70,9 +72,9 @@ web-time.workspace = true # Optional dependencies: -rmp-serde = { version = "1.1", optional = true } +rmp-serde = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["derive", "rc"] } -serde_bytes = { version = "0.11", optional = true } +serde_bytes = { workspace = true, optional = true } # Native dependencies: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/crates/re_log_types/src/data_cell.rs b/crates/re_log_types/src/data_cell.rs index dc4b979463e1..f0249faf8794 100644 --- a/crates/re_log_types/src/data_cell.rs +++ b/crates/re_log_types/src/data_cell.rs @@ -1,9 +1,8 @@ use std::sync::Arc; use arrow2::datatypes::DataType; -use re_types::{Component, ComponentBatch, ComponentName, DeserializationError}; -use crate::SizeBytes; +use re_types_core::{Component, ComponentBatch, ComponentName, DeserializationError, SizeBytes}; // --- @@ -16,10 +15,10 @@ pub enum DataCellError { Arrow(#[from] arrow2::error::Error), #[error("Could not deserialize data from Arrow: {0}")] - LoggableDeserialize(#[from] re_types::DeserializationError), + LoggableDeserialize(#[from] re_types_core::DeserializationError), #[error("Could not serialize data from Arrow: {0}")] - LoggableSerialize(#[from] re_types::SerializationError), + LoggableSerialize(#[from] re_types_core::SerializationError), // Needed to handle TryFrom -> T #[error("Infallible")] @@ -75,9 +74,9 @@ pub type DataCellResult = ::std::result::Result; /// # use arrow2_convert::field::ArrowField as _; /// # use itertools::Itertools as _; /// # -/// # use re_log_types::{DataCell}; +/// # use re_log_types::DataCell; /// # use re_log_types::example_components::MyPoint; -/// # use re_types::Loggable as _; +/// # use re_types_core::Loggable as _; /// # /// let points: &[MyPoint] = &[ /// MyPoint { x: 10.0, y: 10.0 }, @@ -166,7 +165,9 @@ pub struct DataCellInner { impl DataCell { /// Builds a new `DataCell` from a component batch. #[inline] - pub fn from_component_batch(batch: &dyn ComponentBatch) -> re_types::SerializationResult { + pub fn from_component_batch( + batch: &dyn ComponentBatch, + ) -> re_types_core::SerializationResult { batch .to_arrow() .map(|arrow| DataCell::from_arrow(batch.name(), arrow)) @@ -647,7 +648,8 @@ impl DataCellInner { fn data_cell_sizes() { use crate::DataCell; use arrow2::array::UInt64Array; - use re_types::{components::InstanceKey, Loggable as _}; + use re_types_core::Loggable as _; + use re_types::components::InstanceKey; // not computed // NOTE: Unsized cells are illegal in debug mode and will flat out crash. diff --git a/crates/re_log_types/src/data_row.rs b/crates/re_log_types/src/data_row.rs index 918e41b594b4..b9e756725185 100644 --- a/crates/re_log_types/src/data_row.rs +++ b/crates/re_log_types/src/data_row.rs @@ -1,9 +1,10 @@ use ahash::HashSetExt; use nohash_hasher::IntSet; -use re_types::{AsComponents, ComponentName}; use smallvec::SmallVec; -use crate::{DataCell, DataCellError, DataTable, EntityPath, SizeBytes, TableId, TimePoint}; +use re_types_core::{AsComponents, ComponentName, SizeBytes}; + +use crate::{DataCell, DataCellError, DataTable, EntityPath, TableId, TimePoint}; // --- @@ -278,7 +279,7 @@ impl DataRow { row_id: RowId, timepoint: TimePoint, entity_path: EntityPath, - comp_batches: impl IntoIterator, + comp_batches: impl IntoIterator, ) -> anyhow::Result { re_tracing::profile_function!(); diff --git a/crates/re_log_types/src/data_table.rs b/crates/re_log_types/src/data_table.rs index 23020cc71ffe..a1599ab1a8c8 100644 --- a/crates/re_log_types/src/data_table.rs +++ b/crates/re_log_types/src/data_table.rs @@ -1,15 +1,15 @@ use std::collections::BTreeMap; -use re_types::{ComponentName, Loggable}; - use ahash::HashMap; use itertools::{izip, Itertools as _}; use nohash_hasher::IntSet; use smallvec::SmallVec; +use re_types_core::{ComponentName, Loggable, SizeBytes}; + use crate::{ data_row::DataReadResult, ArrowMsg, DataCell, DataCellError, DataRow, DataRowError, EntityPath, - RowId, SizeBytes, TimePoint, Timeline, + RowId, TimePoint, Timeline, }; // --- @@ -37,10 +37,10 @@ pub enum DataTableError { Arrow(#[from] arrow2::error::Error), #[error("Could not serialize component instances to/from Arrow: {0}")] - Serialization(#[from] re_types::SerializationError), + Serialization(#[from] re_types_core::SerializationError), #[error("Could not deserialize component instances to/from Arrow: {0}")] - Deserialization(#[from] re_types::DeserializationError), + Deserialization(#[from] re_types_core::DeserializationError), // Needed to handle TryFrom -> T #[error("Infallible")] @@ -685,7 +685,7 @@ impl DataTable { } /// Serializes a single control column: an iterable of dense arrow-like data. - pub fn serialize_control_column<'a, C: re_types::Component + 'a>( + pub fn serialize_control_column<'a, C: re_types_core::Component + 'a>( values: &'a [C], ) -> DataTableResult<(Field, Box)> where diff --git a/crates/re_log_types/src/data_table_batcher.rs b/crates/re_log_types/src/data_table_batcher.rs index 0e4239908760..9d0ca4887a78 100644 --- a/crates/re_log_types/src/data_table_batcher.rs +++ b/crates/re_log_types/src/data_table_batcher.rs @@ -5,7 +5,9 @@ use std::{ use crossbeam::channel::{Receiver, Sender}; -use crate::{DataRow, DataTable, SizeBytes, TableId}; +use re_types_core::SizeBytes as _; + +use crate::{DataRow, DataTable, TableId}; // --- diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index 2161b4562602..23e0cca32ad0 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -57,10 +57,6 @@ pub use self::time_point::{TimeInt, TimePoint, TimeType, Timeline, TimelineName} pub use self::time_range::{TimeRange, TimeRangeF}; pub use self::time_real::TimeReal; -// Re-export `ComponentName` for convenience -pub use re_types::ComponentName; -pub use re_types::SizeBytes; - #[cfg(not(target_arch = "wasm32"))] pub use self::data_table_batcher::{ DataTableBatcher, DataTableBatcherConfig, DataTableBatcherError, @@ -76,7 +72,9 @@ pub use self::load_file::{data_cells_from_file_contents, FromFileError}; pub mod external { pub use arrow2; pub use arrow2_convert; + pub use re_tuid; + pub use re_types_core; } #[macro_export] @@ -220,7 +218,10 @@ impl std::fmt::Display for ApplicationId { /// The most general log message sent from the SDK to the server. #[must_use] #[derive(Clone, Debug, PartialEq)] // `PartialEq` used for tests in another crate -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr( + feature = "serde", + derive(serde::Deserialize, serde::Serialize) +)] #[allow(clippy::large_enum_variant)] pub enum LogMsg { /// A new recording has begun. @@ -398,14 +399,14 @@ impl PathOp { // --------------------------------------------------------------------------- -/// Implements [`re_types::Component`] for `T: arrow2_convert::{Serialize, Deserialize}`. +/// Implements [`::re_types_core::Component`] for `T: arrow2_convert::{Serialize, Deserialize}`. #[doc(hidden)] #[macro_export] macro_rules! arrow2convert_component_shim { ($entity:ident as $fqname:expr) => { - impl re_types::Loggable for $entity { - type Name = re_types::ComponentName; + impl ::re_types_core::Loggable for $entity { + type Name = ::re_types_core::ComponentName; #[inline] fn name() -> Self::Name { @@ -420,7 +421,7 @@ macro_rules! arrow2convert_component_shim { #[inline] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> re_types::SerializationResult> + ) -> ::re_types_core::SerializationResult> where Self: Clone + 'a, { @@ -433,14 +434,14 @@ macro_rules! arrow2convert_component_shim { let arrow = arrow2_convert::serialize::TryIntoArrow::try_into_arrow(vec.iter()) .map_err(|err| { - re_types::SerializationError::ArrowConvertFailure(err.to_string()) + ::re_types_core::SerializationError::ArrowConvertFailure(err.to_string()) })?; Ok(arrow) } #[inline] - fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> re_types::DeserializationResult>> + fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> ::re_types_core::DeserializationResult>> where Self: Sized { diff --git a/crates/re_log_types/src/load_file.rs b/crates/re_log_types/src/load_file.rs index fcae2fd15405..de7bddf166fc 100644 --- a/crates/re_log_types/src/load_file.rs +++ b/crates/re_log_types/src/load_file.rs @@ -38,7 +38,8 @@ pub fn data_cells_from_file_path( match extension.as_str() { "glb" | "gltf" | "obj" => { - use re_types::{archetypes::Asset3D, AsComponents as _}; + use re_types_core::AsComponents as _; + use re_types::archetypes::Asset3D; let cells: Result, _> = Asset3D::from_file(file_path)? // TODO(#3414): this should be a method of `Archetype` .as_component_batches() @@ -70,8 +71,7 @@ pub fn data_cells_from_file_path( } fn image_indicator_cell() -> DataCell { - use re_types::Archetype as _; - + use re_types_core::Archetype as _; let indicator = re_types::archetypes::Image::indicator(); DataCell::from_arrow( indicator.name(), @@ -96,7 +96,8 @@ pub fn data_cells_from_file_contents( match extension.as_str() { "glb" | "gltf" | "obj" => { - use re_types::{archetypes::Asset3D, components::MediaType, AsComponents as _}; + use re_types_core::AsComponents as _; + use re_types::{archetypes::Asset3D, components::MediaType}; let cells: Result, _> = Asset3D::from_bytes(bytes, MediaType::guess_from_path(file_name)) .as_component_batches() diff --git a/crates/re_log_types/src/path/component_path.rs b/crates/re_log_types/src/path/component_path.rs index c26a42988d3e..73a9206a1aef 100644 --- a/crates/re_log_types/src/path/component_path.rs +++ b/crates/re_log_types/src/path/component_path.rs @@ -1,10 +1,15 @@ -use crate::{path::EntityPath, ComponentName}; +use re_types_core::ComponentName; + +use crate::path::EntityPath; /// A [`EntityPath`] plus a [`ComponentName`]. /// /// Example: `camera / "left" / points / #42`.`color` #[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr( + feature = "serde", + derive(serde::Deserialize, serde::Serialize) +)] pub struct ComponentPath { /// `camera / "left" / points / #42` pub entity_path: EntityPath, diff --git a/crates/re_log_types/src/path/data_path.rs b/crates/re_log_types/src/path/data_path.rs index 5041c2a387ec..cee8991572d9 100644 --- a/crates/re_log_types/src/path/data_path.rs +++ b/crates/re_log_types/src/path/data_path.rs @@ -1,4 +1,5 @@ -use re_types::{components::InstanceKey, ComponentName}; +use re_types_core::ComponentName; +use re_types::components::InstanceKey; use crate::EntityPath; diff --git a/crates/re_log_types/src/path/entity_path.rs b/crates/re_log_types/src/path/entity_path.rs index 809717bd8f46..2737b2837765 100644 --- a/crates/re_log_types/src/path/entity_path.rs +++ b/crates/re_log_types/src/path/entity_path.rs @@ -1,6 +1,8 @@ use std::sync::Arc; -use crate::{hash::Hash64, path::entity_path_impl::EntityPathImpl, EntityPathPart, SizeBytes}; +use re_types_core::SizeBytes; + +use crate::{hash::Hash64, path::entity_path_impl::EntityPathImpl, EntityPathPart}; // ---------------------------------------------------------------------------- diff --git a/crates/re_log_types/src/path/parse_path.rs b/crates/re_log_types/src/path/parse_path.rs index 94378eeb1faa..b2e3d9a0e690 100644 --- a/crates/re_log_types/src/path/parse_path.rs +++ b/crates/re_log_types/src/path/parse_path.rs @@ -1,6 +1,7 @@ use std::str::FromStr; -use re_types::{components::InstanceKey, ComponentName}; +use re_types_core::ComponentName; +use re_types::components::InstanceKey; use crate::{ComponentPath, DataPath, EntityPath, EntityPathPart, Index}; diff --git a/crates/re_log_types/src/time_point/mod.rs b/crates/re_log_types/src/time_point/mod.rs index 2c7fbc42f86e..1856783848a1 100644 --- a/crates/re_log_types/src/time_point/mod.rs +++ b/crates/re_log_types/src/time_point/mod.rs @@ -5,7 +5,7 @@ mod timeline; use crate::{ time::{Time, TimeZone}, - SizeBytes, TimeRange, + TimeRange, }; // Re-exports @@ -20,7 +20,10 @@ pub use timeline::{Timeline, TimelineName}; /// Timeless data will show up on all timelines, past and future, /// and will hit all time queries. In other words, it is always there. #[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr( + feature = "serde", + derive(serde::Deserialize, serde::Serialize) +)] pub struct TimePoint(BTreeMap); impl From> for TimePoint { @@ -93,7 +96,7 @@ impl TimePoint { } } -impl SizeBytes for TimePoint { +impl re_types_core::SizeBytes for TimePoint { #[inline] fn heap_size_bytes(&self) -> u64 { type K = Timeline; diff --git a/crates/re_log_types/src/time_point/timeline.rs b/crates/re_log_types/src/time_point/timeline.rs index 644eeded01f5..ae7d4c431aed 100644 --- a/crates/re_log_types/src/time_point/timeline.rs +++ b/crates/re_log_types/src/time_point/timeline.rs @@ -1,6 +1,6 @@ use arrow2::datatypes::{DataType, TimeUnit}; -use crate::{time::TimeZone, SizeBytes, TimeRange, TimeType}; +use crate::{time::TimeZone, TimeRange, TimeType}; re_string_interner::declare_new_type!( /// The name of a timeline. Often something like `"log_time"` or `"frame_nr"`. @@ -18,7 +18,10 @@ impl Default for TimelineName { /// A time frame/space, e.g. `log_time` or `frame_nr`, coupled with the type of time /// it keeps. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr( + feature = "serde", + derive(serde::Deserialize, serde::Serialize) +)] pub struct Timeline { /// Name of the timeline (e.g. "log_time"). name: TimelineName, @@ -126,7 +129,7 @@ impl Timeline { impl nohash_hasher::IsEnabled for Timeline {} -impl SizeBytes for Timeline { +impl re_types_core::SizeBytes for Timeline { #[inline] fn heap_size_bytes(&self) -> u64 { 0 diff --git a/crates/re_log_types/src/time_range.rs b/crates/re_log_types/src/time_range.rs index 9a5ed66aba95..6d7fd01bbeaf 100644 --- a/crates/re_log_types/src/time_range.rs +++ b/crates/re_log_types/src/time_range.rs @@ -1,6 +1,6 @@ use std::ops::RangeInclusive; -use crate::{SizeBytes, TimeInt, TimeReal}; +use crate::{TimeInt, TimeReal}; // ---------------------------------------------------------------------------- @@ -68,7 +68,7 @@ impl TimeRange { } } -impl SizeBytes for TimeRange { +impl re_types_core::SizeBytes for TimeRange { #[inline] fn heap_size_bytes(&self) -> u64 { 0 From 0f1f58b6af4790fa50154027eec8553de563f2c5 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 18:06:04 +0200 Subject: [PATCH 09/13] prepare re_data_store for an re_types-free life --- crates/re_data_store/Cargo.toml | 1 + crates/re_data_store/src/entity_tree.rs | 5 +++-- crates/re_data_store/src/lib.rs | 2 +- crates/re_data_store/src/store_db.rs | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/re_data_store/Cargo.toml b/crates/re_data_store/Cargo.toml index 89a8789e199b..740485db7d38 100644 --- a/crates/re_data_store/Cargo.toml +++ b/crates/re_data_store/Cargo.toml @@ -32,6 +32,7 @@ re_log_types.workspace = true re_log.workspace = true re_smart_channel.workspace = true re_tracing.workspace = true +re_types_core.workspace = true re_types.workspace = true document-features.workspace = true diff --git a/crates/re_data_store/src/entity_tree.rs b/crates/re_data_store/src/entity_tree.rs index c9a2d3b6fcb1..407500ab9c13 100644 --- a/crates/re_data_store/src/entity_tree.rs +++ b/crates/re_data_store/src/entity_tree.rs @@ -6,7 +6,7 @@ use nohash_hasher::IntMap; use re_log_types::{ ComponentPath, EntityPath, EntityPathPart, PathOp, RowId, TimeInt, TimePoint, Timeline, }; -use re_types::{ComponentName, Loggable}; +use re_types_core::{ComponentName, Loggable}; // ---------------------------------------------------------------------------- @@ -220,7 +220,8 @@ impl EntityTree { time_point: &TimePoint, path_op: &PathOp, ) -> Vec { - use re_types::{archetypes::Clear, components::ClearIsRecursive, Archetype as _}; + use re_types_core::Archetype as _; + use re_types::{archetypes::Clear, components::ClearIsRecursive}; re_tracing::profile_function!(); diff --git a/crates/re_data_store/src/lib.rs b/crates/re_data_store/src/lib.rs index a60e0ef4218d..95fafab66017 100644 --- a/crates/re_data_store/src/lib.rs +++ b/crates/re_data_store/src/lib.rs @@ -21,7 +21,7 @@ pub use self::versioned_instance_path::{VersionedInstancePath, VersionedInstance #[cfg(feature = "serde")] pub use editable_auto_value::EditableAutoValue; use re_log_types::DataTableError; -pub use re_log_types::{ComponentName, EntityPath, EntityPathPart, Index, TimeInt, Timeline}; +pub use re_log_types::{EntityPath, EntityPathPart, Index, TimeInt, Timeline}; // ---------------------------------------------------------------------------- diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index 26b94a42b1e5..cbcaa5b940ad 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -7,7 +7,8 @@ use re_log_types::{ ApplicationId, ComponentPath, DataCell, DataRow, DataTable, EntityPath, EntityPathHash, LogMsg, PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, TimePoint, Timeline, }; -use re_types::{components::InstanceKey, Loggable as _}; +use re_types_core::Loggable; +use re_types::components::InstanceKey; use crate::{Error, TimesPerTimeline}; From 0b382347561fed9db997f6deea0e18bdfbd84e1c Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 18:11:33 +0200 Subject: [PATCH 10/13] last min fixes --- Cargo.lock | 2 -- crates/re_log_types/src/lib.rs | 17 +++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6e8149f7ffd..0a4b68f927ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4873,7 +4873,6 @@ dependencies = [ "re_string_interner", "re_tracing", "re_types", - "re_types_core", "re_ui", "serde", "slotmap", @@ -4904,7 +4903,6 @@ dependencies = [ "re_space_view", "re_tracing", "re_types", - "re_types_core", "re_ui", "re_viewer_context", "serde", diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index 23e0cca32ad0..58dcc6011698 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -218,10 +218,7 @@ impl std::fmt::Display for ApplicationId { /// The most general log message sent from the SDK to the server. #[must_use] #[derive(Clone, Debug, PartialEq)] // `PartialEq` used for tests in another crate -#[cfg_attr( - feature = "serde", - derive(serde::Deserialize, serde::Serialize) -)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[allow(clippy::large_enum_variant)] pub enum LogMsg { /// A new recording has begun. @@ -399,14 +396,14 @@ impl PathOp { // --------------------------------------------------------------------------- -/// Implements [`::re_types_core::Component`] for `T: arrow2_convert::{Serialize, Deserialize}`. +/// Implements [`::re_types::Component`] for `T: arrow2_convert::{Serialize, Deserialize}`. #[doc(hidden)] #[macro_export] macro_rules! arrow2convert_component_shim { ($entity:ident as $fqname:expr) => { - impl ::re_types_core::Loggable for $entity { - type Name = ::re_types_core::ComponentName; + impl ::re_types::Loggable for $entity { + type Name = ::re_types::ComponentName; #[inline] fn name() -> Self::Name { @@ -421,7 +418,7 @@ macro_rules! arrow2convert_component_shim { #[inline] fn to_arrow_opt<'a>( data: impl IntoIterator>>>, - ) -> ::re_types_core::SerializationResult> + ) -> ::re_types::SerializationResult> where Self: Clone + 'a, { @@ -434,14 +431,14 @@ macro_rules! arrow2convert_component_shim { let arrow = arrow2_convert::serialize::TryIntoArrow::try_into_arrow(vec.iter()) .map_err(|err| { - ::re_types_core::SerializationError::ArrowConvertFailure(err.to_string()) + ::re_types::SerializationError::ArrowConvertFailure(err.to_string()) })?; Ok(arrow) } #[inline] - fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> ::re_types_core::DeserializationResult>> + fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> ::re_types::DeserializationResult>> where Self: Sized { From 6571c48015fd6655914246aa7b2ab14161827a09 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 18:51:22 +0200 Subject: [PATCH 11/13] didnt run codegen it seems? --- .../src/archetypes/annotation_context.rs | 3 +- .../src/archetypes/disconnected_space.rs | 3 +- .../src/archetypes/segmentation_image.rs | 3 +- crates/re_types/src/blueprint/panel_view.rs | 10 +- .../re_types/src/components/line_strip2d.rs | 235 ++--- .../re_types/src/components/line_strip3d.rs | 235 ++--- .../re_types/src/datatypes/annotation_info.rs | 30 +- .../src/datatypes/class_description.rs | 160 ++- .../datatypes/class_description_map_elem.rs | 20 +- .../re_types/src/datatypes/keypoint_pair.rs | 20 +- crates/re_types/src/datatypes/material.rs | 10 +- .../re_types/src/datatypes/mesh_properties.rs | 77 +- crates/re_types/src/datatypes/rotation3d.rs | 103 +- .../src/datatypes/rotation_axis_angle.rs | 95 +- crates/re_types/src/datatypes/scale3d.rs | 103 +- .../re_types/src/datatypes/tensor_buffer.rs | 996 +++++++++--------- crates/re_types/src/datatypes/tensor_data.rs | 85 +- .../src/datatypes/tensor_dimension.rs | 20 +- crates/re_types/src/datatypes/transform3d.rs | 4 +- .../src/datatypes/translation_and_mat3x3.rs | 184 ++-- .../datatypes/translation_rotation_scale3d.rs | 115 +- .../src/testing/datatypes/affix_fuzzer1.rs | 157 ++- .../src/testing/datatypes/affix_fuzzer20.rs | 20 +- .../src/testing/datatypes/affix_fuzzer21.rs | 87 +- .../src/testing/datatypes/affix_fuzzer5.rs | 10 +- .../src/testing/datatypes/flattened_scalar.rs | 10 +- 26 files changed, 1310 insertions(+), 1485 deletions(-) diff --git a/crates/re_types/src/archetypes/annotation_context.rs b/crates/re_types/src/archetypes/annotation_context.rs index eb5cedb9722c..8de2b4955d49 100644 --- a/crates/re_types/src/archetypes/annotation_context.rs +++ b/crates/re_types/src/archetypes/annotation_context.rs @@ -98,8 +98,7 @@ impl AnnotationContext { } /// Indicator component for the [`AnnotationContext`] [`::re_types_core::Archetype`] -pub type AnnotationContextIndicator = - ::re_types_core::GenericIndicatorComponent; +pub type AnnotationContextIndicator = ::re_types_core::GenericIndicatorComponent; impl ::re_types_core::Archetype for AnnotationContext { type Indicator = AnnotationContextIndicator; diff --git a/crates/re_types/src/archetypes/disconnected_space.rs b/crates/re_types/src/archetypes/disconnected_space.rs index f3054a8f3e5c..7efe8049a999 100644 --- a/crates/re_types/src/archetypes/disconnected_space.rs +++ b/crates/re_types/src/archetypes/disconnected_space.rs @@ -89,8 +89,7 @@ impl DisconnectedSpace { } /// Indicator component for the [`DisconnectedSpace`] [`::re_types_core::Archetype`] -pub type DisconnectedSpaceIndicator = - ::re_types_core::GenericIndicatorComponent; +pub type DisconnectedSpaceIndicator = ::re_types_core::GenericIndicatorComponent; impl ::re_types_core::Archetype for DisconnectedSpace { type Indicator = DisconnectedSpaceIndicator; diff --git a/crates/re_types/src/archetypes/segmentation_image.rs b/crates/re_types/src/archetypes/segmentation_image.rs index 63a5c9b49d1f..efad927adaa8 100644 --- a/crates/re_types/src/archetypes/segmentation_image.rs +++ b/crates/re_types/src/archetypes/segmentation_image.rs @@ -105,8 +105,7 @@ impl SegmentationImage { } /// Indicator component for the [`SegmentationImage`] [`::re_types_core::Archetype`] -pub type SegmentationImageIndicator = - ::re_types_core::GenericIndicatorComponent; +pub type SegmentationImageIndicator = ::re_types_core::GenericIndicatorComponent; impl ::re_types_core::Archetype for SegmentationImage { type Indicator = SegmentationImageIndicator; diff --git a/crates/re_types/src/blueprint/panel_view.rs b/crates/re_types/src/blueprint/panel_view.rs index 925c2d935e9c..9bbde6174018 100644 --- a/crates/re_types/src/blueprint/panel_view.rs +++ b/crates/re_types/src/blueprint/panel_view.rs @@ -163,12 +163,10 @@ impl ::re_types_core::Loggable for PanelView { .collect(); let is_expanded = { if !arrays_by_name.contains_key("is_expanded") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "is_expanded", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "is_expanded", + )) .with_context("rerun.blueprint.PanelView"); } let arrow_data = &**arrays_by_name["is_expanded"]; diff --git a/crates/re_types/src/components/line_strip2d.rs b/crates/re_types/src/components/line_strip2d.rs index bb2ef0c1151e..212d142cb25f 100644 --- a/crates/re_types/src/components/line_strip2d.rs +++ b/crates/re_types/src/components/line_strip2d.rs @@ -179,33 +179,33 @@ impl ::re_types_core::Loggable for LineStrip2D { re_tracing::profile_function!(); use ::arrow2::{array::*, buffer::*, datatypes::*}; use ::re_types_core::{Loggable as _, ResultExt as _}; - Ok( - { - let arrow_data = arrow_data - .as_any() - .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { - name: "item".to_owned(), - data_type: ::arrow_datatype(), - is_nullable: false, - metadata: [].into(), - }), - ), + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: ::arrow_datatype(), + is_nullable: false, + metadata: [].into(), + })), arrow_data.data_type().clone(), - )) - .with_context("rerun.components.LineStrip2D#points")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - { - let arrow_data_inner = arrow_data_inner - .as_any() - .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + ) + }) + .with_context("rerun.components.LineStrip2D#points")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let arrow_data_inner = { + let arrow_data_inner = &**arrow_data.values(); + { + let arrow_data_inner = arrow_data_inner + .as_any() + .downcast_ref::<::arrow2::array::FixedSizeListArray>() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -216,120 +216,105 @@ impl ::re_types_core::Loggable for LineStrip2D { 2usize, ), arrow_data_inner.data_type().clone(), - )) - .with_context("rerun.components.LineStrip2D#points")?; - if arrow_data_inner.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(2usize) - .zip( - (2usize..).step_by(2usize).take(arrow_data_inner.len()), - ); - let arrow_data_inner_inner = { - let arrow_data_inner_inner = &**arrow_data_inner.values(); - arrow_data_inner_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + ) + }) + .with_context("rerun.components.LineStrip2D#points")?; + if arrow_data_inner.is_empty() { + Vec::new() + } else { + let offsets = (0..) + .step_by(2usize) + .zip((2usize..).step_by(2usize).take(arrow_data_inner.len())); + let arrow_data_inner_inner = { + let arrow_data_inner_inner = &**arrow_data_inner.values(); + arrow_data_inner_inner + .as_any() + .downcast_ref::() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner_inner.data_type().clone(), - )) - .with_context("rerun.components.LineStrip2D#points")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data_inner.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 2usize); - if end as usize > arrow_data_inner_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner_inner.len(), - ), - ); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner_inner - .get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + ) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec2D(v)) - }) - }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? - } - .into_iter() - } - .collect::>() - }; - let offsets = arrow_data.offsets(); - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { + .with_context("rerun.components.LineStrip2D#points")? + .into_iter() + .map(|opt| opt.copied()) + .collect::>() + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets, + arrow_data_inner.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 2usize); + if end as usize > arrow_data_inner_inner.len() { return Err( ::re_types_core::DeserializationError::offset_slice_oob( (start, end), - arrow_data_inner.len(), + arrow_data_inner_inner.len(), ), ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) + arrow_data_inner_inner + .get_unchecked(start as usize..end as usize) }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) .transpose() - }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? - } - .into_iter() - } - .map(|v| { - v.ok_or_else(::re_types_core::DeserializationError::missing_data) + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec2D(v)) + }) + }) + .collect::<::re_types_core::DeserializationResult>>>()? + } + .into_iter() + } + .collect::>() + }; + let offsets = arrow_data.offsets(); + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err(::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + )); + } + + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = + unsafe { arrow_data_inner.get_unchecked(start as usize..end as usize) }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) + }) + .transpose() }) - .map(|res| res.map(|v| Some(Self(v)))) - .collect::<::re_types_core::DeserializationResult>>>() - .with_context("rerun.components.LineStrip2D#points") - .with_context("rerun.components.LineStrip2D")?, - ) + .collect::<::re_types_core::DeserializationResult>>>()? + } + .into_iter() + } + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::<::re_types_core::DeserializationResult>>>() + .with_context("rerun.components.LineStrip2D#points") + .with_context("rerun.components.LineStrip2D")?) } } diff --git a/crates/re_types/src/components/line_strip3d.rs b/crates/re_types/src/components/line_strip3d.rs index 88baa28002d5..d08629f4b4c0 100644 --- a/crates/re_types/src/components/line_strip3d.rs +++ b/crates/re_types/src/components/line_strip3d.rs @@ -179,33 +179,33 @@ impl ::re_types_core::Loggable for LineStrip3D { re_tracing::profile_function!(); use ::arrow2::{array::*, buffer::*, datatypes::*}; use ::re_types_core::{Loggable as _, ResultExt as _}; - Ok( - { - let arrow_data = arrow_data - .as_any() - .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { - name: "item".to_owned(), - data_type: ::arrow_datatype(), - is_nullable: false, - metadata: [].into(), - }), - ), + Ok({ + let arrow_data = arrow_data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: ::arrow_datatype(), + is_nullable: false, + metadata: [].into(), + })), arrow_data.data_type().clone(), - )) - .with_context("rerun.components.LineStrip3D#points")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - { - let arrow_data_inner = arrow_data_inner - .as_any() - .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + ) + }) + .with_context("rerun.components.LineStrip3D#points")?; + if arrow_data.is_empty() { + Vec::new() + } else { + let arrow_data_inner = { + let arrow_data_inner = &**arrow_data.values(); + { + let arrow_data_inner = arrow_data_inner + .as_any() + .downcast_ref::<::arrow2::array::FixedSizeListArray>() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( DataType::FixedSizeList( Box::new(Field { name: "item".to_owned(), @@ -216,120 +216,105 @@ impl ::re_types_core::Loggable for LineStrip3D { 3usize, ), arrow_data_inner.data_type().clone(), - )) - .with_context("rerun.components.LineStrip3D#points")?; - if arrow_data_inner.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(3usize) - .zip( - (3usize..).step_by(3usize).take(arrow_data_inner.len()), - ); - let arrow_data_inner_inner = { - let arrow_data_inner_inner = &**arrow_data_inner.values(); - arrow_data_inner_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( + ) + }) + .with_context("rerun.components.LineStrip3D#points")?; + if arrow_data_inner.is_empty() { + Vec::new() + } else { + let offsets = (0..) + .step_by(3usize) + .zip((3usize..).step_by(3usize).take(arrow_data_inner.len())); + let arrow_data_inner_inner = { + let arrow_data_inner_inner = &**arrow_data_inner.values(); + arrow_data_inner_inner + .as_any() + .downcast_ref::() + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( DataType::Float32, arrow_data_inner_inner.data_type().clone(), - )) - .with_context("rerun.components.LineStrip3D#points")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data_inner.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner_inner.len(), - ), - ); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner_inner - .get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + ) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) - }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? - } - .into_iter() - } - .collect::>() - }; - let offsets = arrow_data.offsets(); - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { + .with_context("rerun.components.LineStrip3D#points")? + .into_iter() + .map(|opt| opt.copied()) + .collect::>() + }; + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets, + arrow_data_inner.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner_inner.len() { return Err( ::re_types_core::DeserializationError::offset_slice_oob( (start, end), - arrow_data_inner.len(), + arrow_data_inner_inner.len(), ), ); } #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) + arrow_data_inner_inner + .get_unchecked(start as usize..end as usize) }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) .transpose() - }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? - } - .into_iter() - } - .map(|v| { - v.ok_or_else(::re_types_core::DeserializationError::missing_data) + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) + }) + }) + .collect::<::re_types_core::DeserializationResult>>>()? + } + .into_iter() + } + .collect::>() + }; + let offsets = arrow_data.offsets(); + arrow2::bitmap::utils::ZipValidity::new_with_validity( + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err(::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + )); + } + + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = + unsafe { arrow_data_inner.get_unchecked(start as usize..end as usize) }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) + }) + .transpose() }) - .map(|res| res.map(|v| Some(Self(v)))) - .collect::<::re_types_core::DeserializationResult>>>() - .with_context("rerun.components.LineStrip3D#points") - .with_context("rerun.components.LineStrip3D")?, - ) + .collect::<::re_types_core::DeserializationResult>>>()? + } + .into_iter() + } + .map(|v| v.ok_or_else(::re_types_core::DeserializationError::missing_data)) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::<::re_types_core::DeserializationResult>>>() + .with_context("rerun.components.LineStrip3D#points") + .with_context("rerun.components.LineStrip3D")?) } } diff --git a/crates/re_types/src/datatypes/annotation_info.rs b/crates/re_types/src/datatypes/annotation_info.rs index 7023000d0c6e..e049b14fc224 100644 --- a/crates/re_types/src/datatypes/annotation_info.rs +++ b/crates/re_types/src/datatypes/annotation_info.rs @@ -271,12 +271,10 @@ impl ::re_types_core::Loggable for AnnotationInfo { .collect(); let id = { if !arrays_by_name.contains_key("id") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "id", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "id", + )) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["id"]; @@ -295,12 +293,10 @@ impl ::re_types_core::Loggable for AnnotationInfo { }; let label = { if !arrays_by_name.contains_key("label") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "label", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "label", + )) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["label"]; @@ -355,12 +351,10 @@ impl ::re_types_core::Loggable for AnnotationInfo { }; let color = { if !arrays_by_name.contains_key("color") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "color", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "color", + )) .with_context("rerun.datatypes.AnnotationInfo"); } let arrow_data = &**arrays_by_name["color"]; diff --git a/crates/re_types/src/datatypes/class_description.rs b/crates/re_types/src/datatypes/class_description.rs index 911ba6ff51eb..a4198b04ee76 100644 --- a/crates/re_types/src/datatypes/class_description.rs +++ b/crates/re_types/src/datatypes/class_description.rs @@ -324,12 +324,10 @@ impl ::re_types_core::Loggable for ClassDescription { .collect(); let info = { if !arrays_by_name.contains_key("info") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "info", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "info", + )) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["info"]; @@ -339,12 +337,10 @@ impl ::re_types_core::Loggable for ClassDescription { }; let keypoint_annotations = { if !arrays_by_name.contains_key("keypoint_annotations") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint_annotations", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint_annotations", + )) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["keypoint_annotations"]; @@ -372,9 +368,7 @@ impl ::re_types_core::Loggable for ClassDescription { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::AnnotationInfo::from_arrow_opt( - arrow_data_inner, - ) + crate::datatypes::AnnotationInfo::from_arrow_opt(arrow_data_inner) .with_context( "rerun.datatypes.ClassDescription#keypoint_annotations", )? @@ -383,51 +377,46 @@ impl ::re_types_core::Loggable for ClassDescription { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let keypoint_connections = { if !arrays_by_name.contains_key("keypoint_connections") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint_connections", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint_connections", + )) .with_context("rerun.datatypes.ClassDescription"); } let arrow_data = &**arrays_by_name["keypoint_connections"]; @@ -455,9 +444,7 @@ impl ::re_types_core::Loggable for ClassDescription { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::KeypointPair::from_arrow_opt( - arrow_data_inner, - ) + crate::datatypes::KeypointPair::from_arrow_opt(arrow_data_inner) .with_context( "rerun.datatypes.ClassDescription#keypoint_connections", )? @@ -466,41 +453,38 @@ impl ::re_types_core::Loggable for ClassDescription { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; arrow2::bitmap::utils::ZipValidity::new_with_validity( diff --git a/crates/re_types/src/datatypes/class_description_map_elem.rs b/crates/re_types/src/datatypes/class_description_map_elem.rs index 88d81b0f4901..ca9d74bd2c0f 100644 --- a/crates/re_types/src/datatypes/class_description_map_elem.rs +++ b/crates/re_types/src/datatypes/class_description_map_elem.rs @@ -200,12 +200,10 @@ impl ::re_types_core::Loggable for ClassDescriptionMapElem { .collect(); let class_id = { if !arrays_by_name.contains_key("class_id") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "class_id", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "class_id", + )) .with_context("rerun.datatypes.ClassDescriptionMapElem"); } let arrow_data = &**arrays_by_name["class_id"]; @@ -225,12 +223,10 @@ impl ::re_types_core::Loggable for ClassDescriptionMapElem { }; let class_description = { if !arrays_by_name.contains_key("class_description") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "class_description", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "class_description", + )) .with_context("rerun.datatypes.ClassDescriptionMapElem"); } let arrow_data = &**arrays_by_name["class_description"]; diff --git a/crates/re_types/src/datatypes/keypoint_pair.rs b/crates/re_types/src/datatypes/keypoint_pair.rs index 70a917ea3838..f47291f71210 100644 --- a/crates/re_types/src/datatypes/keypoint_pair.rs +++ b/crates/re_types/src/datatypes/keypoint_pair.rs @@ -208,12 +208,10 @@ impl ::re_types_core::Loggable for KeypointPair { .collect(); let keypoint0 = { if !arrays_by_name.contains_key("keypoint0") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint0", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint0", + )) .with_context("rerun.datatypes.KeypointPair"); } let arrow_data = &**arrays_by_name["keypoint0"]; @@ -233,12 +231,10 @@ impl ::re_types_core::Loggable for KeypointPair { }; let keypoint1 = { if !arrays_by_name.contains_key("keypoint1") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "keypoint1", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "keypoint1", + )) .with_context("rerun.datatypes.KeypointPair"); } let arrow_data = &**arrays_by_name["keypoint1"]; diff --git a/crates/re_types/src/datatypes/material.rs b/crates/re_types/src/datatypes/material.rs index 870c7ad9fdcb..8ae97a90c49a 100644 --- a/crates/re_types/src/datatypes/material.rs +++ b/crates/re_types/src/datatypes/material.rs @@ -182,12 +182,10 @@ impl ::re_types_core::Loggable for Material { .collect(); let albedo_factor = { if !arrays_by_name.contains_key("albedo_factor") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "albedo_factor", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "albedo_factor", + )) .with_context("rerun.datatypes.Material"); } let arrow_data = &**arrays_by_name["albedo_factor"]; diff --git a/crates/re_types/src/datatypes/mesh_properties.rs b/crates/re_types/src/datatypes/mesh_properties.rs index e9ea2c258911..c0a2a4725bcd 100644 --- a/crates/re_types/src/datatypes/mesh_properties.rs +++ b/crates/re_types/src/datatypes/mesh_properties.rs @@ -205,12 +205,10 @@ impl ::re_types_core::Loggable for MeshProperties { .collect(); let indices = { if !arrays_by_name.contains_key("indices") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "indices", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "indices", + )) .with_context("rerun.datatypes.MeshProperties"); } let arrow_data = &**arrays_by_name["indices"]; @@ -238,48 +236,47 @@ impl ::re_types_core::Loggable for MeshProperties { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.MeshProperties#indices")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; arrow2::bitmap::utils::ZipValidity::new_with_validity( diff --git a/crates/re_types/src/datatypes/rotation3d.rs b/crates/re_types/src/datatypes/rotation3d.rs index dd9c484b20d2..77408660de30 100644 --- a/crates/re_types/src/datatypes/rotation3d.rs +++ b/crates/re_types/src/datatypes/rotation3d.rs @@ -300,18 +300,20 @@ impl ::re_types_core::Loggable for Rotation3D { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::FixedSizeList( - Box::new(Field { - name: "item".to_owned(), - data_type: DataType::Float32, - is_nullable: false, - metadata: [].into(), - }), - 4usize, - ), - arrow_data.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::FixedSizeList( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }), + 4usize, + ), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.Rotation3D#Quaternion")?; if arrow_data.is_empty() { Vec::new() @@ -324,58 +326,53 @@ impl ::re_types_core::Loggable for Rotation3D { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.Rotation3D#Quaternion")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 4usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 4usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Quaternion(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Quaternion(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let axis_angle = { if 2usize >= arrow_data_arrays.len() { diff --git a/crates/re_types/src/datatypes/rotation_axis_angle.rs b/crates/re_types/src/datatypes/rotation_axis_angle.rs index 3c7b7d8d6474..56669afaaba0 100644 --- a/crates/re_types/src/datatypes/rotation_axis_angle.rs +++ b/crates/re_types/src/datatypes/rotation_axis_angle.rs @@ -231,12 +231,10 @@ impl ::re_types_core::Loggable for RotationAxisAngle { .collect(); let axis = { if !arrays_by_name.contains_key("axis") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "axis", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "axis", + )) .with_context("rerun.datatypes.RotationAxisAngle"); } let arrow_data = &**arrays_by_name["axis"]; @@ -270,66 +268,59 @@ impl ::re_types_core::Loggable for RotationAxisAngle { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.RotationAxisAngle#axis")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let angle = { if !arrays_by_name.contains_key("angle") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "angle", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "angle", + )) .with_context("rerun.datatypes.RotationAxisAngle"); } let arrow_data = &**arrays_by_name["angle"]; diff --git a/crates/re_types/src/datatypes/scale3d.rs b/crates/re_types/src/datatypes/scale3d.rs index e311fc1b04f6..95c9dbb8c50f 100644 --- a/crates/re_types/src/datatypes/scale3d.rs +++ b/crates/re_types/src/datatypes/scale3d.rs @@ -297,18 +297,20 @@ impl ::re_types_core::Loggable for Scale3D { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::FixedSizeListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::FixedSizeList( - Box::new(Field { - name: "item".to_owned(), - data_type: DataType::Float32, - is_nullable: false, - metadata: [].into(), - }), - 3usize, - ), - arrow_data.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::FixedSizeList( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }), + 3usize, + ), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.Scale3D#ThreeD")?; if arrow_data.is_empty() { Vec::new() @@ -321,58 +323,53 @@ impl ::re_types_core::Loggable for Scale3D { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.Scale3D#ThreeD")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let uniform = { if 2usize >= arrow_data_arrays.len() { diff --git a/crates/re_types/src/datatypes/tensor_buffer.rs b/crates/re_types/src/datatypes/tensor_buffer.rs index 972c091f76d4..571fbe529f39 100644 --- a/crates/re_types/src/datatypes/tensor_buffer.rs +++ b/crates/re_types/src/datatypes/tensor_buffer.rs @@ -1178,17 +1178,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt8, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U8")?; if arrow_data.is_empty() { Vec::new() @@ -1198,50 +1198,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt8, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt8, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U8")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u16 = { if 2usize >= arrow_data_arrays.len() { @@ -1252,17 +1251,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt16, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U16")?; if arrow_data.is_empty() { Vec::new() @@ -1272,50 +1271,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt16, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt16, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u32 = { if 3usize >= arrow_data_arrays.len() { @@ -1326,17 +1324,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt32, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U32")?; if arrow_data.is_empty() { Vec::new() @@ -1346,50 +1344,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let u64 = { if 4usize >= arrow_data_arrays.len() { @@ -1400,17 +1397,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt64, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U64")?; if arrow_data.is_empty() { Vec::new() @@ -1420,50 +1417,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt64, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt64, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#U64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i8 = { if 5usize >= arrow_data_arrays.len() { @@ -1474,17 +1470,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Int8, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I8")?; if arrow_data.is_empty() { Vec::new() @@ -1494,50 +1490,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Int8, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int8, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I8")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i16 = { if 6usize >= arrow_data_arrays.len() { @@ -1548,17 +1543,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Int16, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I16")?; if arrow_data.is_empty() { Vec::new() @@ -1568,50 +1563,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Int16, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int16, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i32 = { if 7usize >= arrow_data_arrays.len() { @@ -1622,17 +1616,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Int32, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I32")?; if arrow_data.is_empty() { Vec::new() @@ -1642,50 +1636,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Int32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let i64 = { if 8usize >= arrow_data_arrays.len() { @@ -1696,17 +1689,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Int64, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I64")?; if arrow_data.is_empty() { Vec::new() @@ -1716,50 +1709,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Int64, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Int64, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#I64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f16 = { if 9usize >= arrow_data_arrays.len() { @@ -1770,17 +1762,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Float16, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F16")?; if arrow_data.is_empty() { Vec::new() @@ -1790,50 +1782,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float16, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float16, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F16")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f32 = { if 10usize >= arrow_data_arrays.len() { @@ -1844,17 +1835,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Float32, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F32")?; if arrow_data.is_empty() { Vec::new() @@ -1864,50 +1855,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F32")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let f64 = { if 11usize >= arrow_data_arrays.len() { @@ -1918,17 +1908,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::Float64, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F64")?; if arrow_data.is_empty() { Vec::new() @@ -1938,50 +1928,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float64, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float64, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#F64")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; let jpeg = { if 12usize >= arrow_data_arrays.len() { @@ -1992,17 +1981,17 @@ impl ::re_types_core::Loggable for TensorBuffer { let arrow_data = arrow_data .as_any() .downcast_ref::<::arrow2::array::ListArray>() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::List( - Box::new(Field { + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::List(Box::new(Field { name: "item".to_owned(), data_type: DataType::UInt8, is_nullable: false, metadata: [].into(), - }), - ), - arrow_data.data_type().clone(), - )) + })), + arrow_data.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#JPEG")?; if arrow_data.is_empty() { Vec::new() @@ -2012,50 +2001,49 @@ impl ::re_types_core::Loggable for TensorBuffer { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::UInt8, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::UInt8, + arrow_data_inner.data_type().clone(), + ) + }) .with_context("rerun.datatypes.TensorBuffer#JPEG")? .values() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } - .collect::>() + .collect::>() }; arrow_data_types .iter() diff --git a/crates/re_types/src/datatypes/tensor_data.rs b/crates/re_types/src/datatypes/tensor_data.rs index d596ee962228..5437caa17e19 100644 --- a/crates/re_types/src/datatypes/tensor_data.rs +++ b/crates/re_types/src/datatypes/tensor_data.rs @@ -231,12 +231,10 @@ impl ::re_types_core::Loggable for TensorData { .collect(); let shape = { if !arrays_by_name.contains_key("shape") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "shape", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "shape", + )) .with_context("rerun.datatypes.TensorData"); } let arrow_data = &**arrays_by_name["shape"]; @@ -262,60 +260,53 @@ impl ::re_types_core::Loggable for TensorData { } else { let arrow_data_inner = { let arrow_data_inner = &**arrow_data.values(); - crate::datatypes::TensorDimension::from_arrow_opt( - arrow_data_inner, - ) + crate::datatypes::TensorDimension::from_arrow_opt(arrow_data_inner) .with_context("rerun.datatypes.TensorData#shape")? .into_iter() .collect::>() }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default) - .collect(); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data + .iter() + .cloned() + .map(Option::unwrap_or_default) + .collect(); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let buffer = { if !arrays_by_name.contains_key("buffer") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "buffer", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "buffer", + )) .with_context("rerun.datatypes.TensorData"); } let arrow_data = &**arrays_by_name["buffer"]; diff --git a/crates/re_types/src/datatypes/tensor_dimension.rs b/crates/re_types/src/datatypes/tensor_dimension.rs index 82574542a4f2..b295d04467f1 100644 --- a/crates/re_types/src/datatypes/tensor_dimension.rs +++ b/crates/re_types/src/datatypes/tensor_dimension.rs @@ -206,12 +206,10 @@ impl ::re_types_core::Loggable for TensorDimension { .collect(); let size = { if !arrays_by_name.contains_key("size") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "size", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "size", + )) .with_context("rerun.datatypes.TensorDimension"); } let arrow_data = &**arrays_by_name["size"]; @@ -230,12 +228,10 @@ impl ::re_types_core::Loggable for TensorDimension { }; let name = { if !arrays_by_name.contains_key("name") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "name", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "name", + )) .with_context("rerun.datatypes.TensorDimension"); } let arrow_data = &**arrays_by_name["name"]; diff --git a/crates/re_types/src/datatypes/transform3d.rs b/crates/re_types/src/datatypes/transform3d.rs index be4b87e01567..087d37735ede 100644 --- a/crates/re_types/src/datatypes/transform3d.rs +++ b/crates/re_types/src/datatypes/transform3d.rs @@ -320,9 +320,7 @@ impl ::re_types_core::Loggable for Transform3D { translation_rotation_scale.get_unchecked(offset as usize) } .clone() - .ok_or_else( - ::re_types_core::DeserializationError::missing_data, - ) + .ok_or_else(::re_types_core::DeserializationError::missing_data) .with_context( "rerun.datatypes.Transform3D#TranslationRotationScale", )? diff --git a/crates/re_types/src/datatypes/translation_and_mat3x3.rs b/crates/re_types/src/datatypes/translation_and_mat3x3.rs index 81b0f891ac01..26092eba025e 100644 --- a/crates/re_types/src/datatypes/translation_and_mat3x3.rs +++ b/crates/re_types/src/datatypes/translation_and_mat3x3.rs @@ -321,12 +321,10 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { .collect(); let translation = { if !arrays_by_name.contains_key("translation") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "translation", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "translation", + )) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["translation"]; @@ -360,10 +358,12 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context( "rerun.datatypes.TranslationAndMat3x3#translation", )? @@ -372,56 +372,47 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let mat3x3 = { if !arrays_by_name.contains_key("mat3x3") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "mat3x3", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "mat3x3", + )) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["mat3x3"]; @@ -455,68 +446,59 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) - .with_context( - "rerun.datatypes.TranslationAndMat3x3#mat3x3", - )? + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) + .with_context("rerun.datatypes.TranslationAndMat3x3#mat3x3")? .into_iter() .map(|opt| opt.copied()) .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 9usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 9usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Mat3x3(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Mat3x3(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let from_parent = { if !arrays_by_name.contains_key("from_parent") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "from_parent", + )) .with_context("rerun.datatypes.TranslationAndMat3x3"); } let arrow_data = &**arrays_by_name["from_parent"]; diff --git a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs index 02b71db07d38..a6b8a74abd4b 100644 --- a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs +++ b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs @@ -316,12 +316,10 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { .collect(); let translation = { if !arrays_by_name.contains_key("translation") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "translation", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "translation", + )) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["translation"]; @@ -357,10 +355,12 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context( "rerun.datatypes.TranslationRotationScale3D#translation", )? @@ -369,56 +369,47 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { .collect::>() }; arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, end)| { - debug_assert!(end - start == 3usize); - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets, + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, end)| { + debug_assert!(end - start == 3usize); + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner.get_unchecked(start as usize..end as usize) - }; - let data = data - .iter() - .cloned() - .map(Option::unwrap_or_default); - let arr = array_init::from_iter(data).unwrap(); - Ok(arr) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner.get_unchecked(start as usize..end as usize) + }; + let data = data.iter().cloned().map(Option::unwrap_or_default); + let arr = array_init::from_iter(data).unwrap(); + Ok(arr) }) - .map(|res_or_opt| { - res_or_opt - .map(|res_or_opt| { - res_or_opt.map(|v| crate::datatypes::Vec3D(v)) - }) + .transpose() + }) + .map(|res_or_opt| { + res_or_opt.map(|res_or_opt| { + res_or_opt.map(|v| crate::datatypes::Vec3D(v)) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let rotation = { if !arrays_by_name.contains_key("rotation") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "rotation", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "rotation", + )) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["rotation"]; @@ -428,12 +419,10 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { }; let scale = { if !arrays_by_name.contains_key("scale") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "scale", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "scale", + )) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["scale"]; @@ -443,12 +432,10 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { }; let from_parent = { if !arrays_by_name.contains_key("from_parent") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "from_parent", + )) .with_context("rerun.datatypes.TranslationRotationScale3D"); } let arrow_data = &**arrays_by_name["from_parent"]; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs index 3ba7d020d5f0..df17b1870d22 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs @@ -682,12 +682,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { .collect(); let single_float_optional = { if !arrays_by_name.contains_key("single_float_optional") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "single_float_optional", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "single_float_optional", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["single_float_optional"]; @@ -706,12 +704,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let single_string_required = { if !arrays_by_name.contains_key("single_string_required") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "single_string_required", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "single_string_required", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["single_string_required"]; @@ -768,12 +764,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let single_string_optional = { if !arrays_by_name.contains_key("single_string_optional") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "single_string_optional", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "single_string_optional", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["single_string_optional"]; @@ -830,12 +824,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let many_floats_optional = { if !arrays_by_name.contains_key("many_floats_optional") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "many_floats_optional", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "many_floats_optional", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["many_floats_optional"]; @@ -865,10 +857,12 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float32, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float32, + arrow_data_inner.data_type().clone(), + ) + }) .with_context( "rerun.testing.datatypes.AffixFuzzer1#many_floats_optional", )? @@ -876,49 +870,44 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; let many_strings_required = { if !arrays_by_name.contains_key("many_strings_required") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "many_strings_required", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "many_strings_required", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["many_strings_required"]; @@ -1041,12 +1030,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let many_strings_optional = { if !arrays_by_name.contains_key("many_strings_optional") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "many_strings_optional", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "many_strings_optional", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["many_strings_optional"]; @@ -1169,12 +1156,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let flattened_scalar = { if !arrays_by_name.contains_key("flattened_scalar") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "flattened_scalar", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "flattened_scalar", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["flattened_scalar"]; @@ -1193,12 +1178,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let almost_flattened_scalar = { if !arrays_by_name.contains_key("almost_flattened_scalar") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "almost_flattened_scalar", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "almost_flattened_scalar", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["almost_flattened_scalar"]; @@ -1210,12 +1193,10 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; let from_parent = { if !arrays_by_name.contains_key("from_parent") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "from_parent", + )) .with_context("rerun.testing.datatypes.AffixFuzzer1"); } let arrow_data = &**arrays_by_name["from_parent"]; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs index 2b7f41b0c993..1204be638b16 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs @@ -219,12 +219,10 @@ impl ::re_types_core::Loggable for AffixFuzzer20 { .collect(); let p = { if !arrays_by_name.contains_key("p") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "p", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "p", + )) .with_context("rerun.testing.datatypes.AffixFuzzer20"); } let arrow_data = &**arrays_by_name["p"]; @@ -246,12 +244,10 @@ impl ::re_types_core::Loggable for AffixFuzzer20 { }; let s = { if !arrays_by_name.contains_key("s") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "s", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "s", + )) .with_context("rerun.testing.datatypes.AffixFuzzer20"); } let arrow_data = &**arrays_by_name["s"]; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs index f706c9131682..092dfdcceddc 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs @@ -228,12 +228,10 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { .collect(); let single_half = { if !arrays_by_name.contains_key("single_half") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "single_half", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "single_half", + )) .with_context("rerun.testing.datatypes.AffixFuzzer21"); } let arrow_data = &**arrays_by_name["single_half"]; @@ -252,12 +250,10 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { }; let many_halves = { if !arrays_by_name.contains_key("many_halves") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "many_halves", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "many_halves", + )) .with_context("rerun.testing.datatypes.AffixFuzzer21"); } let arrow_data = &**arrays_by_name["many_halves"]; @@ -285,10 +281,12 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { arrow_data_inner .as_any() .downcast_ref::() - .ok_or_else(|| ::re_types_core::DeserializationError::datatype_mismatch( - DataType::Float16, - arrow_data_inner.data_type().clone(), - )) + .ok_or_else(|| { + ::re_types_core::DeserializationError::datatype_mismatch( + DataType::Float16, + arrow_data_inner.data_type().clone(), + ) + }) .with_context( "rerun.testing.datatypes.AffixFuzzer21#many_halves", )? @@ -296,39 +294,36 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { }; let offsets = arrow_data.offsets(); arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets.iter().zip(offsets.lengths()), - arrow_data.validity(), - ) - .map(|elem| { - elem - .map(|(start, len)| { - let start = *start as usize; - let end = start + len; - if end as usize > arrow_data_inner.len() { - return Err( - ::re_types_core::DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - ), - ); - } + offsets.iter().zip(offsets.lengths()), + arrow_data.validity(), + ) + .map(|elem| { + elem.map(|(start, len)| { + let start = *start as usize; + let end = start + len; + if end as usize > arrow_data_inner.len() { + return Err( + ::re_types_core::DeserializationError::offset_slice_oob( + (start, end), + arrow_data_inner.len(), + ), + ); + } - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = unsafe { - arrow_data_inner - .clone() - .sliced_unchecked(start as usize, end - start as usize) - }; - let data = ::re_types_core::ArrowBuffer::from(data); - Ok(data) - }) - .transpose() + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + let data = unsafe { + arrow_data_inner + .clone() + .sliced_unchecked(start as usize, end - start as usize) + }; + let data = ::re_types_core::ArrowBuffer::from(data); + Ok(data) }) - .collect::< - ::re_types_core::DeserializationResult>>, - >()? + .transpose() + }) + .collect::<::re_types_core::DeserializationResult>>>()? } - .into_iter() + .into_iter() } }; arrow2::bitmap::utils::ZipValidity::new_with_validity( diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs index 93aad096808e..01aa44648720 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs @@ -173,12 +173,10 @@ impl ::re_types_core::Loggable for AffixFuzzer5 { .collect(); let single_optional_union = { if !arrays_by_name.contains_key("single_optional_union") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "single_optional_union", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "single_optional_union", + )) .with_context("rerun.testing.datatypes.AffixFuzzer5"); } let arrow_data = &**arrays_by_name["single_optional_union"]; diff --git a/crates/re_types/src/testing/datatypes/flattened_scalar.rs b/crates/re_types/src/testing/datatypes/flattened_scalar.rs index e61b6ed3ffcf..bff5f04431ff 100644 --- a/crates/re_types/src/testing/datatypes/flattened_scalar.rs +++ b/crates/re_types/src/testing/datatypes/flattened_scalar.rs @@ -157,12 +157,10 @@ impl ::re_types_core::Loggable for FlattenedScalar { .collect(); let value = { if !arrays_by_name.contains_key("value") { - return Err( - ::re_types_core::DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "value", - ), - ) + return Err(::re_types_core::DeserializationError::missing_struct_field( + Self::arrow_datatype(), + "value", + )) .with_context("rerun.testing.datatypes.FlattenedScalar"); } let arrow_data = &**arrays_by_name["value"]; From 20427cfd322c6a996528d217662ad4203557ac96 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 19:01:36 +0200 Subject: [PATCH 12/13] what on earth is happening --- crates/re_arrow_store/benches/arrow2.rs | 2 +- crates/re_arrow_store/benches/data_store.rs | 2 +- crates/re_arrow_store/examples/dump_dataframe.rs | 2 +- crates/re_arrow_store/examples/latest_component.rs | 2 +- crates/re_arrow_store/examples/latest_components.rs | 2 +- crates/re_arrow_store/examples/range_components.rs | 2 +- crates/re_arrow_store/src/store_write.rs | 2 +- crates/re_arrow_store/tests/correctness.rs | 2 +- crates/re_arrow_store/tests/data_store.rs | 2 +- crates/re_arrow_store/tests/dump.rs | 2 +- crates/re_arrow_store/tests/internals.rs | 2 +- crates/re_data_store/src/entity_tree.rs | 2 +- crates/re_data_store/src/store_db.rs | 2 +- crates/re_log_types/src/data_cell.rs | 2 +- crates/re_log_types/src/load_file.rs | 4 ++-- crates/re_log_types/src/path/component_path.rs | 5 +---- crates/re_log_types/src/path/data_path.rs | 2 +- crates/re_log_types/src/path/parse_path.rs | 2 +- crates/re_log_types/src/time_point/mod.rs | 5 +---- crates/re_log_types/src/time_point/timeline.rs | 5 +---- crates/re_query/benches/query_benchmark.rs | 2 +- crates/re_query/src/archetype_view.rs | 2 +- crates/re_query/src/dataframe_util.rs | 2 +- crates/re_query/src/query.rs | 2 +- crates/re_query/tests/archetype_query_tests.rs | 2 +- crates/re_query/tests/archetype_range_tests.rs | 2 +- crates/re_sdk/src/lib.rs | 2 +- crates/re_sdk/src/recording_stream.rs | 2 +- 28 files changed, 29 insertions(+), 38 deletions(-) diff --git a/crates/re_arrow_store/benches/arrow2.rs b/crates/re_arrow_store/benches/arrow2.rs index b88a0fb820cd..54ba1c24a9fc 100644 --- a/crates/re_arrow_store/benches/arrow2.rs +++ b/crates/re_arrow_store/benches/arrow2.rs @@ -10,12 +10,12 @@ use criterion::Criterion; use itertools::Itertools; use re_log_types::DataCell; -use re_types_core::{Component, SizeBytes as _}; use re_types::datagen::{build_some_instances, build_some_positions2d}; use re_types::{ components::{InstanceKey, Position2D}, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::{Component, SizeBytes as _}; // --- diff --git a/crates/re_arrow_store/benches/data_store.rs b/crates/re_arrow_store/benches/data_store.rs index d9e5545b93d7..9b0e4719d3af 100644 --- a/crates/re_arrow_store/benches/data_store.rs +++ b/crates/re_arrow_store/benches/data_store.rs @@ -11,12 +11,12 @@ use re_arrow_store::{ use re_log_types::{ build_frame_nr, DataCell, DataRow, DataTable, EntityPath, RowId, TableId, TimeType, Timeline, }; -use re_types_core::{ComponentName, Loggable as _}; use re_types::datagen::build_some_instances; use re_types::{ components::InstanceKey, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::{ComponentName, Loggable as _}; criterion_group!(benches, insert, latest_at, latest_at_missing, range, gc); criterion_main!(benches); diff --git a/crates/re_arrow_store/examples/dump_dataframe.rs b/crates/re_arrow_store/examples/dump_dataframe.rs index fa9f79f5e1fa..495b8a031244 100644 --- a/crates/re_arrow_store/examples/dump_dataframe.rs +++ b/crates/re_arrow_store/examples/dump_dataframe.rs @@ -6,9 +6,9 @@ use re_arrow_store::{test_row, DataStore}; use re_log_types::{build_frame_nr, build_log_time, EntityPath, Time}; -use re_types_core::Loggable as _; use re_types::datagen::{build_some_instances, build_some_instances_from, build_some_positions2d}; use re_types::{components::InstanceKey, testing::build_some_large_structs}; +use re_types_core::Loggable as _; // --- diff --git a/crates/re_arrow_store/examples/latest_component.rs b/crates/re_arrow_store/examples/latest_component.rs index bb470bc840e5..a774cf8b897b 100644 --- a/crates/re_arrow_store/examples/latest_component.rs +++ b/crates/re_arrow_store/examples/latest_component.rs @@ -7,12 +7,12 @@ use re_arrow_store::polars_util::latest_component; use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline}; use re_log_types::{build_frame_nr, EntityPath}; -use re_types_core::Loggable as _; use re_types::datagen::build_some_positions2d; use re_types::{ components::{InstanceKey, Position2D}, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::Loggable as _; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/latest_components.rs b/crates/re_arrow_store/examples/latest_components.rs index b842348c78ec..8189b4bfee8d 100644 --- a/crates/re_arrow_store/examples/latest_components.rs +++ b/crates/re_arrow_store/examples/latest_components.rs @@ -9,12 +9,12 @@ use polars_core::prelude::*; use re_arrow_store::polars_util::latest_components; use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline}; use re_log_types::{build_frame_nr, EntityPath}; -use re_types_core::Loggable as _; use re_types::datagen::build_some_positions2d; use re_types::{ components::{InstanceKey, Position2D}, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::Loggable as _; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/range_components.rs b/crates/re_arrow_store/examples/range_components.rs index af0f890564e3..448bc4528544 100644 --- a/crates/re_arrow_store/examples/range_components.rs +++ b/crates/re_arrow_store/examples/range_components.rs @@ -7,12 +7,12 @@ use polars_core::prelude::JoinType; use re_arrow_store::{polars_util, test_row, DataStore, RangeQuery, TimeRange}; use re_log_types::{build_frame_nr, EntityPath, TimeType, Timeline}; -use re_types_core::Loggable as _; use re_types::datagen::build_some_positions2d; use re_types::{ components::{InstanceKey, Position2D}, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::Loggable as _; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index a1fed7a66411..09adb801dff0 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -9,8 +9,8 @@ use re_log_types::{ DataCell, DataCellColumn, DataCellError, DataRow, DataTable, RowId, TimeInt, TimePoint, TimeRange, }; -use re_types_core::{ComponentName, ComponentNameSet, Loggable, SizeBytes as _}; use re_types::components::InstanceKey; +use re_types_core::{ComponentName, ComponentNameSet, Loggable, SizeBytes as _}; use crate::{ store::MetadataRegistry, DataStore, DataStoreConfig, IndexedBucket, IndexedBucketInner, diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 44edfb77fd13..e24d7dcb0be0 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -13,9 +13,9 @@ use re_arrow_store::{ use re_log_types::{ build_frame_nr, build_log_time, DataCell, Duration, EntityPath, Time, TimeType, Timeline, }; -use re_types_core::Loggable as _; use re_types::components::InstanceKey; use re_types::datagen::{build_some_colors, build_some_instances, build_some_positions2d}; +use re_types_core::Loggable as _; // --- diff --git a/crates/re_arrow_store/tests/data_store.rs b/crates/re_arrow_store/tests/data_store.rs index 9024f76459de..47eb3e08a887 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -18,7 +18,6 @@ use re_arrow_store::{ use re_log_types::{ build_frame_nr, DataCell, DataRow, DataTable, EntityPath, TableId, TimeType, Timeline, }; -use re_types_core::{ComponentName, Loggable as _}; use re_types::datagen::{ build_some_colors, build_some_instances, build_some_instances_from, build_some_positions2d, }; @@ -26,6 +25,7 @@ use re_types::{ components::{Color, InstanceKey, Position2D}, testing::{build_some_large_structs, LargeStruct}, }; +use re_types_core::{ComponentName, Loggable as _}; // --- LatestComponentsAt --- diff --git a/crates/re_arrow_store/tests/dump.rs b/crates/re_arrow_store/tests/dump.rs index 21c30eca13f1..76dc579f526c 100644 --- a/crates/re_arrow_store/tests/dump.rs +++ b/crates/re_arrow_store/tests/dump.rs @@ -8,9 +8,9 @@ use re_arrow_store::{ TimeInt, TimeRange, Timeline, }; use re_log_types::{build_frame_nr, build_log_time, DataTable, EntityPath, TableId}; -use re_types_core::Loggable as _; use re_types::components::InstanceKey; use re_types::datagen::{build_some_colors, build_some_instances, build_some_positions2d}; +use re_types_core::Loggable as _; // --- Dump --- diff --git a/crates/re_arrow_store/tests/internals.rs b/crates/re_arrow_store/tests/internals.rs index 92736b5f5fd4..92f7d4c12b04 100644 --- a/crates/re_arrow_store/tests/internals.rs +++ b/crates/re_arrow_store/tests/internals.rs @@ -6,8 +6,8 @@ use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; use re_arrow_store::{DataStore, DataStoreConfig}; use re_log_types::{build_frame_nr, DataRow, EntityPath, RowId, TimePoint}; -use re_types_core::Loggable as _; use re_types::{components::InstanceKey, datagen::build_some_instances}; +use re_types_core::Loggable as _; // --- Internals --- diff --git a/crates/re_data_store/src/entity_tree.rs b/crates/re_data_store/src/entity_tree.rs index 407500ab9c13..250349ee41c5 100644 --- a/crates/re_data_store/src/entity_tree.rs +++ b/crates/re_data_store/src/entity_tree.rs @@ -220,8 +220,8 @@ impl EntityTree { time_point: &TimePoint, path_op: &PathOp, ) -> Vec { - use re_types_core::Archetype as _; use re_types::{archetypes::Clear, components::ClearIsRecursive}; + use re_types_core::Archetype as _; re_tracing::profile_function!(); diff --git a/crates/re_data_store/src/store_db.rs b/crates/re_data_store/src/store_db.rs index cbcaa5b940ad..a54d1242b400 100644 --- a/crates/re_data_store/src/store_db.rs +++ b/crates/re_data_store/src/store_db.rs @@ -7,8 +7,8 @@ use re_log_types::{ ApplicationId, ComponentPath, DataCell, DataRow, DataTable, EntityPath, EntityPathHash, LogMsg, PathOp, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, TimePoint, Timeline, }; -use re_types_core::Loggable; use re_types::components::InstanceKey; +use re_types_core::Loggable; use crate::{Error, TimesPerTimeline}; diff --git a/crates/re_log_types/src/data_cell.rs b/crates/re_log_types/src/data_cell.rs index f0249faf8794..96c0a46c45da 100644 --- a/crates/re_log_types/src/data_cell.rs +++ b/crates/re_log_types/src/data_cell.rs @@ -648,8 +648,8 @@ impl DataCellInner { fn data_cell_sizes() { use crate::DataCell; use arrow2::array::UInt64Array; - use re_types_core::Loggable as _; use re_types::components::InstanceKey; + use re_types_core::Loggable as _; // not computed // NOTE: Unsized cells are illegal in debug mode and will flat out crash. diff --git a/crates/re_log_types/src/load_file.rs b/crates/re_log_types/src/load_file.rs index de7bddf166fc..f769f0ce0dba 100644 --- a/crates/re_log_types/src/load_file.rs +++ b/crates/re_log_types/src/load_file.rs @@ -38,8 +38,8 @@ pub fn data_cells_from_file_path( match extension.as_str() { "glb" | "gltf" | "obj" => { - use re_types_core::AsComponents as _; use re_types::archetypes::Asset3D; + use re_types_core::AsComponents as _; let cells: Result, _> = Asset3D::from_file(file_path)? // TODO(#3414): this should be a method of `Archetype` .as_component_batches() @@ -96,8 +96,8 @@ pub fn data_cells_from_file_contents( match extension.as_str() { "glb" | "gltf" | "obj" => { - use re_types_core::AsComponents as _; use re_types::{archetypes::Asset3D, components::MediaType}; + use re_types_core::AsComponents as _; let cells: Result, _> = Asset3D::from_bytes(bytes, MediaType::guess_from_path(file_name)) .as_component_batches() diff --git a/crates/re_log_types/src/path/component_path.rs b/crates/re_log_types/src/path/component_path.rs index 73a9206a1aef..645d1394250d 100644 --- a/crates/re_log_types/src/path/component_path.rs +++ b/crates/re_log_types/src/path/component_path.rs @@ -6,10 +6,7 @@ use crate::path::EntityPath; /// /// Example: `camera / "left" / points / #42`.`color` #[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr( - feature = "serde", - derive(serde::Deserialize, serde::Serialize) -)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct ComponentPath { /// `camera / "left" / points / #42` pub entity_path: EntityPath, diff --git a/crates/re_log_types/src/path/data_path.rs b/crates/re_log_types/src/path/data_path.rs index cee8991572d9..b568e88c41bc 100644 --- a/crates/re_log_types/src/path/data_path.rs +++ b/crates/re_log_types/src/path/data_path.rs @@ -1,5 +1,5 @@ -use re_types_core::ComponentName; use re_types::components::InstanceKey; +use re_types_core::ComponentName; use crate::EntityPath; diff --git a/crates/re_log_types/src/path/parse_path.rs b/crates/re_log_types/src/path/parse_path.rs index b2e3d9a0e690..65d645597d0d 100644 --- a/crates/re_log_types/src/path/parse_path.rs +++ b/crates/re_log_types/src/path/parse_path.rs @@ -1,7 +1,7 @@ use std::str::FromStr; -use re_types_core::ComponentName; use re_types::components::InstanceKey; +use re_types_core::ComponentName; use crate::{ComponentPath, DataPath, EntityPath, EntityPathPart, Index}; diff --git a/crates/re_log_types/src/time_point/mod.rs b/crates/re_log_types/src/time_point/mod.rs index 1856783848a1..63c73a4aa2e1 100644 --- a/crates/re_log_types/src/time_point/mod.rs +++ b/crates/re_log_types/src/time_point/mod.rs @@ -20,10 +20,7 @@ pub use timeline::{Timeline, TimelineName}; /// Timeless data will show up on all timelines, past and future, /// and will hit all time queries. In other words, it is always there. #[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr( - feature = "serde", - derive(serde::Deserialize, serde::Serialize) -)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct TimePoint(BTreeMap); impl From> for TimePoint { diff --git a/crates/re_log_types/src/time_point/timeline.rs b/crates/re_log_types/src/time_point/timeline.rs index ae7d4c431aed..3f880eef1aec 100644 --- a/crates/re_log_types/src/time_point/timeline.rs +++ b/crates/re_log_types/src/time_point/timeline.rs @@ -18,10 +18,7 @@ impl Default for TimelineName { /// A time frame/space, e.g. `log_time` or `frame_nr`, coupled with the type of time /// it keeps. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -#[cfg_attr( - feature = "serde", - derive(serde::Deserialize, serde::Serialize) -)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Timeline { /// Name of the timeline (e.g. "log_time"). name: TimelineName, diff --git a/crates/re_query/benches/query_benchmark.rs b/crates/re_query/benches/query_benchmark.rs index 8be7e49fefce..126a9ad378a3 100644 --- a/crates/re_query/benches/query_benchmark.rs +++ b/crates/re_query/benches/query_benchmark.rs @@ -7,11 +7,11 @@ use itertools::Itertools; use re_arrow_store::{DataStore, LatestAtQuery}; use re_log_types::{entity_path, DataRow, EntityPath, Index, RowId, TimeInt, TimeType, Timeline}; use re_query::query_archetype; -use re_types_core::Loggable as _; use re_types::{ archetypes::Points2D, components::{Color, InstanceKey, Position2D, Text}, }; +use re_types_core::Loggable as _; // --- diff --git a/crates/re_query/src/archetype_view.rs b/crates/re_query/src/archetype_view.rs index f7ef8de859a3..db0ef8e04f02 100644 --- a/crates/re_query/src/archetype_view.rs +++ b/crates/re_query/src/archetype_view.rs @@ -3,11 +3,11 @@ use std::{collections::BTreeMap, marker::PhantomData}; use arrow2::array::{Array, PrimitiveArray}; use re_format::arrow; use re_log_types::{DataCell, RowId}; +use re_types::components::InstanceKey; use re_types_core::{ Archetype, Component, ComponentName, DeserializationError, DeserializationResult, Loggable, SerializationResult, }; -use re_types::components::InstanceKey; use crate::QueryError; diff --git a/crates/re_query/src/dataframe_util.rs b/crates/re_query/src/dataframe_util.rs index 1c0249fb8c30..6d72f06cb206 100644 --- a/crates/re_query/src/dataframe_util.rs +++ b/crates/re_query/src/dataframe_util.rs @@ -4,8 +4,8 @@ use arrow2::{ }; use polars_core::prelude::*; use re_arrow_store::ArrayExt; -use re_types_core::{Archetype, Component, Loggable}; use re_types::components::InstanceKey; +use re_types_core::{Archetype, Component, Loggable}; use crate::{ArchetypeView, ComponentWithInstances, QueryError}; diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 73b7df8e4452..3b6bbc552e7b 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -1,7 +1,7 @@ use re_arrow_store::{DataStore, LatestAtQuery}; use re_log_types::{DataRow, EntityPath, RowId}; -use re_types_core::{Archetype, ComponentName, Loggable}; use re_types::components::InstanceKey; +use re_types_core::{Archetype, ComponentName, Loggable}; use crate::{ArchetypeView, ComponentWithInstances, QueryError}; diff --git a/crates/re_query/tests/archetype_query_tests.rs b/crates/re_query/tests/archetype_query_tests.rs index 071da99306f6..7ed29d8e89cb 100644 --- a/crates/re_query/tests/archetype_query_tests.rs +++ b/crates/re_query/tests/archetype_query_tests.rs @@ -3,11 +3,11 @@ mod common; use re_arrow_store::DataStore; use re_log_types::{build_frame_nr, DataRow, RowId}; use re_query::query_archetype; -use re_types_core::Loggable as _; use re_types::{ archetypes::Points2D, components::{Color, InstanceKey, Position2D}, }; +use re_types_core::Loggable as _; #[test] fn simple_query() { diff --git a/crates/re_query/tests/archetype_range_tests.rs b/crates/re_query/tests/archetype_range_tests.rs index 65be8e347074..e34a7b39791c 100644 --- a/crates/re_query/tests/archetype_range_tests.rs +++ b/crates/re_query/tests/archetype_range_tests.rs @@ -3,11 +3,11 @@ mod common; use re_arrow_store::{DataStore, TimeInt, TimeRange}; use re_log_types::{build_frame_nr, DataRow, EntityPath, RowId}; use re_query::range_archetype; -use re_types_core::Loggable as _; use re_types::{ archetypes::Points2D, components::{Color, InstanceKey, Position2D}, }; +use re_types_core::Loggable as _; #[test] fn simple_range() { diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index afa2dab455ad..12545ebdd09d 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -90,12 +90,12 @@ pub mod coordinates { pub use re_types::view_coordinates::{Axis3, Handedness, Sign, SignedAxis3}; } +pub use re_types::{archetypes, components, datatypes}; pub use re_types_core::{ Archetype, ArchetypeName, AsComponents, Component, ComponentBatch, ComponentName, Datatype, DatatypeBatch, DatatypeName, GenericIndicatorComponent, Loggable, LoggableBatch, MaybeOwnedComponentBatch, NamedIndicatorComponent, }; -pub use re_types::{archetypes, components, datatypes}; mod prelude { // Import all archetypes into the global namespace to minimize diff --git a/crates/re_sdk/src/recording_stream.rs b/crates/re_sdk/src/recording_stream.rs index 2c4eaf25b1ec..af7b0f035728 100644 --- a/crates/re_sdk/src/recording_stream.rs +++ b/crates/re_sdk/src/recording_stream.rs @@ -9,8 +9,8 @@ use re_log_types::{ DataTableBatcherConfig, DataTableBatcherError, EntityPath, LogMsg, RowId, StoreId, StoreInfo, StoreKind, StoreSource, Time, TimeInt, TimePoint, TimeType, Timeline, TimelineName, }; -use re_types_core::{AsComponents, ComponentBatch, SerializationError}; use re_types::components::InstanceKey; +use re_types_core::{AsComponents, ComponentBatch, SerializationError}; #[cfg(feature = "web_viewer")] use re_web_viewer_server::WebViewerServerPort; From 47ba55a5df3fae568c45283ef7c1fcab48f719c1 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 16 Oct 2023 20:18:43 +0200 Subject: [PATCH 13/13] pr comments --- crates/re_arrow_store/Cargo.toml | 1 + crates/re_data_store/Cargo.toml | 1 + crates/re_log_types/Cargo.toml | 1 + crates/re_query/Cargo.toml | 1 + crates/re_types/Cargo.toml | 2 +- crates/re_types_core/src/lib.rs | 6 ------ 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/re_arrow_store/Cargo.toml b/crates/re_arrow_store/Cargo.toml index 7e485fb0eabd..9ba9deda9675 100644 --- a/crates/re_arrow_store/Cargo.toml +++ b/crates/re_arrow_store/Cargo.toml @@ -40,6 +40,7 @@ re_format.workspace = true re_log_types.workspace = true re_log.workspace = true re_tracing.workspace = true +# NOTE: We're on our way to make this crate re_types-free, which is why we import both. re_types_core.workspace = true re_types.workspace = true diff --git a/crates/re_data_store/Cargo.toml b/crates/re_data_store/Cargo.toml index 740485db7d38..fd830ae5d46e 100644 --- a/crates/re_data_store/Cargo.toml +++ b/crates/re_data_store/Cargo.toml @@ -32,6 +32,7 @@ re_log_types.workspace = true re_log.workspace = true re_smart_channel.workspace = true re_tracing.workspace = true +# NOTE: We're on our way to make this crate re_types-free, which is why we import both. re_types_core.workspace = true re_types.workspace = true diff --git a/crates/re_log_types/Cargo.toml b/crates/re_log_types/Cargo.toml index 5c177b7ac111..a16c30182efe 100644 --- a/crates/re_log_types/Cargo.toml +++ b/crates/re_log_types/Cargo.toml @@ -39,6 +39,7 @@ re_log.workspace = true re_string_interner.workspace = true re_tracing.workspace = true re_tuid = { workspace = true, features = ["arrow"] } +# NOTE: We're on our way to make this crate re_types-free, which is why we import both. re_types_core.workspace = true re_types = { workspace = true, features = ["image"] } diff --git a/crates/re_query/Cargo.toml b/crates/re_query/Cargo.toml index 7edf0d048a54..bb3bf34aaf82 100644 --- a/crates/re_query/Cargo.toml +++ b/crates/re_query/Cargo.toml @@ -29,6 +29,7 @@ re_arrow_store.workspace = true re_data_store.workspace = true re_format.workspace = true re_log_types.workspace = true +# NOTE: We're on our way to make this crate re_types-free, which is why we import both. re_types_core.workspace = true re_types = { workspace = true, features = ["datagen"] } re_log.workspace = true diff --git a/crates/re_types/Cargo.toml b/crates/re_types/Cargo.toml index f5397f857a3b..3d0c35bba104 100644 --- a/crates/re_types/Cargo.toml +++ b/crates/re_types/Cargo.toml @@ -99,7 +99,7 @@ re_types_builder.workspace = true # External rayon.workspace = true - +# `machete` is not a fan of `build-dependencies`. [package.metadata.cargo-machete] ignored = ["rayon", "re_build_tools", "re_types_builder"] diff --git a/crates/re_types_core/src/lib.rs b/crates/re_types_core/src/lib.rs index 9543e877c770..1000809a9338 100644 --- a/crates/re_types_core/src/lib.rs +++ b/crates/re_types_core/src/lib.rs @@ -1,8 +1,5 @@ //! The core types and traits that power Rerun's data model. //! -//! This crate contains both the IDL definitions for Rerun types (flatbuffers) as well as the code -//! generated from those using `re_types_builder`. -//! //! The [`Archetype`] trait is the core of this crate and is a good starting point to get familiar //! with the code. //! An archetype is a logical collection of batches of [`Component`]s that play well with each other. @@ -13,9 +10,6 @@ //! [`ComponentBatch`]: the atomic unit of (de)serialization. //! //! Internally, [`Component`]s are implemented using many different [`Datatype`]s. -//! -//! All builtin archetypes, components and datatypes can be found in their respective top-level -//! modules. // ---