diff --git a/Cargo.lock b/Cargo.lock index fdcc7b2249a6..2db60497efb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,30 +321,6 @@ dependencies = [ "strength_reduce", ] -[[package]] -name = "arrow2_convert" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e907cf50c3406c79e3a6f4c36d177df9ce99edb7e39ca448d947e6945725034e" -dependencies = [ - "arrow2", - "arrow2_convert_derive", - "chrono", - "err-derive", -] - -[[package]] -name = "arrow2_convert_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b159d799b7c3bec80793e79e2b7f49443b34313aa2cfe6002fb91a9bf28d90c" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ash" version = "0.37.3+1.3.251" @@ -1735,20 +1711,6 @@ dependencies = [ "serde", ] -[[package]] -name = "err-derive" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34a887c8df3ed90498c1c437ce21f211c8e27672921a8ffa293cb8d6d4caa9e" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "errno" version = "0.3.1" @@ -3769,30 +3731,6 @@ dependencies = [ "toml_edit", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.66" @@ -4299,8 +4237,8 @@ dependencies = [ "ahash 0.8.3", "anyhow", "arrow2", - "arrow2_convert", "backtrace", + "bytemuck", "crossbeam", "document-features", "fixed", @@ -4432,7 +4370,6 @@ version = "0.10.0-alpha.7+dev" dependencies = [ "ahash 0.8.3", "anyhow", - "arrow2_convert", "crossbeam", "document-features", "env_logger", @@ -5812,18 +5749,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "sysinfo" version = "0.29.0" diff --git a/crates/re_arrow_store/src/store.rs b/crates/re_arrow_store/src/store.rs index d67f4a1aa8a9..dbde24886c02 100644 --- a/crates/re_arrow_store/src/store.rs +++ b/crates/re_arrow_store/src/store.rs @@ -265,8 +265,8 @@ impl DataStore { /// dataframes. /// /// See [`DataStoreConfig::store_insert_ids`]. - pub fn insert_id_key() -> ComponentName { - "rerun.insert_id".into() + pub fn insert_id_component_name() -> ComponentName { + "rerun.controls.InsertId".into() } /// Return the current `StoreGeneration`. This can be used to determine whether the diff --git a/crates/re_arrow_store/src/store_arrow.rs b/crates/re_arrow_store/src/store_arrow.rs index fae89b7feacc..61f90fdce45a 100644 --- a/crates/re_arrow_store/src/store_arrow.rs +++ b/crates/re_arrow_store/src/store_arrow.rs @@ -2,10 +2,7 @@ use std::collections::BTreeMap; use arrow2::{array::Array, chunk::Chunk, datatypes::Schema}; use nohash_hasher::IntMap; -use re_log_types::{ - DataCellColumn, DataTable, DataTableResult, RowId, Timeline, COLUMN_INSERT_ID, - COLUMN_NUM_INSTANCES, -}; +use re_log_types::{DataCellColumn, DataTable, DataTableResult, NumInstances, RowId, Timeline}; use re_types_core::ComponentName; use crate::store::{IndexedBucket, IndexedBucketInner, PersistentIndexedTable}; @@ -93,7 +90,7 @@ fn serialize( col_time: Option<(Timeline, &[i64])>, col_insert_id: &[u64], col_row_id: &[RowId], - col_num_instances: &[u32], + col_num_instances: &[NumInstances], table: &IntMap, ) -> DataTableResult<(Schema, Chunk>)> { re_tracing::profile_function!(); @@ -128,7 +125,7 @@ fn serialize_control_columns( col_time: Option<(Timeline, &[i64])>, col_insert_id: &[u64], col_row_id: &[RowId], - col_num_instances: &[u32], + col_num_instances: &[NumInstances], ) -> DataTableResult<(Schema, Vec>)> { re_tracing::profile_function!(); @@ -143,8 +140,11 @@ fn serialize_control_columns( // NOTE: Optional column, so make sure it's actually there: if !col_insert_id.is_empty() { - let (insert_id_field, insert_id_column) = - DataTable::serialize_primitive_column(COLUMN_INSERT_ID, col_insert_id, None); + let (insert_id_field, insert_id_column) = DataTable::serialize_primitive_column( + &crate::DataStore::insert_id_component_name(), + col_insert_id, + None, + ); schema.fields.push(insert_id_field); columns.push(insert_id_column); } @@ -164,7 +164,7 @@ fn serialize_control_columns( } let (num_instances_field, num_instances_column) = - DataTable::serialize_primitive_column(COLUMN_NUM_INSTANCES, col_num_instances, None); + DataTable::serialize_control_column(col_num_instances)?; schema.fields.push(num_instances_field); columns.push(num_instances_column); diff --git a/crates/re_arrow_store/src/store_gc.rs b/crates/re_arrow_store/src/store_gc.rs index 054955dd2ddf..e05340136b08 100644 --- a/crates/re_arrow_store/src/store_gc.rs +++ b/crates/re_arrow_store/src/store_gc.rs @@ -373,7 +373,7 @@ impl DataStore { self.timeless_tables.retain(|_, table| { // If any column is non-empty, we need to keep this table for num in &table.col_num_instances { - if num != &0 { + if num.get() != 0 { return true; } } @@ -395,7 +395,7 @@ impl DataStore { for bucket in table.buckets.values() { let inner = bucket.inner.read(); for num in &inner.col_num_instances { - if num != &0 { + if num.get() != 0 { return true; } } diff --git a/crates/re_arrow_store/src/store_polars.rs b/crates/re_arrow_store/src/store_polars.rs index 2e29bfefb146..a58832113887 100644 --- a/crates/re_arrow_store/src/store_polars.rs +++ b/crates/re_arrow_store/src/store_polars.rs @@ -119,7 +119,7 @@ impl DataStore { let df = sort_df_columns(&df, self.config.store_insert_ids, &timelines); let has_timeless = df.column(TIMELESS_COL).is_ok(); - let insert_id_col = DataStore::insert_id_key(); + let insert_id_col = DataStore::insert_id_component_name(); const ASCENDING: bool = false; const DESCENDING: bool = true; @@ -264,7 +264,7 @@ fn insert_ids_as_series(col_insert_id: &InsertIdVec) -> Series { let insert_ids = arrow2::array::UInt64Array::from_slice(col_insert_id.as_slice()); new_infallible_series( - DataStore::insert_id_key().as_ref(), + DataStore::insert_id_component_name().as_ref(), &insert_ids, insert_ids.len(), ) diff --git a/crates/re_arrow_store/src/store_sanity.rs b/crates/re_arrow_store/src/store_sanity.rs index 028565104b98..71851459e911 100644 --- a/crates/re_arrow_store/src/store_sanity.rs +++ b/crates/re_arrow_store/src/store_sanity.rs @@ -1,4 +1,4 @@ -use re_log_types::{DataCellColumn, RowId, TimeRange, COLUMN_NUM_INSTANCES, COLUMN_TIMEPOINT}; +use re_log_types::{DataCellColumn, NumInstances, RowId, TimeRange}; use re_types_core::{ComponentName, Loggable, SizeBytes as _}; use crate::{DataStore, IndexedBucket, IndexedBucketInner, IndexedTable, PersistentIndexedTable}; @@ -184,14 +184,16 @@ impl IndexedBucket { // All columns should be `Self::num_rows` long. { + const COLUMN_TIMEPOINT: &str = "rerun.controls.TimePoint"; + let num_rows = self.num_rows(); let column_lengths = [ (!col_insert_id.is_empty()) - .then(|| (DataStore::insert_id_key(), col_insert_id.len())), // + .then(|| (DataStore::insert_id_component_name(), col_insert_id.len())), // Some((COLUMN_TIMEPOINT.into(), col_time.len())), Some((RowId::name(), col_row_id.len())), - Some((COLUMN_NUM_INSTANCES.into(), col_num_instances.len())), + Some((NumInstances::name(), col_num_instances.len())), ] .into_iter() .flatten() @@ -270,9 +272,9 @@ impl PersistentIndexedTable { let column_lengths = [ (!col_insert_id.is_empty()) - .then(|| (DataStore::insert_id_key(), col_insert_id.len())), // + .then(|| (DataStore::insert_id_component_name(), col_insert_id.len())), // Some((RowId::name(), col_row_id.len())), - Some((COLUMN_NUM_INSTANCES.into(), col_num_instances.len())), + Some((NumInstances::name(), col_num_instances.len())), ] .into_iter() .flatten() diff --git a/crates/re_arrow_store/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index ab5ac5f94055..ccc21ab95112 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -163,7 +163,7 @@ impl DataStore { // one… unless we've already generated one of this exact length in the past, // in which case we can simply re-use that cell. - Some(self.generate_cluster_cell(num_instances)) + Some(self.generate_cluster_cell(num_instances.into())) }; let insert_id = self.config.store_insert_ids.then_some(self.insert_id); diff --git a/crates/re_arrow_store/tests/data_store.rs b/crates/re_arrow_store/tests/data_store.rs index 47eb3e08a887..8bcb33ec57c0 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -810,7 +810,7 @@ fn joint_df(cluster_key: ComponentName, rows: &[(ComponentName, &DataRow)]) -> D let num_instances = row.num_instances(); Series::try_from(( cluster_key.as_ref(), - DataCell::from_component::(0..num_instances as u64) + DataCell::from_component::(0..num_instances.get() as u64) .to_arrow_monolist(), )) .unwrap() diff --git a/crates/re_log_types/Cargo.toml b/crates/re_log_types/Cargo.toml index 5c177b7ac111..cd0db137cf09 100644 --- a/crates/re_log_types/Cargo.toml +++ b/crates/re_log_types/Cargo.toml @@ -50,8 +50,8 @@ arrow2 = { workspace = true, features = [ "io_print", "compute_concatenate", ] } -arrow2_convert.workspace = true backtrace.workspace = true +bytemuck.workspace = true document-features.workspace = true fixed = { version = "1.17", default-features = false, features = ["serde"] } # `fixed` depends on `half`, so even though `half` is not directly used in this crate, diff --git a/crates/re_log_types/src/data_cell.rs b/crates/re_log_types/src/data_cell.rs index 96c0a46c45da..202cf6f6cb5e 100644 --- a/crates/re_log_types/src/data_cell.rs +++ b/crates/re_log_types/src/data_cell.rs @@ -71,7 +71,6 @@ pub type DataCellResult = ::std::result::Result; /// ## Example /// /// ```rust -/// # use arrow2_convert::field::ArrowField as _; /// # use itertools::Itertools as _; /// # /// # use re_log_types::DataCell; @@ -97,7 +96,7 @@ pub type DataCellResult = ::std::result::Result; /// # /// # assert_eq!(MyPoint::name(), cell.component_name()); /// # assert_eq!(3, cell.num_instances()); -/// # assert_eq!(cell.datatype(), &MyPoint::data_type()); +/// # assert_eq!(cell.datatype(), &MyPoint::arrow_datatype()); /// # /// # assert_eq!(points, cell.to_native().as_slice()); /// ``` @@ -157,7 +156,6 @@ pub struct DataCellInner { pub(crate) values: Box, } -// TODO(cmc): We should be able to build a cell from non-reference types. // TODO(#1696): We shouldn't have to specify the component name separately, this should be // part of the metadata by using an extension. // TODO(#1696): Check that the array is indeed a leaf / component type when building a cell from an @@ -232,6 +230,7 @@ impl DataCell { } /// Builds a cell from an iterable of items that can be turned into a [`Component`]. + #[inline] pub fn from_component<'a, C>(values: impl IntoIterator>) -> Self where C: Component + Clone + 'a, @@ -241,10 +240,7 @@ impl DataCell { } /// Builds a cell from an iterable of items that can be turned into a [`Component`]. - /// - /// ⚠ Due to quirks in `arrow2-convert`, this requires consuming and collecting the passed-in - /// iterator into a vector first. - /// Prefer [`Self::from_native`] when performance matters. + #[inline] pub fn from_component_sparse<'a, C>( values: impl IntoIterator>>, ) -> Self diff --git a/crates/re_log_types/src/data_row.rs b/crates/re_log_types/src/data_row.rs index b9e756725185..947add7a2758 100644 --- a/crates/re_log_types/src/data_row.rs +++ b/crates/re_log_types/src/data_row.rs @@ -4,7 +4,7 @@ use smallvec::SmallVec; use re_types_core::{AsComponents, ComponentName, SizeBytes}; -use crate::{DataCell, DataCellError, DataTable, EntityPath, TableId, TimePoint}; +use crate::{DataCell, DataCellError, DataTable, EntityPath, NumInstances, TableId, TimePoint}; // --- @@ -249,7 +249,7 @@ pub struct DataRow { /// - 0 instance (clear), /// - 1 instance (splat), /// - `num_instances` instances (standard). - pub num_instances: u32, + pub num_instances: NumInstances, /// The actual cells (== columns, == components). pub cells: DataCellRow, @@ -344,7 +344,7 @@ impl DataRow { row_id, entity_path, timepoint, - num_instances, + num_instances: num_instances.into(), cells, }) } @@ -401,7 +401,7 @@ impl DataRow { } #[inline] - pub fn num_instances(&self) -> u32 { + pub fn num_instances(&self) -> NumInstances { self.num_instances } diff --git a/crates/re_log_types/src/data_table.rs b/crates/re_log_types/src/data_table.rs index a1599ab1a8c8..a64f55032aab 100644 --- a/crates/re_log_types/src/data_table.rs +++ b/crates/re_log_types/src/data_table.rs @@ -9,7 +9,7 @@ use re_types_core::{ComponentName, Loggable, SizeBytes}; use crate::{ data_row::DataReadResult, ArrowMsg, DataCell, DataCellError, DataRow, DataRowError, EntityPath, - RowId, TimePoint, Timeline, + NumInstances, RowId, TimePoint, Timeline, }; // --- @@ -61,7 +61,7 @@ pub type ErasedTimeVec = SmallVec<[i64; 4]>; pub type EntityPathVec = SmallVec<[EntityPath; 4]>; -pub type NumInstancesVec = SmallVec<[u32; 4]>; +pub type NumInstancesVec = SmallVec<[NumInstances; 4]>; pub type DataCellOptVec = SmallVec<[Option; 4]>; @@ -481,7 +481,7 @@ impl DataTable { .collect::>(), ), col_entity_path[i].clone(), - col_num_instances[i], + col_num_instances[i].into(), cells, ) }) @@ -542,19 +542,7 @@ use arrow2::{ chunk::Chunk, datatypes::{DataType, Field, Schema, TimeUnit}, offset::Offsets, - types::NativeType, }; -use arrow2_convert::{ - deserialize::TryIntoCollection, field::ArrowField, serialize::ArrowSerialize, - serialize::TryIntoArrow, -}; - -// TODO(#1696): Those names should come from the datatypes themselves. - -pub const COLUMN_INSERT_ID: &str = "rerun.insert_id"; -pub const COLUMN_TIMEPOINT: &str = "rerun.timepoint"; -pub const COLUMN_ENTITY_PATH: &str = "rerun.entity_path"; -pub const COLUMN_NUM_INSTANCES: &str = "rerun.num_instances"; pub const METADATA_KIND: &str = "rerun.kind"; pub const METADATA_KIND_DATA: &str = "data"; @@ -667,15 +655,12 @@ impl DataTable { columns.push(row_id_column); let (entity_path_field, entity_path_column) = - Self::serialize_control_column_legacy(COLUMN_ENTITY_PATH, col_entity_path)?; + Self::serialize_control_column(col_entity_path)?; schema.fields.push(entity_path_field); columns.push(entity_path_column); - let (num_instances_field, num_instances_column) = Self::serialize_primitive_column( - COLUMN_NUM_INSTANCES, - col_num_instances.as_slice(), - None, - ); + let (num_instances_field, num_instances_column) = + Self::serialize_control_column(col_num_instances)?; schema.fields.push(num_instances_field); columns.push(num_instances_column); @@ -709,47 +694,8 @@ impl DataTable { Ok((field, data)) } - /// Serializes a single control column: an iterable of dense arrow-like data. - // TODO(#3741): remove once arrow2_convert is fully gone - pub fn serialize_control_column_legacy + 'static>( - name: &str, - values: &[C], - ) -> DataTableResult<(Field, Box)> { - re_tracing::profile_function!(); - - /// Transforms an array of unit values into a list of unit arrays. - /// - /// * Before: `[C, C, C, C, C, …]` - /// * After: `ListArray[ [C], [C], [C], [C], [C], … ]` - // NOTE: keeping that one around, just in case. - #[allow(dead_code)] - fn unit_values_to_unit_lists(array: Box) -> Box { - let datatype = array.data_type().clone(); - let datatype = ListArray::::default_datatype(datatype); - let offsets = Offsets::try_from_lengths(std::iter::repeat(1).take(array.len())) - .unwrap() - .into(); - let validity = None; - ListArray::::new(datatype, offsets, array, validity).boxed() - } - - let data: Box = values.try_into_arrow()?; - // let data = unit_values_to_unit_lists(data); - - let mut field = Field::new(name, data.data_type().clone(), false) - .with_metadata([(METADATA_KIND.to_owned(), METADATA_KIND_CONTROL.to_owned())].into()); - - if let DataType::Extension(name, _, _) = data.data_type() { - field - .metadata - .extend([("ARROW:extension:name".to_owned(), name.clone())]); - } - - Ok((field, data)) - } - /// Serializes a single control column; optimized path for primitive datatypes. - pub fn serialize_primitive_column( + pub fn serialize_primitive_column( name: &str, values: &[T], datatype: Option, @@ -946,11 +892,18 @@ impl DataTable { .unwrap() .as_ref(), )?; - let col_entity_path = - (&**chunk.get(control_index(COLUMN_ENTITY_PATH)?).unwrap()).try_into_collection()?; - // TODO(#3741): This is unnecessarily slow… - let col_num_instances = - (&**chunk.get(control_index(COLUMN_NUM_INSTANCES)?).unwrap()).try_into_collection()?; + let col_entity_path = EntityPath::from_arrow( + chunk + .get(control_index(EntityPath::name().as_str())?) + .unwrap() + .as_ref(), + )?; + let col_num_instances = NumInstances::from_arrow( + chunk + .get(control_index(NumInstances::name().as_str())?) + .unwrap() + .as_ref(), + )?; // --- Components --- @@ -980,8 +933,8 @@ impl DataTable { table_id, col_row_id: col_row_id.into(), col_timelines, - col_entity_path, - col_num_instances, + col_entity_path: col_entity_path.into(), + col_num_instances: col_num_instances.into(), columns, }) } diff --git a/crates/re_log_types/src/example_components.rs b/crates/re_log_types/src/example_components.rs index de340cf17e91..8d73548d5f49 100644 --- a/crates/re_log_types/src/example_components.rs +++ b/crates/re_log_types/src/example_components.rs @@ -1,7 +1,6 @@ //! Example components to be used for tests and docs -use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use re_types::Loggable as _; +use re_types::Loggable; // ---------------------------------------------------------------------------- @@ -25,7 +24,7 @@ impl re_types::Archetype for MyPoints { // ---------------------------------------------------------------------------- -#[derive(Clone, Debug, Default, ArrowField, ArrowSerialize, ArrowDeserialize, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct MyPoint { pub x: f32, pub y: f32, @@ -37,24 +36,79 @@ impl MyPoint { } } -use crate as re_log_types; +re_types::macros::impl_into_cow!(MyPoint); -re_log_types::arrow2convert_component_shim!(MyPoint as "test.Point2D"); +impl Loggable for MyPoint { + type Name = re_types::ComponentName; + + fn name() -> Self::Name { + "example.MyPoint".into() + } + + fn arrow_datatype() -> arrow2::datatypes::DataType { + use arrow2::datatypes::DataType::Float32; + arrow2::datatypes::DataType::Struct(vec![ + arrow2::datatypes::Field::new("x", Float32, false), + arrow2::datatypes::Field::new("y", Float32, false), + ]) + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + let (xs, ys): (Vec<_>, Vec<_>) = data + .into_iter() + .map(Option::unwrap) + .map(Into::into) + .map(|p| (p.x, p.y)) + .unzip(); + + let x_array = arrow2::array::Float32Array::from_vec(xs).boxed(); + let y_array = arrow2::array::Float32Array::from_vec(ys).boxed(); + + Ok( + arrow2::array::StructArray::new(Self::arrow_datatype(), vec![x_array, y_array], None) + .boxed(), + ) + } + + fn from_arrow_opt( + data: &dyn arrow2::array::Array, + ) -> re_types_core::DeserializationResult>> { + let array = data + .as_any() + .downcast_ref::() + .unwrap(); + + let x_array = array.values()[0].as_ref(); + let y_array = array.values()[1].as_ref(); + + let xs = x_array + .as_any() + .downcast_ref::() + .unwrap(); + let ys = y_array + .as_any() + .downcast_ref::() + .unwrap(); + + Ok(xs + .values_iter() + .copied() + .zip(ys.values_iter().copied()) + .map(|(x, y)| Self { x, y }) + .map(Some) + .collect()) + } +} // ---------------------------------------------------------------------------- -#[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - arrow2_convert::ArrowField, - arrow2_convert::ArrowSerialize, - arrow2_convert::ArrowDeserialize, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -#[arrow_field(transparent)] #[repr(transparent)] pub struct MyColor(pub u32); @@ -64,13 +118,82 @@ impl From for MyColor { } } -re_log_types::arrow2convert_component_shim!(MyColor as "test.Color"); +re_types::macros::impl_into_cow!(MyColor); + +impl Loggable for MyColor { + type Name = re_types::ComponentName; + + fn name() -> Self::Name { + "example.MyColor".into() + } + + fn arrow_datatype() -> arrow2::datatypes::DataType { + arrow2::datatypes::DataType::UInt32 + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + use re_types::datatypes::UInt32; + UInt32::to_arrow_opt( + data.into_iter() + .map(|opt| opt.map(Into::into).map(|c| UInt32(c.0))), + ) + } + + fn from_arrow_opt( + data: &dyn arrow2::array::Array, + ) -> re_types_core::DeserializationResult>> { + use re_types::datatypes::UInt32; + Ok(UInt32::from_arrow_opt(data)? + .into_iter() + .map(|opt| opt.map(|v| Self(v.0))) + .collect()) + } +} // ---------------------------------------------------------------------------- -#[derive(Debug, Clone, PartialEq, Eq, ArrowField, ArrowSerialize, ArrowDeserialize)] +#[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -#[arrow_field(transparent)] pub struct MyLabel(pub String); -re_log_types::arrow2convert_component_shim!(MyLabel as "test.Label"); +re_types::macros::impl_into_cow!(MyLabel); + +impl Loggable for MyLabel { + type Name = re_types::ComponentName; + + fn name() -> Self::Name { + "example.MyLabel".into() + } + + fn arrow_datatype() -> arrow2::datatypes::DataType { + re_types::datatypes::Utf8::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + use re_types::datatypes::Utf8; + Utf8::to_arrow_opt( + data.into_iter() + .map(|opt| opt.map(Into::into).map(|l| Utf8(l.0.clone().into()))), + ) + } + + fn from_arrow_opt( + data: &dyn arrow2::array::Array, + ) -> re_types_core::DeserializationResult>> { + use re_types::datatypes::Utf8; + Ok(Utf8::from_arrow_opt(data)? + .into_iter() + .map(|opt| opt.map(|v| Self(v.0.to_string()))) + .collect()) + } +} diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index 9bbea82d704a..e00c2a82a1c6 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -24,6 +24,7 @@ mod data_table; pub mod example_components; pub mod hash; mod index; +mod num_instances; pub mod path; mod time; pub mod time_point; @@ -33,9 +34,6 @@ mod time_real; #[cfg(not(target_arch = "wasm32"))] mod data_table_batcher; -#[cfg(feature = "serde")] -pub mod serde_field; - use std::sync::Arc; pub use self::arrow_msg::ArrowMsg; @@ -46,11 +44,11 @@ pub use self::data_row::{ }; pub use self::data_table::{ DataCellColumn, DataCellOptVec, DataTable, DataTableError, DataTableResult, EntityPathVec, - ErasedTimeVec, NumInstancesVec, RowIdVec, TableId, TimePointVec, COLUMN_ENTITY_PATH, - COLUMN_INSERT_ID, COLUMN_NUM_INSTANCES, COLUMN_TIMEPOINT, METADATA_KIND, METADATA_KIND_CONTROL, - METADATA_KIND_DATA, + ErasedTimeVec, NumInstancesVec, RowIdVec, TableId, TimePointVec, METADATA_KIND, + METADATA_KIND_CONTROL, METADATA_KIND_DATA, }; pub use self::index::*; +pub use self::num_instances::NumInstances; pub use self::path::*; pub use self::time::{Duration, Time, TimeZone}; pub use self::time_point::{TimeInt, TimePoint, TimeType, Timeline, TimelineName}; @@ -71,7 +69,6 @@ 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; @@ -398,82 +395,6 @@ impl PathOp { } } -// --------------------------------------------------------------------------- - -/// 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::Loggable for $entity { - type Name = ::re_types::ComponentName; - - #[inline] - fn name() -> Self::Name { - $fqname.into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - ::data_type() - } - - #[inline] - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> ::re_types::SerializationResult> - where - Self: Clone + 'a, - { - let input = data.into_iter().map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - datum.map(|d| d.into_owned()) - }); - - let vec: Vec<_> = input.collect(); - - let arrow = arrow2_convert::serialize::TryIntoArrow::try_into_arrow(vec.iter()) - .map_err(|err| { - ::re_types::SerializationError::ArrowConvertFailure(err.to_string()) - })?; - - Ok(arrow) - } - - #[inline] - fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> ::re_types::DeserializationResult>> - where - Self: Sized - { - let native = < - ::ArrayType as arrow2_convert::deserialize::ArrowArray - >::iter_from_array_ref(data); - Ok( - native - .into_iter() - .map(|item| ::arrow_deserialize(item)) - .collect() - ) - } - } - - impl<'a> From<$entity> for ::std::borrow::Cow<'a, $entity> { - #[inline] - fn from(value: $entity) -> Self { - std::borrow::Cow::Owned(value) - } - } - - impl<'a> From<&'a $entity> for ::std::borrow::Cow<'a, $entity> { - #[inline] - fn from(value: &'a $entity) -> Self { - std::borrow::Cow::Borrowed(value) - } - } - }; -} - // --- /// Build a ([`Timeline`], [`TimeInt`]) tuple from `log_time` suitable for inserting in a [`TimePoint`]. diff --git a/crates/re_log_types/src/num_instances.rs b/crates/re_log_types/src/num_instances.rs new file mode 100644 index 000000000000..093f1258f271 --- /dev/null +++ b/crates/re_log_types/src/num_instances.rs @@ -0,0 +1,87 @@ +use re_types_core::{Loggable, SizeBytes}; + +// --- + +/// Explicit number of instances in a [`crate::DataRow`]. +/// +/// Component batches in that row should have a length of either this number, zero (clear) or one (splat). +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, bytemuck::Pod, bytemuck::Zeroable)] +#[repr(transparent)] +pub struct NumInstances(pub u32); + +impl NumInstances { + #[inline] + pub fn get(self) -> u32 { + self.0 + } +} + +impl From for u32 { + #[inline] + fn from(val: NumInstances) -> Self { + val.0 + } +} + +impl From for NumInstances { + #[inline] + fn from(value: u32) -> Self { + Self(value) + } +} + +impl SizeBytes for NumInstances { + #[inline] + fn heap_size_bytes(&self) -> u64 { + 0 + } +} + +re_types_core::macros::impl_into_cow!(NumInstances); + +impl Loggable for NumInstances { + type Name = re_types_core::ComponentName; + + #[inline] + fn name() -> Self::Name { + "rerun.controls.NumInstances".into() + } + + #[inline] + fn arrow_datatype() -> arrow2::datatypes::DataType { + re_types::datatypes::UInt32::arrow_datatype() + } + + fn to_arrow_opt<'a>( + _data: impl IntoIterator>>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + Err(re_types_core::SerializationError::not_implemented( + Self::name(), + "NumInstances is never nullable, use `to_arrow()` instead", + )) + } + + #[inline] + fn to_arrow<'a>( + data: impl IntoIterator>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + use re_types::datatypes::UInt32; + UInt32::to_arrow(data.into_iter().map(Into::into).map(|c| UInt32(c.0))) + } + + fn from_arrow( + array: &dyn ::arrow2::array::Array, + ) -> re_types_core::DeserializationResult> { + use re_types::datatypes::UInt32; + Ok(UInt32::from_arrow(array)? + .into_iter() + .map(|v| Self(v.0)) + .collect()) + } +} diff --git a/crates/re_log_types/src/path/entity_path.rs b/crates/re_log_types/src/path/entity_path.rs index 2737b2837765..1b34a473f0ee 100644 --- a/crates/re_log_types/src/path/entity_path.rs +++ b/crates/re_log_types/src/path/entity_path.rs @@ -86,16 +86,6 @@ impl std::fmt::Debug for EntityPathHash { /// ]) /// ); /// ``` -/// -/// ``` -/// # use re_log_types::EntityPath; -/// # use arrow2_convert::field::ArrowField; -/// # use arrow2::datatypes::{DataType, Field}; -/// assert_eq!( -/// EntityPath::data_type(), -/// DataType::Extension("rerun.entity_path".into(), Box::new(DataType::Utf8), None), -/// ); -/// ``` #[derive(Clone, Eq)] pub struct EntityPath { /// precomputed hash @@ -256,55 +246,56 @@ impl From for String { // ---------------------------------------------------------------------------- -use arrow2::{ - array::{MutableUtf8ValuesArray, TryPush, Utf8Array}, - datatypes::DataType, - offset::Offsets, -}; -use arrow2_convert::{deserialize::ArrowDeserialize, field::ArrowField, serialize::ArrowSerialize}; +use re_types_core::Loggable; -arrow2_convert::arrow_enable_vec_for_type!(EntityPath); +re_types_core::macros::impl_into_cow!(EntityPath); -impl ArrowField for EntityPath { - type Type = Self; +impl Loggable for EntityPath { + type Name = re_types_core::ComponentName; #[inline] - fn data_type() -> DataType { - DataType::Extension( - "rerun.entity_path".to_owned(), - Box::new(DataType::Utf8), - None, - ) + fn name() -> Self::Name { + "rerun.controls.EntityPath".into() } -} - -impl ArrowSerialize for EntityPath { - type MutableArrayType = MutableUtf8ValuesArray; #[inline] - fn new_array() -> Self::MutableArrayType { - MutableUtf8ValuesArray::::try_new( - ::data_type(), - Offsets::new(), - Vec::::new(), - ) - .unwrap() // literally cannot fail + fn arrow_datatype() -> arrow2::datatypes::DataType { + re_types::datatypes::Utf8::arrow_datatype() } - fn arrow_serialize( - v: &::Type, - array: &mut Self::MutableArrayType, - ) -> arrow2::error::Result<()> { - array.try_push(v.to_string()) + fn to_arrow_opt<'a>( + _data: impl IntoIterator>>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + Err(re_types_core::SerializationError::not_implemented( + Self::name(), + "EntityPaths are never nullable, use `to_arrow()` instead", + )) } -} - -impl ArrowDeserialize for EntityPath { - type ArrayType = Utf8Array; #[inline] - fn arrow_deserialize(v: Option<&str>) -> Option { - v.map(Into::into) + fn to_arrow<'a>( + data: impl IntoIterator>>, + ) -> re_types_core::SerializationResult> + where + Self: 'a, + { + re_types::datatypes::Utf8::to_arrow( + data.into_iter() + .map(Into::into) + .map(|ent_path| re_types::datatypes::Utf8(ent_path.path.to_string().into())), + ) + } + + fn from_arrow( + array: &dyn ::arrow2::array::Array, + ) -> re_types_core::DeserializationResult> { + Ok(re_types::datatypes::Utf8::from_arrow(array)? + .into_iter() + .map(|utf8| Self::from(utf8.to_string())) + .collect()) } } diff --git a/crates/re_log_types/src/serde_field.rs b/crates/re_log_types/src/serde_field.rs deleted file mode 100644 index 269b1ad252f6..000000000000 --- a/crates/re_log_types/src/serde_field.rs +++ /dev/null @@ -1,123 +0,0 @@ -use arrow2::{ - array::{BinaryArray, MutableBinaryArray, TryPush}, - datatypes::DataType, -}; -use arrow2_convert::{deserialize::ArrowDeserialize, field::ArrowField, serialize::ArrowSerialize}; - -/// Helper for storing arbitrary serde-compatible types in an arrow2 [`BinaryArray`] field -/// -/// Use as: -/// ``` -/// use re_log_types::serde_field::SerdeField; -/// use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize, field::ArrowField}; -/// use arrow2::datatypes::{DataType, Field}; -/// -/// #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] -/// struct SomeStruct { -/// foo: String, -/// bar: u32, -/// } -/// -/// #[derive(Clone, Debug, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)] -/// #[arrow_field(transparent)] -/// struct SomeStructArrow(#[arrow_field(type = "SerdeField")] SomeStruct); -/// -/// assert_eq!(SomeStructArrow::data_type(), DataType::Binary); -/// ``` -pub struct SerdeField(std::marker::PhantomData); - -impl ArrowField for SerdeField -where - T: serde::ser::Serialize + serde::de::DeserializeOwned, -{ - type Type = T; - - #[inline] - fn data_type() -> DataType { - arrow2::datatypes::DataType::Binary - } -} - -impl ArrowSerialize for SerdeField -where - T: serde::ser::Serialize + serde::de::DeserializeOwned, -{ - type MutableArrayType = MutableBinaryArray; - #[inline] - fn new_array() -> Self::MutableArrayType { - MutableBinaryArray::new() - } - - fn arrow_serialize( - v: &::Type, - array: &mut Self::MutableArrayType, - ) -> arrow2::error::Result<()> { - re_tracing::profile_function!(); - let mut buf = Vec::new(); - rmp_serde::encode::write_named(&mut buf, v).map_err(|err| { - arrow2::error::Error::ExternalFormat(format!("Could not encode as rmp: {err}")) - })?; - array.try_push(Some(buf)) - } -} - -impl ArrowDeserialize for SerdeField -where - T: serde::ser::Serialize + serde::de::DeserializeOwned + Default, -{ - type ArrayType = BinaryArray; - - #[inline] - fn arrow_deserialize(v: <&Self::ArrayType as IntoIterator>::Item) -> Option { - re_tracing::profile_function!(); - Some( - v.and_then(|v| rmp_serde::from_slice::(v).ok()) - .unwrap_or_default(), - ) - } -} - -#[cfg(test)] -mod tests { - use super::SerdeField; - use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; - - #[derive(Clone, Debug, PartialEq, Default, serde::Deserialize, serde::Serialize)] - struct SomeStruct { - foo: String, - bar: u32, - } - - #[derive(Clone, Debug, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)] - struct SomeArrowStruct { - #[arrow_field(type = "SerdeField")] - field: SomeStruct, - } - - impl From for SomeArrowStruct { - fn from(s: SomeStruct) -> Self { - Self { field: s } - } - } - - #[test] - fn round_trip_serdefield() { - use arrow2_convert::{deserialize::TryIntoCollection, serialize::TryIntoArrow}; - - let data: [SomeArrowStruct; 2] = [ - SomeStruct { - foo: "hello".into(), - bar: 42, - } - .into(), - SomeStruct { - foo: "world".into(), - bar: 1983, - } - .into(), - ]; - let array: Box = data.try_into_arrow().unwrap(); - let ret: Vec = array.try_into_collection().unwrap(); - assert_eq!(&data, ret.as_slice()); - } -} diff --git a/crates/re_query/src/dataframe_util.rs b/crates/re_query/src/dataframe_util.rs index 8b6e1272f916..8532a7607340 100644 --- a/crates/re_query/src/dataframe_util.rs +++ b/crates/re_query/src/dataframe_util.rs @@ -8,7 +8,7 @@ use re_types_core::{components::InstanceKey, Archetype, Component, Loggable}; use crate::{ArchetypeView, ComponentWithInstances, QueryError}; -/// Make it so that our arrays can be deserialized again by arrow2-convert +/// Make it so that our arrays can be deserialized again by `polars`. fn fix_polars_nulls(array: &dyn Array) -> Box { // TODO(jleibs): This is an ugly work-around but gets our serializers // working again @@ -196,7 +196,7 @@ fn test_df_builder() { eprintln!("{df:?}"); // // ┌──────────────┬─────────────────┐ - // │ rerun.components.Radius ┆ rerun.components.Color │ + // │ Radius ┆ Color │ // │ --- ┆ --- │ // │ f32 ┆ u32 │ // ╞══════════════╪═════════════════╡ diff --git a/crates/re_sdk/Cargo.toml b/crates/re_sdk/Cargo.toml index b8f9d5765585..3275c59377a8 100644 --- a/crates/re_sdk/Cargo.toml +++ b/crates/re_sdk/Cargo.toml @@ -87,7 +87,6 @@ webbrowser = { workspace = true, optional = true } [dev-dependencies] re_types = { workspace = true, features = ["datagen"] } -arrow2_convert.workspace = true ndarray.workspace = true ndarray-rand.workspace = true rand.workspace = true diff --git a/crates/re_tuid/src/arrow.rs b/crates/re_tuid/src/arrow.rs index 5af31cd55190..ca3fc685048c 100644 --- a/crates/re_tuid/src/arrow.rs +++ b/crates/re_tuid/src/arrow.rs @@ -8,19 +8,7 @@ use crate::Tuid; // --- -impl<'a> From for ::std::borrow::Cow<'a, Tuid> { - #[inline] - fn from(value: Tuid) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Tuid> for ::std::borrow::Cow<'a, Tuid> { - #[inline] - fn from(value: &'a Tuid) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +re_types_core::macros::impl_into_cow!(Tuid); impl Loggable for Tuid { type Name = re_types_core::ComponentName; @@ -147,19 +135,7 @@ impl Loggable for Tuid { #[macro_export] macro_rules! delegate_arrow_tuid { ($typ:ident as $fqname:expr) => { - impl<'a> From<$typ> for ::std::borrow::Cow<'a, $typ> { - #[inline] - fn from(value: $typ) -> Self { - ::std::borrow::Cow::Owned(value) - } - } - - impl<'a> From<&'a $typ> for ::std::borrow::Cow<'a, $typ> { - #[inline] - fn from(value: &'a $typ) -> Self { - ::std::borrow::Cow::Borrowed(value) - } - } + ::re_types_core::macros::impl_into_cow!($typ); impl ::re_types_core::Loggable for $typ { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/definitions/rerun/datatypes.fbs b/crates/re_types/definitions/rerun/datatypes.fbs index bf0ca804fdde..36a5fd4a1e46 100644 --- a/crates/re_types/definitions/rerun/datatypes.fbs +++ b/crates/re_types/definitions/rerun/datatypes.fbs @@ -1,19 +1,19 @@ include "./datatypes/angle.fbs"; include "./datatypes/annotation_info.fbs"; -include "./datatypes/class_description_map_elem.fbs"; include "./datatypes/class_description.fbs"; +include "./datatypes/class_description_map_elem.fbs"; include "./datatypes/class_id.fbs"; include "./datatypes/float32.fbs"; include "./datatypes/keypoint_id.fbs"; include "./datatypes/keypoint_pair.fbs"; include "./datatypes/mat3x3.fbs"; include "./datatypes/mat4x4.fbs"; -include "./datatypes/material.fbs"; // Must come after rgba32.fbs +include "./datatypes/material.fbs"; include "./datatypes/mesh_properties.fbs"; include "./datatypes/quaternion.fbs"; include "./datatypes/rgba32.fbs"; -include "./datatypes/rotation_axis_angle.fbs"; include "./datatypes/rotation3d.fbs"; +include "./datatypes/rotation_axis_angle.fbs"; include "./datatypes/scale3d.fbs"; include "./datatypes/tensor_buffer.fbs"; include "./datatypes/tensor_data.fbs"; @@ -21,6 +21,7 @@ include "./datatypes/tensor_dimension.fbs"; include "./datatypes/transform3d.fbs"; include "./datatypes/translation_and_mat3x3.fbs"; include "./datatypes/translation_rotation_scale3d.fbs"; +include "./datatypes/uint32.fbs"; include "./datatypes/utf8.fbs"; include "./datatypes/uvec2d.fbs"; include "./datatypes/uvec3d.fbs"; diff --git a/crates/re_types/definitions/rerun/datatypes/float32.fbs b/crates/re_types/definitions/rerun/datatypes/float32.fbs index c8488aa54af3..758d98e19086 100644 --- a/crates/re_types/definitions/rerun/datatypes/float32.fbs +++ b/crates/re_types/definitions/rerun/datatypes/float32.fbs @@ -9,6 +9,7 @@ namespace rerun.datatypes; struct Float32 ( "attr.arrow.transparent", "attr.rust.derive": "Copy, PartialEq, PartialOrd", + "attr.rust.override_crate": "re_types_core", "attr.rust.tuple_struct" ) { value: float (order: 100); diff --git a/crates/re_types/definitions/rerun/datatypes/uint32.fbs b/crates/re_types/definitions/rerun/datatypes/uint32.fbs new file mode 100644 index 000000000000..be704fcfaa03 --- /dev/null +++ b/crates/re_types/definitions/rerun/datatypes/uint32.fbs @@ -0,0 +1,16 @@ +include "arrow/attributes.fbs"; +include "python/attributes.fbs"; +include "fbs/attributes.fbs"; +include "rust/attributes.fbs"; + +namespace rerun.datatypes; + +/// A 32bit unsigned integer. +struct UInt32 ( + "attr.arrow.transparent", + "attr.rust.derive": "Copy, PartialEq, Eq, PartialOrd, Ord", + "attr.rust.override_crate": "re_types_core", + "attr.rust.tuple_struct" +) { + value: uint32 (order: 100); +} diff --git a/crates/re_types/definitions/rerun/datatypes/utf8.fbs b/crates/re_types/definitions/rerun/datatypes/utf8.fbs index 005116588c10..7f42f283df25 100644 --- a/crates/re_types/definitions/rerun/datatypes/utf8.fbs +++ b/crates/re_types/definitions/rerun/datatypes/utf8.fbs @@ -15,6 +15,7 @@ table Utf8 ( "attr.python.aliases": "str", "attr.python.array_aliases": "str, Sequence[str]", "attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash", + "attr.rust.override_crate": "re_types_core", "attr.rust.repr": "transparent", "attr.rust.tuple_struct" ) { diff --git a/crates/re_types/src/components/annotation_context.rs b/crates/re_types/src/components/annotation_context.rs index 16e63c1ab56d..b603b98a4bef 100644 --- a/crates/re_types/src/components/annotation_context.rs +++ b/crates/re_types/src/components/annotation_context.rs @@ -42,19 +42,7 @@ impl, T: IntoIterator From for ::std::borrow::Cow<'a, AnnotationContext> { - #[inline] - fn from(value: AnnotationContext) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AnnotationContext> for ::std::borrow::Cow<'a, AnnotationContext> { - #[inline] - fn from(value: &'a AnnotationContext) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AnnotationContext); impl ::re_types_core::Loggable for AnnotationContext { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/blob.rs b/crates/re_types/src/components/blob.rs index 3307166de4e1..4511ec01372c 100644 --- a/crates/re_types/src/components/blob.rs +++ b/crates/re_types/src/components/blob.rs @@ -40,19 +40,7 @@ impl From for ::re_types_core::ArrowBuffer { } } -impl<'a> From for ::std::borrow::Cow<'a, Blob> { - #[inline] - fn from(value: Blob) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Blob> for ::std::borrow::Cow<'a, Blob> { - #[inline] - fn from(value: &'a Blob) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Blob); impl ::re_types_core::Loggable for Blob { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/class_id.rs b/crates/re_types/src/components/class_id.rs index a6b3359afa56..f23b5f66ee50 100644 --- a/crates/re_types/src/components/class_id.rs +++ b/crates/re_types/src/components/class_id.rs @@ -53,19 +53,7 @@ impl std::ops::Deref for ClassId { } } -impl<'a> From for ::std::borrow::Cow<'a, ClassId> { - #[inline] - fn from(value: ClassId) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ClassId> for ::std::borrow::Cow<'a, ClassId> { - #[inline] - fn from(value: &'a ClassId) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ClassId); impl ::re_types_core::Loggable for ClassId { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/color.rs b/crates/re_types/src/components/color.rs index 4a45ad6d7d4a..ee370e6a5117 100644 --- a/crates/re_types/src/components/color.rs +++ b/crates/re_types/src/components/color.rs @@ -51,19 +51,7 @@ impl std::ops::Deref for Color { } } -impl<'a> From for ::std::borrow::Cow<'a, Color> { - #[inline] - fn from(value: Color) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Color> for ::std::borrow::Cow<'a, Color> { - #[inline] - fn from(value: &'a Color) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Color); impl ::re_types_core::Loggable for Color { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/depth_meter.rs b/crates/re_types/src/components/depth_meter.rs index 7069d2c4d245..88628ac20a21 100644 --- a/crates/re_types/src/components/depth_meter.rs +++ b/crates/re_types/src/components/depth_meter.rs @@ -40,19 +40,7 @@ impl From for f32 { } } -impl<'a> From for ::std::borrow::Cow<'a, DepthMeter> { - #[inline] - fn from(value: DepthMeter) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a DepthMeter> for ::std::borrow::Cow<'a, DepthMeter> { - #[inline] - fn from(value: &'a DepthMeter) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(DepthMeter); impl ::re_types_core::Loggable for DepthMeter { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/disconnected_space.rs b/crates/re_types/src/components/disconnected_space.rs index 68d720cd0d13..dfffd63a91e2 100644 --- a/crates/re_types/src/components/disconnected_space.rs +++ b/crates/re_types/src/components/disconnected_space.rs @@ -46,19 +46,7 @@ impl From for bool { } } -impl<'a> From for ::std::borrow::Cow<'a, DisconnectedSpace> { - #[inline] - fn from(value: DisconnectedSpace) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a DisconnectedSpace> for ::std::borrow::Cow<'a, DisconnectedSpace> { - #[inline] - fn from(value: &'a DisconnectedSpace) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(DisconnectedSpace); impl ::re_types_core::Loggable for DisconnectedSpace { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/draw_order.rs b/crates/re_types/src/components/draw_order.rs index b071a3b15c92..dd255b765294 100644 --- a/crates/re_types/src/components/draw_order.rs +++ b/crates/re_types/src/components/draw_order.rs @@ -46,19 +46,7 @@ impl From for f32 { } } -impl<'a> From for ::std::borrow::Cow<'a, DrawOrder> { - #[inline] - fn from(value: DrawOrder) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a DrawOrder> for ::std::borrow::Cow<'a, DrawOrder> { - #[inline] - fn from(value: &'a DrawOrder) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(DrawOrder); impl ::re_types_core::Loggable for DrawOrder { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/half_sizes2d.rs b/crates/re_types/src/components/half_sizes2d.rs index 3a0c603b3c61..63fbc3f7f070 100644 --- a/crates/re_types/src/components/half_sizes2d.rs +++ b/crates/re_types/src/components/half_sizes2d.rs @@ -50,19 +50,7 @@ impl std::ops::Deref for HalfSizes2D { } } -impl<'a> From for ::std::borrow::Cow<'a, HalfSizes2D> { - #[inline] - fn from(value: HalfSizes2D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a HalfSizes2D> for ::std::borrow::Cow<'a, HalfSizes2D> { - #[inline] - fn from(value: &'a HalfSizes2D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(HalfSizes2D); impl ::re_types_core::Loggable for HalfSizes2D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/half_sizes3d.rs b/crates/re_types/src/components/half_sizes3d.rs index 007238f72581..0dc82b717400 100644 --- a/crates/re_types/src/components/half_sizes3d.rs +++ b/crates/re_types/src/components/half_sizes3d.rs @@ -50,19 +50,7 @@ impl std::ops::Deref for HalfSizes3D { } } -impl<'a> From for ::std::borrow::Cow<'a, HalfSizes3D> { - #[inline] - fn from(value: HalfSizes3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a HalfSizes3D> for ::std::borrow::Cow<'a, HalfSizes3D> { - #[inline] - fn from(value: &'a HalfSizes3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(HalfSizes3D); impl ::re_types_core::Loggable for HalfSizes3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/keypoint_id.rs b/crates/re_types/src/components/keypoint_id.rs index b7a711072223..25f40fd40b30 100644 --- a/crates/re_types/src/components/keypoint_id.rs +++ b/crates/re_types/src/components/keypoint_id.rs @@ -55,19 +55,7 @@ impl std::ops::Deref for KeypointId { } } -impl<'a> From for ::std::borrow::Cow<'a, KeypointId> { - #[inline] - fn from(value: KeypointId) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a KeypointId> for ::std::borrow::Cow<'a, KeypointId> { - #[inline] - fn from(value: &'a KeypointId) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(KeypointId); impl ::re_types_core::Loggable for KeypointId { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/line_strip2d.rs b/crates/re_types/src/components/line_strip2d.rs index a88dcfd38dbd..5d7340bafda8 100644 --- a/crates/re_types/src/components/line_strip2d.rs +++ b/crates/re_types/src/components/line_strip2d.rs @@ -42,19 +42,7 @@ impl, T: IntoIterator> From for Li } } -impl<'a> From for ::std::borrow::Cow<'a, LineStrip2D> { - #[inline] - fn from(value: LineStrip2D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a LineStrip2D> for ::std::borrow::Cow<'a, LineStrip2D> { - #[inline] - fn from(value: &'a LineStrip2D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(LineStrip2D); impl ::re_types_core::Loggable for LineStrip2D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/line_strip3d.rs b/crates/re_types/src/components/line_strip3d.rs index dd1f39f16523..04abff3990ad 100644 --- a/crates/re_types/src/components/line_strip3d.rs +++ b/crates/re_types/src/components/line_strip3d.rs @@ -42,19 +42,7 @@ impl, T: IntoIterator> From for Li } } -impl<'a> From for ::std::borrow::Cow<'a, LineStrip3D> { - #[inline] - fn from(value: LineStrip3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a LineStrip3D> for ::std::borrow::Cow<'a, LineStrip3D> { - #[inline] - fn from(value: &'a LineStrip3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(LineStrip3D); impl ::re_types_core::Loggable for LineStrip3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/material.rs b/crates/re_types/src/components/material.rs index db1cf90c1165..cfd0700fa59e 100644 --- a/crates/re_types/src/components/material.rs +++ b/crates/re_types/src/components/material.rs @@ -47,19 +47,7 @@ impl std::ops::Deref for Material { } } -impl<'a> From for ::std::borrow::Cow<'a, Material> { - #[inline] - fn from(value: Material) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Material> for ::std::borrow::Cow<'a, Material> { - #[inline] - fn from(value: &'a Material) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Material); impl ::re_types_core::Loggable for Material { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/media_type.rs b/crates/re_types/src/components/media_type.rs index ba7143b96be7..1982d9395bc9 100644 --- a/crates/re_types/src/components/media_type.rs +++ b/crates/re_types/src/components/media_type.rs @@ -51,19 +51,7 @@ impl std::ops::Deref for MediaType { } } -impl<'a> From for ::std::borrow::Cow<'a, MediaType> { - #[inline] - fn from(value: MediaType) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a MediaType> for ::std::borrow::Cow<'a, MediaType> { - #[inline] - fn from(value: &'a MediaType) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(MediaType); impl ::re_types_core::Loggable for MediaType { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/mesh_properties.rs b/crates/re_types/src/components/mesh_properties.rs index 302030fbbf41..632554e00e68 100644 --- a/crates/re_types/src/components/mesh_properties.rs +++ b/crates/re_types/src/components/mesh_properties.rs @@ -47,19 +47,7 @@ impl std::ops::Deref for MeshProperties { } } -impl<'a> From for ::std::borrow::Cow<'a, MeshProperties> { - #[inline] - fn from(value: MeshProperties) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a MeshProperties> for ::std::borrow::Cow<'a, MeshProperties> { - #[inline] - fn from(value: &'a MeshProperties) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(MeshProperties); impl ::re_types_core::Loggable for MeshProperties { type Name = ::re_types_core::ComponentName; 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 7156d8e74fc3..b7d9e69bf830 100644 --- a/crates/re_types/src/components/out_of_tree_transform3d.rs +++ b/crates/re_types/src/components/out_of_tree_transform3d.rs @@ -52,19 +52,7 @@ impl std::ops::Deref for OutOfTreeTransform3D { } } -impl<'a> From for ::std::borrow::Cow<'a, OutOfTreeTransform3D> { - #[inline] - fn from(value: OutOfTreeTransform3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a OutOfTreeTransform3D> for ::std::borrow::Cow<'a, OutOfTreeTransform3D> { - #[inline] - fn from(value: &'a OutOfTreeTransform3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(OutOfTreeTransform3D); impl ::re_types_core::Loggable for OutOfTreeTransform3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/pinhole_projection.rs b/crates/re_types/src/components/pinhole_projection.rs index 272fdd526cfe..999b088707ee 100644 --- a/crates/re_types/src/components/pinhole_projection.rs +++ b/crates/re_types/src/components/pinhole_projection.rs @@ -57,19 +57,7 @@ impl std::ops::Deref for PinholeProjection { } } -impl<'a> From for ::std::borrow::Cow<'a, PinholeProjection> { - #[inline] - fn from(value: PinholeProjection) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a PinholeProjection> for ::std::borrow::Cow<'a, PinholeProjection> { - #[inline] - fn from(value: &'a PinholeProjection) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(PinholeProjection); impl ::re_types_core::Loggable for PinholeProjection { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/position2d.rs b/crates/re_types/src/components/position2d.rs index 2c2ca1e47977..9be559a57bcb 100644 --- a/crates/re_types/src/components/position2d.rs +++ b/crates/re_types/src/components/position2d.rs @@ -48,19 +48,7 @@ impl std::ops::Deref for Position2D { } } -impl<'a> From for ::std::borrow::Cow<'a, Position2D> { - #[inline] - fn from(value: Position2D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Position2D> for ::std::borrow::Cow<'a, Position2D> { - #[inline] - fn from(value: &'a Position2D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Position2D); impl ::re_types_core::Loggable for Position2D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/position3d.rs b/crates/re_types/src/components/position3d.rs index 9e17459e3bc2..9e7a4f695769 100644 --- a/crates/re_types/src/components/position3d.rs +++ b/crates/re_types/src/components/position3d.rs @@ -48,19 +48,7 @@ impl std::ops::Deref for Position3D { } } -impl<'a> From for ::std::borrow::Cow<'a, Position3D> { - #[inline] - fn from(value: Position3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Position3D> for ::std::borrow::Cow<'a, Position3D> { - #[inline] - fn from(value: &'a Position3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Position3D); impl ::re_types_core::Loggable for Position3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/radius.rs b/crates/re_types/src/components/radius.rs index 81de7ce84fff..0d3c26af3936 100644 --- a/crates/re_types/src/components/radius.rs +++ b/crates/re_types/src/components/radius.rs @@ -40,19 +40,7 @@ impl From for f32 { } } -impl<'a> From for ::std::borrow::Cow<'a, Radius> { - #[inline] - fn from(value: Radius) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Radius> for ::std::borrow::Cow<'a, Radius> { - #[inline] - fn from(value: &'a Radius) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Radius); impl ::re_types_core::Loggable for Radius { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/resolution.rs b/crates/re_types/src/components/resolution.rs index f79a7d7f35e4..4a336b59f556 100644 --- a/crates/re_types/src/components/resolution.rs +++ b/crates/re_types/src/components/resolution.rs @@ -49,19 +49,7 @@ impl std::ops::Deref for Resolution { } } -impl<'a> From for ::std::borrow::Cow<'a, Resolution> { - #[inline] - fn from(value: Resolution) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Resolution> for ::std::borrow::Cow<'a, Resolution> { - #[inline] - fn from(value: &'a Resolution) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Resolution); impl ::re_types_core::Loggable for Resolution { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/rotation3d.rs b/crates/re_types/src/components/rotation3d.rs index f8b6750e3f0b..5278ec14e339 100644 --- a/crates/re_types/src/components/rotation3d.rs +++ b/crates/re_types/src/components/rotation3d.rs @@ -50,19 +50,7 @@ impl std::ops::Deref for Rotation3D { } } -impl<'a> From for ::std::borrow::Cow<'a, Rotation3D> { - #[inline] - fn from(value: Rotation3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Rotation3D> for ::std::borrow::Cow<'a, Rotation3D> { - #[inline] - fn from(value: &'a Rotation3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Rotation3D); impl ::re_types_core::Loggable for Rotation3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/scalar.rs b/crates/re_types/src/components/scalar.rs index 8d9d9ceaf46d..ca8b9baaf712 100644 --- a/crates/re_types/src/components/scalar.rs +++ b/crates/re_types/src/components/scalar.rs @@ -42,19 +42,7 @@ impl From for f64 { } } -impl<'a> From for ::std::borrow::Cow<'a, Scalar> { - #[inline] - fn from(value: Scalar) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Scalar> for ::std::borrow::Cow<'a, Scalar> { - #[inline] - fn from(value: &'a Scalar) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Scalar); impl ::re_types_core::Loggable for Scalar { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/scalar_scattering.rs b/crates/re_types/src/components/scalar_scattering.rs index cc532077904a..080c1811ec12 100644 --- a/crates/re_types/src/components/scalar_scattering.rs +++ b/crates/re_types/src/components/scalar_scattering.rs @@ -39,19 +39,7 @@ impl From for bool { } } -impl<'a> From for ::std::borrow::Cow<'a, ScalarScattering> { - #[inline] - fn from(value: ScalarScattering) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ScalarScattering> for ::std::borrow::Cow<'a, ScalarScattering> { - #[inline] - fn from(value: &'a ScalarScattering) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ScalarScattering); impl ::re_types_core::Loggable for ScalarScattering { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/tensor_data.rs b/crates/re_types/src/components/tensor_data.rs index 0e7cd8816979..da59c30eea91 100644 --- a/crates/re_types/src/components/tensor_data.rs +++ b/crates/re_types/src/components/tensor_data.rs @@ -48,19 +48,7 @@ impl std::ops::Deref for TensorData { } } -impl<'a> From for ::std::borrow::Cow<'a, TensorData> { - #[inline] - fn from(value: TensorData) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TensorData> for ::std::borrow::Cow<'a, TensorData> { - #[inline] - fn from(value: &'a TensorData) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TensorData); impl ::re_types_core::Loggable for TensorData { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/text.rs b/crates/re_types/src/components/text.rs index d17874ebb76a..dfe3b93b7679 100644 --- a/crates/re_types/src/components/text.rs +++ b/crates/re_types/src/components/text.rs @@ -48,19 +48,7 @@ impl std::ops::Deref for Text { } } -impl<'a> From for ::std::borrow::Cow<'a, Text> { - #[inline] - fn from(value: Text) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Text> for ::std::borrow::Cow<'a, Text> { - #[inline] - fn from(value: &'a Text) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Text); impl ::re_types_core::Loggable for Text { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/text_log_level.rs b/crates/re_types/src/components/text_log_level.rs index 7caddac71e88..c7ac8cd5dfde 100644 --- a/crates/re_types/src/components/text_log_level.rs +++ b/crates/re_types/src/components/text_log_level.rs @@ -56,19 +56,7 @@ impl std::ops::Deref for TextLogLevel { } } -impl<'a> From for ::std::borrow::Cow<'a, TextLogLevel> { - #[inline] - fn from(value: TextLogLevel) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TextLogLevel> for ::std::borrow::Cow<'a, TextLogLevel> { - #[inline] - fn from(value: &'a TextLogLevel) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TextLogLevel); impl ::re_types_core::Loggable for TextLogLevel { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/transform3d.rs b/crates/re_types/src/components/transform3d.rs index 6bd6d3e28fa5..d736110314c3 100644 --- a/crates/re_types/src/components/transform3d.rs +++ b/crates/re_types/src/components/transform3d.rs @@ -50,19 +50,7 @@ impl std::ops::Deref for Transform3D { } } -impl<'a> From for ::std::borrow::Cow<'a, Transform3D> { - #[inline] - fn from(value: Transform3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Transform3D> for ::std::borrow::Cow<'a, Transform3D> { - #[inline] - fn from(value: &'a Transform3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Transform3D); impl ::re_types_core::Loggable for Transform3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/vector3d.rs b/crates/re_types/src/components/vector3d.rs index acfd014716d2..e54339823f12 100644 --- a/crates/re_types/src/components/vector3d.rs +++ b/crates/re_types/src/components/vector3d.rs @@ -48,19 +48,7 @@ impl std::ops::Deref for Vector3D { } } -impl<'a> From for ::std::borrow::Cow<'a, Vector3D> { - #[inline] - fn from(value: Vector3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Vector3D> for ::std::borrow::Cow<'a, Vector3D> { - #[inline] - fn from(value: &'a Vector3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Vector3D); impl ::re_types_core::Loggable for Vector3D { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/components/view_coordinates.rs b/crates/re_types/src/components/view_coordinates.rs index 430ad722beaf..4e4de29c77d5 100644 --- a/crates/re_types/src/components/view_coordinates.rs +++ b/crates/re_types/src/components/view_coordinates.rs @@ -58,19 +58,7 @@ impl From for [u8; 3usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, ViewCoordinates> { - #[inline] - fn from(value: ViewCoordinates) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ViewCoordinates> for ::std::borrow::Cow<'a, ViewCoordinates> { - #[inline] - fn from(value: &'a ViewCoordinates) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ViewCoordinates); impl ::re_types_core::Loggable for ViewCoordinates { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/datatypes/.gitattributes b/crates/re_types/src/datatypes/.gitattributes index fef3075e51ac..77abd8451886 100644 --- a/crates/re_types/src/datatypes/.gitattributes +++ b/crates/re_types/src/datatypes/.gitattributes @@ -6,7 +6,6 @@ annotation_info.rs linguist-generated=true class_description.rs linguist-generated=true class_description_map_elem.rs linguist-generated=true class_id.rs linguist-generated=true -float32.rs linguist-generated=true keypoint_id.rs linguist-generated=true keypoint_pair.rs linguist-generated=true mat3x3.rs linguist-generated=true @@ -25,7 +24,6 @@ tensor_dimension.rs linguist-generated=true transform3d.rs linguist-generated=true translation_and_mat3x3.rs linguist-generated=true translation_rotation_scale3d.rs linguist-generated=true -utf8.rs linguist-generated=true uvec2d.rs linguist-generated=true uvec3d.rs linguist-generated=true uvec4d.rs linguist-generated=true diff --git a/crates/re_types/src/datatypes/angle.rs b/crates/re_types/src/datatypes/angle.rs index ab7266c0a724..665560084518 100644 --- a/crates/re_types/src/datatypes/angle.rs +++ b/crates/re_types/src/datatypes/angle.rs @@ -28,19 +28,7 @@ pub enum Angle { Degrees(f32), } -impl<'a> From for ::std::borrow::Cow<'a, Angle> { - #[inline] - fn from(value: Angle) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Angle> for ::std::borrow::Cow<'a, Angle> { - #[inline] - fn from(value: &'a Angle) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Angle); impl ::re_types_core::Loggable for Angle { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/annotation_info.rs b/crates/re_types/src/datatypes/annotation_info.rs index 76e8da3d467d..851866c60051 100644 --- a/crates/re_types/src/datatypes/annotation_info.rs +++ b/crates/re_types/src/datatypes/annotation_info.rs @@ -37,19 +37,7 @@ pub struct AnnotationInfo { pub color: Option, } -impl<'a> From for ::std::borrow::Cow<'a, AnnotationInfo> { - #[inline] - fn from(value: AnnotationInfo) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AnnotationInfo> for ::std::borrow::Cow<'a, AnnotationInfo> { - #[inline] - fn from(value: &'a AnnotationInfo) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AnnotationInfo); impl ::re_types_core::Loggable for AnnotationInfo { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/class_description.rs b/crates/re_types/src/datatypes/class_description.rs index d5d60b3fadd3..b5b8fb240835 100644 --- a/crates/re_types/src/datatypes/class_description.rs +++ b/crates/re_types/src/datatypes/class_description.rs @@ -47,19 +47,7 @@ pub struct ClassDescription { pub keypoint_connections: Vec, } -impl<'a> From for ::std::borrow::Cow<'a, ClassDescription> { - #[inline] - fn from(value: ClassDescription) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ClassDescription> for ::std::borrow::Cow<'a, ClassDescription> { - #[inline] - fn from(value: &'a ClassDescription) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ClassDescription); impl ::re_types_core::Loggable for ClassDescription { type Name = ::re_types_core::DatatypeName; 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 74baccf10c59..614754ed72f6 100644 --- a/crates/re_types/src/datatypes/class_description_map_elem.rs +++ b/crates/re_types/src/datatypes/class_description_map_elem.rs @@ -33,19 +33,7 @@ pub struct ClassDescriptionMapElem { pub class_description: crate::datatypes::ClassDescription, } -impl<'a> From for ::std::borrow::Cow<'a, ClassDescriptionMapElem> { - #[inline] - fn from(value: ClassDescriptionMapElem) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ClassDescriptionMapElem> for ::std::borrow::Cow<'a, ClassDescriptionMapElem> { - #[inline] - fn from(value: &'a ClassDescriptionMapElem) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ClassDescriptionMapElem); impl ::re_types_core::Loggable for ClassDescriptionMapElem { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/class_id.rs b/crates/re_types/src/datatypes/class_id.rs index 6db7ebf0ab47..134a69e583ef 100644 --- a/crates/re_types/src/datatypes/class_id.rs +++ b/crates/re_types/src/datatypes/class_id.rs @@ -55,19 +55,7 @@ impl From for u16 { } } -impl<'a> From for ::std::borrow::Cow<'a, ClassId> { - #[inline] - fn from(value: ClassId) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ClassId> for ::std::borrow::Cow<'a, ClassId> { - #[inline] - fn from(value: &'a ClassId) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ClassId); impl ::re_types_core::Loggable for ClassId { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/keypoint_id.rs b/crates/re_types/src/datatypes/keypoint_id.rs index de818f742461..cc348d98a095 100644 --- a/crates/re_types/src/datatypes/keypoint_id.rs +++ b/crates/re_types/src/datatypes/keypoint_id.rs @@ -57,19 +57,7 @@ impl From for u16 { } } -impl<'a> From for ::std::borrow::Cow<'a, KeypointId> { - #[inline] - fn from(value: KeypointId) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a KeypointId> for ::std::borrow::Cow<'a, KeypointId> { - #[inline] - fn from(value: &'a KeypointId) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(KeypointId); impl ::re_types_core::Loggable for KeypointId { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/keypoint_pair.rs b/crates/re_types/src/datatypes/keypoint_pair.rs index 0c9671c0b5e4..345fae55d987 100644 --- a/crates/re_types/src/datatypes/keypoint_pair.rs +++ b/crates/re_types/src/datatypes/keypoint_pair.rs @@ -31,19 +31,7 @@ pub struct KeypointPair { pub keypoint1: crate::datatypes::KeypointId, } -impl<'a> From for ::std::borrow::Cow<'a, KeypointPair> { - #[inline] - fn from(value: KeypointPair) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a KeypointPair> for ::std::borrow::Cow<'a, KeypointPair> { - #[inline] - fn from(value: &'a KeypointPair) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(KeypointPair); impl ::re_types_core::Loggable for KeypointPair { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/mat3x3.rs b/crates/re_types/src/datatypes/mat3x3.rs index 79f90175aa11..172a074a892b 100644 --- a/crates/re_types/src/datatypes/mat3x3.rs +++ b/crates/re_types/src/datatypes/mat3x3.rs @@ -51,19 +51,7 @@ impl From for [f32; 9usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Mat3x3> { - #[inline] - fn from(value: Mat3x3) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Mat3x3> for ::std::borrow::Cow<'a, Mat3x3> { - #[inline] - fn from(value: &'a Mat3x3) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Mat3x3); impl ::re_types_core::Loggable for Mat3x3 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/mat4x4.rs b/crates/re_types/src/datatypes/mat4x4.rs index e2d49ae3131e..a66603f36a17 100644 --- a/crates/re_types/src/datatypes/mat4x4.rs +++ b/crates/re_types/src/datatypes/mat4x4.rs @@ -52,19 +52,7 @@ impl From for [f32; 16usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Mat4x4> { - #[inline] - fn from(value: Mat4x4) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Mat4x4> for ::std::borrow::Cow<'a, Mat4x4> { - #[inline] - fn from(value: &'a Mat4x4) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Mat4x4); impl ::re_types_core::Loggable for Mat4x4 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/material.rs b/crates/re_types/src/datatypes/material.rs index a9657a94b476..6005afcabba8 100644 --- a/crates/re_types/src/datatypes/material.rs +++ b/crates/re_types/src/datatypes/material.rs @@ -52,19 +52,7 @@ impl std::ops::Deref for Material { } } -impl<'a> From for ::std::borrow::Cow<'a, Material> { - #[inline] - fn from(value: Material) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Material> for ::std::borrow::Cow<'a, Material> { - #[inline] - fn from(value: &'a Material) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Material); impl ::re_types_core::Loggable for Material { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/mesh_properties.rs b/crates/re_types/src/datatypes/mesh_properties.rs index 90e83359db9a..4f82afe6adfa 100644 --- a/crates/re_types/src/datatypes/mesh_properties.rs +++ b/crates/re_types/src/datatypes/mesh_properties.rs @@ -44,19 +44,7 @@ impl From for Option<::re_types_core::ArrowBuffer> { } } -impl<'a> From for ::std::borrow::Cow<'a, MeshProperties> { - #[inline] - fn from(value: MeshProperties) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a MeshProperties> for ::std::borrow::Cow<'a, MeshProperties> { - #[inline] - fn from(value: &'a MeshProperties) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(MeshProperties); impl ::re_types_core::Loggable for MeshProperties { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/mod.rs b/crates/re_types/src/datatypes/mod.rs index 10491fc48333..85e43430e5b9 100644 --- a/crates/re_types/src/datatypes/mod.rs +++ b/crates/re_types/src/datatypes/mod.rs @@ -10,7 +10,6 @@ mod class_description_map_elem; mod class_description_map_elem_ext; mod class_id; mod class_id_ext; -mod float32; mod keypoint_id; mod keypoint_id_ext; mod keypoint_pair; @@ -44,8 +43,6 @@ mod translation_and_mat3x3; mod translation_and_mat3x3_ext; mod translation_rotation_scale3d; mod translation_rotation_scale3d_ext; -mod utf8; -mod utf8_ext; mod uvec2d; mod uvec2d_ext; mod uvec3d; @@ -64,7 +61,6 @@ pub use self::annotation_info::AnnotationInfo; pub use self::class_description::ClassDescription; pub use self::class_description_map_elem::ClassDescriptionMapElem; pub use self::class_id::ClassId; -pub use self::float32::Float32; pub use self::keypoint_id::KeypointId; pub use self::keypoint_pair::KeypointPair; pub use self::mat3x3::Mat3x3; @@ -82,7 +78,6 @@ pub use self::tensor_dimension::TensorDimension; pub use self::transform3d::Transform3D; pub use self::translation_and_mat3x3::TranslationAndMat3x3; pub use self::translation_rotation_scale3d::TranslationRotationScale3D; -pub use self::utf8::Utf8; pub use self::uvec2d::UVec2D; pub use self::uvec3d::UVec3D; pub use self::uvec4d::UVec4D; diff --git a/crates/re_types/src/datatypes/quaternion.rs b/crates/re_types/src/datatypes/quaternion.rs index 721dfe0f03d9..990ff3b74a58 100644 --- a/crates/re_types/src/datatypes/quaternion.rs +++ b/crates/re_types/src/datatypes/quaternion.rs @@ -42,19 +42,7 @@ impl From for [f32; 4usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Quaternion> { - #[inline] - fn from(value: Quaternion) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Quaternion> for ::std::borrow::Cow<'a, Quaternion> { - #[inline] - fn from(value: &'a Quaternion) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Quaternion); impl ::re_types_core::Loggable for Quaternion { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/rgba32.rs b/crates/re_types/src/datatypes/rgba32.rs index 093bcb01a2a9..f03116f91588 100644 --- a/crates/re_types/src/datatypes/rgba32.rs +++ b/crates/re_types/src/datatypes/rgba32.rs @@ -45,19 +45,7 @@ impl From for u32 { } } -impl<'a> From for ::std::borrow::Cow<'a, Rgba32> { - #[inline] - fn from(value: Rgba32) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Rgba32> for ::std::borrow::Cow<'a, Rgba32> { - #[inline] - fn from(value: &'a Rgba32) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Rgba32); impl ::re_types_core::Loggable for Rgba32 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/rotation3d.rs b/crates/re_types/src/datatypes/rotation3d.rs index ee7a64cb1bde..fcbb4f818b95 100644 --- a/crates/re_types/src/datatypes/rotation3d.rs +++ b/crates/re_types/src/datatypes/rotation3d.rs @@ -31,19 +31,7 @@ pub enum Rotation3D { AxisAngle(crate::datatypes::RotationAxisAngle), } -impl<'a> From for ::std::borrow::Cow<'a, Rotation3D> { - #[inline] - fn from(value: Rotation3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Rotation3D> for ::std::borrow::Cow<'a, Rotation3D> { - #[inline] - fn from(value: &'a Rotation3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Rotation3D); impl ::re_types_core::Loggable for Rotation3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/rotation_axis_angle.rs b/crates/re_types/src/datatypes/rotation_axis_angle.rs index 24f4bc0f012b..ac5964c64fa7 100644 --- a/crates/re_types/src/datatypes/rotation_axis_angle.rs +++ b/crates/re_types/src/datatypes/rotation_axis_angle.rs @@ -35,19 +35,7 @@ pub struct RotationAxisAngle { pub angle: crate::datatypes::Angle, } -impl<'a> From for ::std::borrow::Cow<'a, RotationAxisAngle> { - #[inline] - fn from(value: RotationAxisAngle) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a RotationAxisAngle> for ::std::borrow::Cow<'a, RotationAxisAngle> { - #[inline] - fn from(value: &'a RotationAxisAngle) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(RotationAxisAngle); impl ::re_types_core::Loggable for RotationAxisAngle { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/scale3d.rs b/crates/re_types/src/datatypes/scale3d.rs index a1032450486b..b4352c5954d9 100644 --- a/crates/re_types/src/datatypes/scale3d.rs +++ b/crates/re_types/src/datatypes/scale3d.rs @@ -31,19 +31,7 @@ pub enum Scale3D { Uniform(f32), } -impl<'a> From for ::std::borrow::Cow<'a, Scale3D> { - #[inline] - fn from(value: Scale3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Scale3D> for ::std::borrow::Cow<'a, Scale3D> { - #[inline] - fn from(value: &'a Scale3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Scale3D); impl ::re_types_core::Loggable for Scale3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/tensor_buffer.rs b/crates/re_types/src/datatypes/tensor_buffer.rs index 5b9f1613e0c2..46e0c1217f56 100644 --- a/crates/re_types/src/datatypes/tensor_buffer.rs +++ b/crates/re_types/src/datatypes/tensor_buffer.rs @@ -41,19 +41,7 @@ pub enum TensorBuffer { Nv12(::re_types_core::ArrowBuffer), } -impl<'a> From for ::std::borrow::Cow<'a, TensorBuffer> { - #[inline] - fn from(value: TensorBuffer) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TensorBuffer> for ::std::borrow::Cow<'a, TensorBuffer> { - #[inline] - fn from(value: &'a TensorBuffer) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TensorBuffer); impl ::re_types_core::Loggable for TensorBuffer { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/tensor_data.rs b/crates/re_types/src/datatypes/tensor_data.rs index 9d2bb235ff76..dc4e3421fbeb 100644 --- a/crates/re_types/src/datatypes/tensor_data.rs +++ b/crates/re_types/src/datatypes/tensor_data.rs @@ -35,19 +35,7 @@ pub struct TensorData { pub buffer: crate::datatypes::TensorBuffer, } -impl<'a> From for ::std::borrow::Cow<'a, TensorData> { - #[inline] - fn from(value: TensorData) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TensorData> for ::std::borrow::Cow<'a, TensorData> { - #[inline] - fn from(value: &'a TensorData) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TensorData); impl ::re_types_core::Loggable for TensorData { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/tensor_dimension.rs b/crates/re_types/src/datatypes/tensor_dimension.rs index c42105de6049..c8fa3fdc52cf 100644 --- a/crates/re_types/src/datatypes/tensor_dimension.rs +++ b/crates/re_types/src/datatypes/tensor_dimension.rs @@ -31,19 +31,7 @@ pub struct TensorDimension { pub name: Option<::re_types_core::ArrowString>, } -impl<'a> From for ::std::borrow::Cow<'a, TensorDimension> { - #[inline] - fn from(value: TensorDimension) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TensorDimension> for ::std::borrow::Cow<'a, TensorDimension> { - #[inline] - fn from(value: &'a TensorDimension) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TensorDimension); impl ::re_types_core::Loggable for TensorDimension { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/transform3d.rs b/crates/re_types/src/datatypes/transform3d.rs index a1bf8577fe7a..84687786e2b0 100644 --- a/crates/re_types/src/datatypes/transform3d.rs +++ b/crates/re_types/src/datatypes/transform3d.rs @@ -31,19 +31,7 @@ pub enum Transform3D { TranslationRotationScale(crate::datatypes::TranslationRotationScale3D), } -impl<'a> From for ::std::borrow::Cow<'a, Transform3D> { - #[inline] - fn from(value: Transform3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Transform3D> for ::std::borrow::Cow<'a, Transform3D> { - #[inline] - fn from(value: &'a Transform3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Transform3D); impl ::re_types_core::Loggable for Transform3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/translation_and_mat3x3.rs b/crates/re_types/src/datatypes/translation_and_mat3x3.rs index 8539bec5f6b2..f2c9d192949b 100644 --- a/crates/re_types/src/datatypes/translation_and_mat3x3.rs +++ b/crates/re_types/src/datatypes/translation_and_mat3x3.rs @@ -39,19 +39,7 @@ pub struct TranslationAndMat3x3 { pub from_parent: bool, } -impl<'a> From for ::std::borrow::Cow<'a, TranslationAndMat3x3> { - #[inline] - fn from(value: TranslationAndMat3x3) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TranslationAndMat3x3> for ::std::borrow::Cow<'a, TranslationAndMat3x3> { - #[inline] - fn from(value: &'a TranslationAndMat3x3) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TranslationAndMat3x3); impl ::re_types_core::Loggable for TranslationAndMat3x3 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs index 8cf84648bbad..ff6d4e709e34 100644 --- a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs +++ b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs @@ -40,21 +40,7 @@ pub struct TranslationRotationScale3D { pub from_parent: bool, } -impl<'a> From for ::std::borrow::Cow<'a, TranslationRotationScale3D> { - #[inline] - fn from(value: TranslationRotationScale3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a TranslationRotationScale3D> - for ::std::borrow::Cow<'a, TranslationRotationScale3D> -{ - #[inline] - fn from(value: &'a TranslationRotationScale3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(TranslationRotationScale3D); impl ::re_types_core::Loggable for TranslationRotationScale3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/uvec2d.rs b/crates/re_types/src/datatypes/uvec2d.rs index ff9b1b288c1a..60cbfd8dec24 100644 --- a/crates/re_types/src/datatypes/uvec2d.rs +++ b/crates/re_types/src/datatypes/uvec2d.rs @@ -40,19 +40,7 @@ impl From for [u32; 2usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, UVec2D> { - #[inline] - fn from(value: UVec2D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a UVec2D> for ::std::borrow::Cow<'a, UVec2D> { - #[inline] - fn from(value: &'a UVec2D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(UVec2D); impl ::re_types_core::Loggable for UVec2D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/uvec3d.rs b/crates/re_types/src/datatypes/uvec3d.rs index f4b2b4b76d06..6557f8d3e39d 100644 --- a/crates/re_types/src/datatypes/uvec3d.rs +++ b/crates/re_types/src/datatypes/uvec3d.rs @@ -40,19 +40,7 @@ impl From for [u32; 3usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, UVec3D> { - #[inline] - fn from(value: UVec3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a UVec3D> for ::std::borrow::Cow<'a, UVec3D> { - #[inline] - fn from(value: &'a UVec3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(UVec3D); impl ::re_types_core::Loggable for UVec3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/uvec4d.rs b/crates/re_types/src/datatypes/uvec4d.rs index a41ba2cfb6bc..358503ccb89e 100644 --- a/crates/re_types/src/datatypes/uvec4d.rs +++ b/crates/re_types/src/datatypes/uvec4d.rs @@ -40,19 +40,7 @@ impl From for [u32; 4usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, UVec4D> { - #[inline] - fn from(value: UVec4D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a UVec4D> for ::std::borrow::Cow<'a, UVec4D> { - #[inline] - fn from(value: &'a UVec4D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(UVec4D); impl ::re_types_core::Loggable for UVec4D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/vec2d.rs b/crates/re_types/src/datatypes/vec2d.rs index 3bf64909860d..87164d85524e 100644 --- a/crates/re_types/src/datatypes/vec2d.rs +++ b/crates/re_types/src/datatypes/vec2d.rs @@ -40,19 +40,7 @@ impl From for [f32; 2usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Vec2D> { - #[inline] - fn from(value: Vec2D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Vec2D> for ::std::borrow::Cow<'a, Vec2D> { - #[inline] - fn from(value: &'a Vec2D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Vec2D); impl ::re_types_core::Loggable for Vec2D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/vec3d.rs b/crates/re_types/src/datatypes/vec3d.rs index 04ea41b10248..03940db8b725 100644 --- a/crates/re_types/src/datatypes/vec3d.rs +++ b/crates/re_types/src/datatypes/vec3d.rs @@ -40,19 +40,7 @@ impl From for [f32; 3usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Vec3D> { - #[inline] - fn from(value: Vec3D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Vec3D> for ::std::borrow::Cow<'a, Vec3D> { - #[inline] - fn from(value: &'a Vec3D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Vec3D); impl ::re_types_core::Loggable for Vec3D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/datatypes/vec4d.rs b/crates/re_types/src/datatypes/vec4d.rs index e27121bc6e6e..e7e8d53db48a 100644 --- a/crates/re_types/src/datatypes/vec4d.rs +++ b/crates/re_types/src/datatypes/vec4d.rs @@ -40,19 +40,7 @@ impl From for [f32; 4usize] { } } -impl<'a> From for ::std::borrow::Cow<'a, Vec4D> { - #[inline] - fn from(value: Vec4D) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Vec4D> for ::std::borrow::Cow<'a, Vec4D> { - #[inline] - fn from(value: &'a Vec4D) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(Vec4D); impl ::re_types_core::Loggable for Vec4D { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/lib.rs b/crates/re_types/src/lib.rs index 08ecf126f423..fc136addc3f8 100644 --- a/crates/re_types/src/lib.rs +++ b/crates/re_types/src/lib.rs @@ -230,7 +230,20 @@ pub mod components { /// The low-level datatypes that [`components`] are built from. /// /// They all implement the [`Datatype`] trait. -pub mod datatypes; +pub mod datatypes { + + // Some datatypes (e.g. `InstanceKey`) are so fundamental and used everywhere that we want + // them to be exposed by `re_types_core` directly; that way we don't force a dependency on the + // `re_types` behemoth just so one can use one of these fundamental types. + // + // To do so, re-inject `re_types_core`'s datatypes into our own module. + + #[path = "../datatypes/mod.rs"] + mod _datatypes; + + pub use self::_datatypes::*; + pub use re_types_core::datatypes::*; +} #[cfg(feature = "datagen")] pub mod datagen; diff --git a/crates/re_types/src/testing/components/affix_fuzzer1.rs b/crates/re_types/src/testing/components/affix_fuzzer1.rs index 31218823e2b1..17712f45108d 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer1.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer1.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer1 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer1> { - #[inline] - fn from(value: AffixFuzzer1) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer1> for ::std::borrow::Cow<'a, AffixFuzzer1> { - #[inline] - fn from(value: &'a AffixFuzzer1) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer1); impl ::re_types_core::Loggable for AffixFuzzer1 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer10.rs b/crates/re_types/src/testing/components/affix_fuzzer10.rs index 02dcc41d3171..fd6dba6f2991 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer10.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer10.rs @@ -38,19 +38,7 @@ impl From for Option<::re_types_core::ArrowString> { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer10> { - #[inline] - fn from(value: AffixFuzzer10) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer10> for ::std::borrow::Cow<'a, AffixFuzzer10> { - #[inline] - fn from(value: &'a AffixFuzzer10) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer10); impl ::re_types_core::Loggable for AffixFuzzer10 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer11.rs b/crates/re_types/src/testing/components/affix_fuzzer11.rs index 98fc081564c9..5f98a46ebb28 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer11.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer11.rs @@ -38,19 +38,7 @@ impl From for Option<::re_types_core::ArrowBuffer> { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer11> { - #[inline] - fn from(value: AffixFuzzer11) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer11> for ::std::borrow::Cow<'a, AffixFuzzer11> { - #[inline] - fn from(value: &'a AffixFuzzer11) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer11); impl ::re_types_core::Loggable for AffixFuzzer11 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer12.rs b/crates/re_types/src/testing/components/affix_fuzzer12.rs index f42e8e218597..e45c7cc2ece9 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer12.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer12.rs @@ -38,19 +38,7 @@ impl From for Vec<::re_types_core::ArrowString> { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer12> { - #[inline] - fn from(value: AffixFuzzer12) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer12> for ::std::borrow::Cow<'a, AffixFuzzer12> { - #[inline] - fn from(value: &'a AffixFuzzer12) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer12); impl ::re_types_core::Loggable for AffixFuzzer12 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer13.rs b/crates/re_types/src/testing/components/affix_fuzzer13.rs index e148c4e2cfc7..38216a3be59b 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer13.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer13.rs @@ -38,19 +38,7 @@ impl From for Option> { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer13> { - #[inline] - fn from(value: AffixFuzzer13) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer13> for ::std::borrow::Cow<'a, AffixFuzzer13> { - #[inline] - fn from(value: &'a AffixFuzzer13) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer13); impl ::re_types_core::Loggable for AffixFuzzer13 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer14.rs b/crates/re_types/src/testing/components/affix_fuzzer14.rs index 831c0da0941b..b701104899a6 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer14.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer14.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer14 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer14> { - #[inline] - fn from(value: AffixFuzzer14) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer14> for ::std::borrow::Cow<'a, AffixFuzzer14> { - #[inline] - fn from(value: &'a AffixFuzzer14) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer14); impl ::re_types_core::Loggable for AffixFuzzer14 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer15.rs b/crates/re_types/src/testing/components/affix_fuzzer15.rs index a81aacae283a..4bed690aeb39 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer15.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer15.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer15 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer15> { - #[inline] - fn from(value: AffixFuzzer15) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer15> for ::std::borrow::Cow<'a, AffixFuzzer15> { - #[inline] - fn from(value: &'a AffixFuzzer15) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer15); impl ::re_types_core::Loggable for AffixFuzzer15 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer16.rs b/crates/re_types/src/testing/components/affix_fuzzer16.rs index 82fb71d23f63..f25251b58679 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer16.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer16.rs @@ -32,19 +32,7 @@ impl, T: IntoIterator } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer16> { - #[inline] - fn from(value: AffixFuzzer16) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer16> for ::std::borrow::Cow<'a, AffixFuzzer16> { - #[inline] - fn from(value: &'a AffixFuzzer16) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer16); impl ::re_types_core::Loggable for AffixFuzzer16 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer17.rs b/crates/re_types/src/testing/components/affix_fuzzer17.rs index be519abde208..6f0e4c561824 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer17.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer17.rs @@ -32,19 +32,7 @@ impl, T: IntoIterator } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer17> { - #[inline] - fn from(value: AffixFuzzer17) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer17> for ::std::borrow::Cow<'a, AffixFuzzer17> { - #[inline] - fn from(value: &'a AffixFuzzer17) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer17); impl ::re_types_core::Loggable for AffixFuzzer17 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer18.rs b/crates/re_types/src/testing/components/affix_fuzzer18.rs index a0d103f825ac..dd0bac07768a 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer18.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer18.rs @@ -32,19 +32,7 @@ impl, T: IntoIterator } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer18> { - #[inline] - fn from(value: AffixFuzzer18) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer18> for ::std::borrow::Cow<'a, AffixFuzzer18> { - #[inline] - fn from(value: &'a AffixFuzzer18) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer18); impl ::re_types_core::Loggable for AffixFuzzer18 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer19.rs b/crates/re_types/src/testing/components/affix_fuzzer19.rs index 792d77fe42f1..f1a9486d3229 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer19.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer19.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer19 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer19> { - #[inline] - fn from(value: AffixFuzzer19) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer19> for ::std::borrow::Cow<'a, AffixFuzzer19> { - #[inline] - fn from(value: &'a AffixFuzzer19) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer19); impl ::re_types_core::Loggable for AffixFuzzer19 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer2.rs b/crates/re_types/src/testing/components/affix_fuzzer2.rs index e0eff0099afe..cede24fecaf8 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer2.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer2.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer2 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer2> { - #[inline] - fn from(value: AffixFuzzer2) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer2> for ::std::borrow::Cow<'a, AffixFuzzer2> { - #[inline] - fn from(value: &'a AffixFuzzer2) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer2); impl ::re_types_core::Loggable for AffixFuzzer2 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer20.rs b/crates/re_types/src/testing/components/affix_fuzzer20.rs index 2193e361ba0b..b1c58dc3b6b7 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer20.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer20.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer20 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer20> { - #[inline] - fn from(value: AffixFuzzer20) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer20> for ::std::borrow::Cow<'a, AffixFuzzer20> { - #[inline] - fn from(value: &'a AffixFuzzer20) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer20); impl ::re_types_core::Loggable for AffixFuzzer20 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer21.rs b/crates/re_types/src/testing/components/affix_fuzzer21.rs index f42878afc094..be9eabac5178 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer21.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer21.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer21 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer21> { - #[inline] - fn from(value: AffixFuzzer21) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer21> for ::std::borrow::Cow<'a, AffixFuzzer21> { - #[inline] - fn from(value: &'a AffixFuzzer21) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer21); impl ::re_types_core::Loggable for AffixFuzzer21 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer3.rs b/crates/re_types/src/testing/components/affix_fuzzer3.rs index 92745cbafbbc..f8fca62c8509 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer3.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer3.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer3 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer3> { - #[inline] - fn from(value: AffixFuzzer3) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer3> for ::std::borrow::Cow<'a, AffixFuzzer3> { - #[inline] - fn from(value: &'a AffixFuzzer3) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer3); impl ::re_types_core::Loggable for AffixFuzzer3 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer4.rs b/crates/re_types/src/testing/components/affix_fuzzer4.rs index beb175f42300..17fdecb4cd6b 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer4.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer4.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer4 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer4> { - #[inline] - fn from(value: AffixFuzzer4) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer4> for ::std::borrow::Cow<'a, AffixFuzzer4> { - #[inline] - fn from(value: &'a AffixFuzzer4) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer4); impl ::re_types_core::Loggable for AffixFuzzer4 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer5.rs b/crates/re_types/src/testing/components/affix_fuzzer5.rs index 35fc36692da2..39be2d3b8548 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer5.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer5.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer5 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer5> { - #[inline] - fn from(value: AffixFuzzer5) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer5> for ::std::borrow::Cow<'a, AffixFuzzer5> { - #[inline] - fn from(value: &'a AffixFuzzer5) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer5); impl ::re_types_core::Loggable for AffixFuzzer5 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer6.rs b/crates/re_types/src/testing/components/affix_fuzzer6.rs index 1bc7a97894db..953fa8c0969e 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer6.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer6.rs @@ -46,19 +46,7 @@ impl std::ops::Deref for AffixFuzzer6 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer6> { - #[inline] - fn from(value: AffixFuzzer6) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer6> for ::std::borrow::Cow<'a, AffixFuzzer6> { - #[inline] - fn from(value: &'a AffixFuzzer6) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer6); impl ::re_types_core::Loggable for AffixFuzzer6 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer7.rs b/crates/re_types/src/testing/components/affix_fuzzer7.rs index ee3258f98075..cd7a8e8b7475 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer7.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer7.rs @@ -32,19 +32,7 @@ impl, T: IntoIterator } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer7> { - #[inline] - fn from(value: AffixFuzzer7) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer7> for ::std::borrow::Cow<'a, AffixFuzzer7> { - #[inline] - fn from(value: &'a AffixFuzzer7) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer7); impl ::re_types_core::Loggable for AffixFuzzer7 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer8.rs b/crates/re_types/src/testing/components/affix_fuzzer8.rs index cde4d42f59fd..4a0536b8b139 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer8.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer8.rs @@ -38,19 +38,7 @@ impl From for Option { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer8> { - #[inline] - fn from(value: AffixFuzzer8) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer8> for ::std::borrow::Cow<'a, AffixFuzzer8> { - #[inline] - fn from(value: &'a AffixFuzzer8) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer8); impl ::re_types_core::Loggable for AffixFuzzer8 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/components/affix_fuzzer9.rs b/crates/re_types/src/testing/components/affix_fuzzer9.rs index 4d5029567f35..0f7bdca021c2 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer9.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer9.rs @@ -38,19 +38,7 @@ impl From for ::re_types_core::ArrowString { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer9> { - #[inline] - fn from(value: AffixFuzzer9) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer9> for ::std::borrow::Cow<'a, AffixFuzzer9> { - #[inline] - fn from(value: &'a AffixFuzzer9) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer9); impl ::re_types_core::Loggable for AffixFuzzer9 { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs index ec195eb86f7b..946c1672db7e 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs @@ -34,19 +34,7 @@ pub struct AffixFuzzer1 { pub from_parent: Option, } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer1> { - #[inline] - fn from(value: AffixFuzzer1) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer1> for ::std::borrow::Cow<'a, AffixFuzzer1> { - #[inline] - fn from(value: &'a AffixFuzzer1) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer1); impl ::re_types_core::Loggable for AffixFuzzer1 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer2.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer2.rs index 065361cadc4b..9ea837db4ff8 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer2.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer2.rs @@ -38,19 +38,7 @@ impl From for Option { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer2> { - #[inline] - fn from(value: AffixFuzzer2) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer2> for ::std::borrow::Cow<'a, AffixFuzzer2> { - #[inline] - fn from(value: &'a AffixFuzzer2) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer2); impl ::re_types_core::Loggable for AffixFuzzer2 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs index ee6b29d9a261..ed6e9eebbc66 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs @@ -27,19 +27,7 @@ pub struct AffixFuzzer20 { pub s: crate::testing::datatypes::StringComponent, } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer20> { - #[inline] - fn from(value: AffixFuzzer20) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer20> for ::std::borrow::Cow<'a, AffixFuzzer20> { - #[inline] - fn from(value: &'a AffixFuzzer20) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer20); impl ::re_types_core::Loggable for AffixFuzzer20 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs index e43f710fe5e1..183e1c619e44 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs @@ -27,19 +27,7 @@ pub struct AffixFuzzer21 { pub many_halves: ::re_types_core::ArrowBuffer, } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer21> { - #[inline] - fn from(value: AffixFuzzer21) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer21> for ::std::borrow::Cow<'a, AffixFuzzer21> { - #[inline] - fn from(value: &'a AffixFuzzer21) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer21); impl ::re_types_core::Loggable for AffixFuzzer21 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs index ba2cacfc08e2..0ed55066b1c2 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs @@ -29,19 +29,7 @@ pub enum AffixFuzzer3 { FixedSizeShenanigans([f32; 3usize]), } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer3> { - #[inline] - fn from(value: AffixFuzzer3) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer3> for ::std::borrow::Cow<'a, AffixFuzzer3> { - #[inline] - fn from(value: &'a AffixFuzzer3) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer3); impl ::re_types_core::Loggable for AffixFuzzer3 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs index b636a75e0d11..5ad1bc11c33c 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs @@ -28,19 +28,7 @@ pub enum AffixFuzzer4 { ManyOptional(Option>), } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer4> { - #[inline] - fn from(value: AffixFuzzer4) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer4> for ::std::borrow::Cow<'a, AffixFuzzer4> { - #[inline] - fn from(value: &'a AffixFuzzer4) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer4); impl ::re_types_core::Loggable for AffixFuzzer4 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs index 03a076fd4e46..6e1b6301a65c 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer5.rs @@ -50,19 +50,7 @@ impl std::ops::Deref for AffixFuzzer5 { } } -impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer5> { - #[inline] - fn from(value: AffixFuzzer5) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AffixFuzzer5> for ::std::borrow::Cow<'a, AffixFuzzer5> { - #[inline] - fn from(value: &'a AffixFuzzer5) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AffixFuzzer5); impl ::re_types_core::Loggable for AffixFuzzer5 { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/flattened_scalar.rs b/crates/re_types/src/testing/datatypes/flattened_scalar.rs index bb60ab3b3098..8a3da73b3f3e 100644 --- a/crates/re_types/src/testing/datatypes/flattened_scalar.rs +++ b/crates/re_types/src/testing/datatypes/flattened_scalar.rs @@ -40,19 +40,7 @@ impl From for f32 { } } -impl<'a> From for ::std::borrow::Cow<'a, FlattenedScalar> { - #[inline] - fn from(value: FlattenedScalar) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a FlattenedScalar> for ::std::borrow::Cow<'a, FlattenedScalar> { - #[inline] - fn from(value: &'a FlattenedScalar) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(FlattenedScalar); impl ::re_types_core::Loggable for FlattenedScalar { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/primitive_component.rs b/crates/re_types/src/testing/datatypes/primitive_component.rs index 5e449c5e4ece..2d88ee61b94f 100644 --- a/crates/re_types/src/testing/datatypes/primitive_component.rs +++ b/crates/re_types/src/testing/datatypes/primitive_component.rs @@ -39,19 +39,7 @@ impl From for u32 { } } -impl<'a> From for ::std::borrow::Cow<'a, PrimitiveComponent> { - #[inline] - fn from(value: PrimitiveComponent) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a PrimitiveComponent> for ::std::borrow::Cow<'a, PrimitiveComponent> { - #[inline] - fn from(value: &'a PrimitiveComponent) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(PrimitiveComponent); impl ::re_types_core::Loggable for PrimitiveComponent { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types/src/testing/datatypes/string_component.rs b/crates/re_types/src/testing/datatypes/string_component.rs index b367311db560..54c7ddfebdb4 100644 --- a/crates/re_types/src/testing/datatypes/string_component.rs +++ b/crates/re_types/src/testing/datatypes/string_component.rs @@ -39,19 +39,7 @@ impl From for ::re_types_core::ArrowString { } } -impl<'a> From for ::std::borrow::Cow<'a, StringComponent> { - #[inline] - fn from(value: StringComponent) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a StringComponent> for ::std::borrow::Cow<'a, StringComponent> { - #[inline] - fn from(value: &'a StringComponent) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(StringComponent); impl ::re_types_core::Loggable for StringComponent { type Name = ::re_types_core::DatatypeName; diff --git a/crates/re_types_builder/src/codegen/rust/api.rs b/crates/re_types_builder/src/codegen/rust/api.rs index 34ac15521c3a..22d8896b4132 100644 --- a/crates/re_types_builder/src/codegen/rust/api.rs +++ b/crates/re_types_builder/src/codegen/rust/api.rs @@ -699,26 +699,6 @@ fn quote_trait_impls_from_obj( quote_arrow_serializer(arrow_registry, objects, obj, &format_ident!("data")); let quoted_deserializer = quote_arrow_deserializer(arrow_registry, objects, obj); - let into_cow = quote! { - // NOTE: We need these so end-user code can effortlessly serialize both iterators - // of owned data and iterators of referenced data without ever having to stop and - // think about it. - - impl<'a> From<#name> for ::std::borrow::Cow<'a, #name> { - #[inline] - fn from(value: #name) -> Self { - std::borrow::Cow::Owned(value) - } - } - - impl<'a> From<&'a #name> for ::std::borrow::Cow<'a, #name> { - #[inline] - fn from(value: &'a #name) -> Self { - std::borrow::Cow::Borrowed(value) - } - } - }; - let quoted_from_arrow = if optimize_for_buffer_slice { let quoted_deserializer = quote_arrow_deserializer_buffer_slice(arrow_registry, objects, obj); @@ -752,7 +732,7 @@ fn quote_trait_impls_from_obj( }; quote! { - #into_cow + ::re_types_core::macros::impl_into_cow!(#name); impl ::re_types_core::Loggable for #name { type Name = ::re_types_core::#kind_name; diff --git a/crates/re_types_builder/src/codegen/rust/util.rs b/crates/re_types_builder/src/codegen/rust/util.rs index 06555b2e802e..50e522276c42 100644 --- a/crates/re_types_builder/src/codegen/rust/util.rs +++ b/crates/re_types_builder/src/codegen/rust/util.rs @@ -110,7 +110,8 @@ pub fn string_from_quoted(acc: &TokenStream) -> String { || trimmed.starts_with("impl ") || trimmed.starts_with("impl<") || trimmed.starts_with("pub fn ") - || trimmed.starts_with("static ")) + || trimmed.starts_with("static ") + || trimmed.starts_with("::re_types_core::macros")) { output.push('\n'); } diff --git a/crates/re_types_builder/src/lib.rs b/crates/re_types_builder/src/lib.rs index 6e61f13eff84..68a7b71eba87 100644 --- a/crates/re_types_builder/src/lib.rs +++ b/crates/re_types_builder/src/lib.rs @@ -408,7 +408,7 @@ pub fn generate_cpp_code( // Make sure to filter out that directory, or else we will end up removing those handwritten // files. let root_src = output_path.as_ref().join("src/rerun"); - files.retain(|filepath, _| !filepath.starts_with(&root_src)); + files.retain(|filepath, _| filepath.parent() != Some(root_src.as_path())); crate::codegen::common::remove_orphaned_files(reporter, &files); fn format_code(code: &str) -> String { @@ -736,7 +736,7 @@ pub(crate) fn to_snake_case(s: &str) -> String { let mut parts: Vec<_> = s.split('.').map(ToOwned::to_owned).collect(); if let Some(last) = parts.last_mut() { - *last = last.replace("UVec", "uvec"); + *last = last.replace("UVec", "uvec").replace("UInt", "uint"); *last = rerun_snake.convert(&last); } parts.join(".") @@ -771,6 +771,15 @@ fn test_to_snake_case() { "rerun.datatypes.uvec2d" ); + assert_eq!( + to_snake_case("rerun.datatypes.UInt32"), + "rerun.datatypes.uint32" + ); + assert_eq!( + to_snake_case("rerun.datatypes.uint32"), + "rerun.datatypes.uint32" + ); + assert_eq!( to_snake_case("rerun.archetypes.Points2DIndicator"), "rerun.archetypes.points2d_indicator" @@ -816,6 +825,7 @@ pub(crate) fn to_pascal_case(s: &str) -> String { if let Some(last) = parts.last_mut() { *last = last .replace("uvec", "UVec") + .replace("uint", "UInt") .replace("2d", "2D") .replace("3d", "3D") .replace("4d", "4D"); @@ -849,6 +859,15 @@ fn test_to_pascal_case() { "rerun.datatypes.UVec2D" ); + assert_eq!( + to_pascal_case("rerun.datatypes.uint32"), + "rerun.datatypes.UInt32" + ); + assert_eq!( + to_pascal_case("rerun.datatypes.UInt32"), + "rerun.datatypes.UInt32" + ); + assert_eq!( to_pascal_case("rerun.archetypes.points2d_indicator"), "rerun.archetypes.Points2DIndicator" diff --git a/crates/re_types_core/src/components/clear_is_recursive.rs b/crates/re_types_core/src/components/clear_is_recursive.rs index 9dd997e762ce..4f18a216d059 100644 --- a/crates/re_types_core/src/components/clear_is_recursive.rs +++ b/crates/re_types_core/src/components/clear_is_recursive.rs @@ -42,19 +42,7 @@ impl From for bool { } } -impl<'a> From for ::std::borrow::Cow<'a, ClearIsRecursive> { - #[inline] - fn from(value: ClearIsRecursive) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ClearIsRecursive> for ::std::borrow::Cow<'a, ClearIsRecursive> { - #[inline] - fn from(value: &'a ClearIsRecursive) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +crate::macros::impl_into_cow!(ClearIsRecursive); impl crate::Loggable for ClearIsRecursive { type Name = crate::ComponentName; diff --git a/crates/re_types_core/src/components/instance_key.rs b/crates/re_types_core/src/components/instance_key.rs index 3cb86f9c6003..4a3361a0d73f 100644 --- a/crates/re_types_core/src/components/instance_key.rs +++ b/crates/re_types_core/src/components/instance_key.rs @@ -40,19 +40,7 @@ impl From for u64 { } } -impl<'a> From for ::std::borrow::Cow<'a, InstanceKey> { - #[inline] - fn from(value: InstanceKey) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a InstanceKey> for ::std::borrow::Cow<'a, InstanceKey> { - #[inline] - fn from(value: &'a InstanceKey) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +crate::macros::impl_into_cow!(InstanceKey); impl crate::Loggable for InstanceKey { type Name = crate::ComponentName; diff --git a/crates/re_types_core/src/datatypes/.gitattributes b/crates/re_types_core/src/datatypes/.gitattributes new file mode 100644 index 000000000000..5c6cfc18298d --- /dev/null +++ b/crates/re_types_core/src/datatypes/.gitattributes @@ -0,0 +1,7 @@ +# DO NOT EDIT! This file is generated by crates/re_types_builder/src/lib.rs + +.gitattributes linguist-generated=true +float32.rs linguist-generated=true +mod.rs linguist-generated=true +uint32.rs linguist-generated=true +utf8.rs linguist-generated=true diff --git a/crates/re_types/src/datatypes/float32.rs b/crates/re_types_core/src/datatypes/float32.rs similarity index 81% rename from crates/re_types/src/datatypes/float32.rs rename to crates/re_types_core/src/datatypes/float32.rs index 749d95ed3e1d..935a45588282 100644 --- a/crates/re_types/src/datatypes/float32.rs +++ b/crates/re_types_core/src/datatypes/float32.rs @@ -15,11 +15,11 @@ #![allow(clippy::too_many_lines)] #![allow(clippy::unnecessary_cast)] -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; +use crate::external::arrow2; +use crate::ComponentName; +use crate::SerializationResult; +use crate::{ComponentBatch, MaybeOwnedComponentBatch}; +use crate::{DeserializationError, DeserializationResult}; /// **Datatype**: A single-precision 32-bit IEEE 754 floating point number. #[derive(Clone, Debug, Copy, PartialEq, PartialOrd)] @@ -39,22 +39,10 @@ impl From for f32 { } } -impl<'a> From for ::std::borrow::Cow<'a, Float32> { - #[inline] - fn from(value: Float32) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Float32> for ::std::borrow::Cow<'a, Float32> { - #[inline] - fn from(value: &'a Float32) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +crate::macros::impl_into_cow!(Float32); -impl ::re_types_core::Loggable for Float32 { - type Name = ::re_types_core::DatatypeName; +impl crate::Loggable for Float32 { + type Name = crate::DatatypeName; #[inline] fn name() -> Self::Name { @@ -76,7 +64,7 @@ impl ::re_types_core::Loggable for Float32 { Self: Clone + 'a, { re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; + use crate::{Loggable as _, ResultExt as _}; use arrow2::{array::*, datatypes::*}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data @@ -111,7 +99,7 @@ impl ::re_types_core::Loggable for Float32 { Self: Sized, { re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; + use crate::{Loggable as _, ResultExt as _}; use arrow2::{array::*, buffer::*, datatypes::*}; Ok(arrow_data .as_any() diff --git a/crates/re_types_core/src/datatypes/mod.rs b/crates/re_types_core/src/datatypes/mod.rs new file mode 100644 index 000000000000..793e2a405cfc --- /dev/null +++ b/crates/re_types_core/src/datatypes/mod.rs @@ -0,0 +1,10 @@ +// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/rust/api.rs + +mod float32; +mod uint32; +mod utf8; +mod utf8_ext; + +pub use self::float32::Float32; +pub use self::uint32::UInt32; +pub use self::utf8::Utf8; diff --git a/crates/re_types_core/src/datatypes/uint32.rs b/crates/re_types_core/src/datatypes/uint32.rs new file mode 100644 index 000000000000..728f5408c582 --- /dev/null +++ b/crates/re_types_core/src/datatypes/uint32.rs @@ -0,0 +1,122 @@ +// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/re_types/definitions/rerun/datatypes/uint32.fbs". + +#![allow(trivial_numeric_casts)] +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::iter_on_single_items)] +#![allow(clippy::map_flatten)] +#![allow(clippy::match_wildcard_for_single_variants)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] +#![allow(clippy::unnecessary_cast)] + +use crate::external::arrow2; +use crate::ComponentName; +use crate::SerializationResult; +use crate::{ComponentBatch, MaybeOwnedComponentBatch}; +use crate::{DeserializationError, DeserializationResult}; + +/// **Datatype**: A 32bit unsigned integer. +#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub struct UInt32(pub u32); + +impl From for UInt32 { + #[inline] + fn from(value: u32) -> Self { + Self(value) + } +} + +impl From for u32 { + #[inline] + fn from(value: UInt32) -> Self { + value.0 + } +} + +crate::macros::impl_into_cow!(UInt32); + +impl crate::Loggable for UInt32 { + type Name = crate::DatatypeName; + + #[inline] + fn name() -> Self::Name { + "rerun.datatypes.UInt32".into() + } + + #[allow(clippy::wildcard_imports)] + #[inline] + fn arrow_datatype() -> arrow2::datatypes::DataType { + use arrow2::datatypes::*; + DataType::UInt32 + } + + #[allow(clippy::wildcard_imports)] + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult> + where + Self: Clone + 'a, + { + re_tracing::profile_function!(); + use crate::{Loggable as _, ResultExt as _}; + use arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + Self::arrow_datatype(), + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(clippy::wildcard_imports)] + fn from_arrow_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + re_tracing::profile_function!(); + use crate::{Loggable as _, ResultExt as _}; + use arrow2::{array::*, buffer::*, datatypes::*}; + Ok(arrow_data + .as_any() + .downcast_ref::() + .ok_or_else(|| { + DeserializationError::datatype_mismatch( + DataType::UInt32, + arrow_data.data_type().clone(), + ) + }) + .with_context("rerun.datatypes.UInt32#value")? + .into_iter() + .map(|opt| opt.copied()) + .map(|v| v.ok_or_else(DeserializationError::missing_data)) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>() + .with_context("rerun.datatypes.UInt32#value") + .with_context("rerun.datatypes.UInt32")?) + } +} diff --git a/crates/re_types/src/datatypes/utf8.rs b/crates/re_types_core/src/datatypes/utf8.rs similarity index 82% rename from crates/re_types/src/datatypes/utf8.rs rename to crates/re_types_core/src/datatypes/utf8.rs index 17c536b08d2d..41c90aaafc2f 100644 --- a/crates/re_types/src/datatypes/utf8.rs +++ b/crates/re_types_core/src/datatypes/utf8.rs @@ -15,47 +15,35 @@ #![allow(clippy::too_many_lines)] #![allow(clippy::unnecessary_cast)] -use ::re_types_core::external::arrow2; -use ::re_types_core::ComponentName; -use ::re_types_core::SerializationResult; -use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; -use ::re_types_core::{DeserializationError, DeserializationResult}; +use crate::external::arrow2; +use crate::ComponentName; +use crate::SerializationResult; +use crate::{ComponentBatch, MaybeOwnedComponentBatch}; +use crate::{DeserializationError, DeserializationResult}; /// **Datatype**: A string of text, encoded as UTF-8. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] -pub struct Utf8(pub ::re_types_core::ArrowString); +pub struct Utf8(pub crate::ArrowString); -impl From<::re_types_core::ArrowString> for Utf8 { +impl From for Utf8 { #[inline] - fn from(value: ::re_types_core::ArrowString) -> Self { + fn from(value: crate::ArrowString) -> Self { Self(value) } } -impl From for ::re_types_core::ArrowString { +impl From for crate::ArrowString { #[inline] fn from(value: Utf8) -> Self { value.0 } } -impl<'a> From for ::std::borrow::Cow<'a, Utf8> { - #[inline] - fn from(value: Utf8) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a Utf8> for ::std::borrow::Cow<'a, Utf8> { - #[inline] - fn from(value: &'a Utf8) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +crate::macros::impl_into_cow!(Utf8); -impl ::re_types_core::Loggable for Utf8 { - type Name = ::re_types_core::DatatypeName; +impl crate::Loggable for Utf8 { + type Name = crate::DatatypeName; #[inline] fn name() -> Self::Name { @@ -77,7 +65,7 @@ impl ::re_types_core::Loggable for Utf8 { Self: Clone + 'a, { re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; + use crate::{Loggable as _, ResultExt as _}; use arrow2::{array::*, datatypes::*}; Ok({ let (somes, data0): (Vec<_>, Vec<_>) = data @@ -128,7 +116,7 @@ impl ::re_types_core::Loggable for Utf8 { Self: Sized, { re_tracing::profile_function!(); - use ::re_types_core::{Loggable as _, ResultExt as _}; + use crate::{Loggable as _, ResultExt as _}; use arrow2::{array::*, buffer::*, datatypes::*}; Ok({ let arrow_data = arrow_data @@ -165,7 +153,7 @@ impl ::re_types_core::Loggable for Utf8 { .transpose() }) .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| res_or_opt.map(|v| ::re_types_core::ArrowString(v))) + res_or_opt.map(|res_or_opt| res_or_opt.map(|v| crate::ArrowString(v))) }) .collect::>>>() .with_context("rerun.datatypes.Utf8#value")? diff --git a/crates/re_types/src/datatypes/utf8_ext.rs b/crates/re_types_core/src/datatypes/utf8_ext.rs similarity index 100% rename from crates/re_types/src/datatypes/utf8_ext.rs rename to crates/re_types_core/src/datatypes/utf8_ext.rs diff --git a/crates/re_types_core/src/lib.rs b/crates/re_types_core/src/lib.rs index 32e7c8ae3a2b..8a4be0e99ba3 100644 --- a/crates/re_types_core/src/lib.rs +++ b/crates/re_types_core/src/lib.rs @@ -116,6 +116,12 @@ pub mod archetypes; /// There are also re-exported by `re_types`. pub mod components; +/// Fundamental [`Datatype`]s that are implemented in `re_types_core` directly for convenience and +/// dependency optimization. +/// +/// There are also re-exported by `re_types`. +pub mod datatypes; + // --- mod arrow_buffer; @@ -123,6 +129,13 @@ mod arrow_string; pub use self::arrow_buffer::ArrowBuffer; pub use self::arrow_string::ArrowString; +#[path = "macros.rs"] +mod _macros; // just for the side-effect of exporting the macros + +pub mod macros { + pub use super::impl_into_cow; +} + pub mod external { pub use anyhow; pub use arrow2; diff --git a/crates/re_types_core/src/macros.rs b/crates/re_types_core/src/macros.rs new file mode 100644 index 000000000000..d0ba78fc6bb8 --- /dev/null +++ b/crates/re_types_core/src/macros.rs @@ -0,0 +1,19 @@ +/// Implements `From` and `From<'a Self>` for `Cow`. +#[macro_export] +macro_rules! impl_into_cow { + ($typ:ident) => { + impl<'a> From<$typ> for ::std::borrow::Cow<'a, $typ> { + #[inline] + fn from(value: $typ) -> Self { + std::borrow::Cow::Owned(value) + } + } + + impl<'a> From<&'a $typ> for ::std::borrow::Cow<'a, $typ> { + #[inline] + fn from(value: &'a $typ) -> Self { + std::borrow::Cow::Borrowed(value) + } + } + }; +} diff --git a/crates/re_types_core/src/result.rs b/crates/re_types_core/src/result.rs index eb074873cc8d..03a991f8d270 100644 --- a/crates/re_types_core/src/result.rs +++ b/crates/re_types_core/src/result.rs @@ -20,16 +20,13 @@ pub enum SerializationError { backtrace: _Backtrace, }, - #[error("arrow2-convert serialization failed: {0}")] - ArrowConvertFailure(String), - #[error("serde-based serialization (`attr.rust.serde_type`) failed: {reason}")] SerdeFailure { reason: String, backtrace: _Backtrace, }, - #[error("{fqname} doesn't support deserialization: {reason}")] + #[error("{fqname} doesn't support Serialization: {reason}")] NotImplemented { fqname: String, reason: String, @@ -87,7 +84,7 @@ impl SerializationError { Self::MissingExtensionMetadata { backtrace, .. } | Self::SerdeFailure { backtrace, .. } | Self::NotImplemented { backtrace, .. } => Some(backtrace.clone()), - SerializationError::Context { .. } | SerializationError::ArrowConvertFailure(_) => None, + SerializationError::Context { .. } => None, } } } @@ -170,9 +167,6 @@ pub enum DeserializationError { backtrace: _Backtrace, }, - #[error("arrow2-convert deserialization Failed: {0}")] - ArrowConvertFailure(String), - #[error("serde-based deserialization (`attr.rust.serde_type`) failed: {reason}")] SerdeFailure { reason: String, @@ -311,9 +305,9 @@ impl DeserializationError { | DeserializationError::OffsetOutOfBounds { backtrace, .. } | DeserializationError::OffsetSliceOutOfBounds { backtrace, .. } | DeserializationError::SerdeFailure { backtrace, .. } => Some(backtrace.clone()), - DeserializationError::ArrowConvertFailure(_) - | DeserializationError::DataCellError(_) - | DeserializationError::ValidationError(_) => None, + DeserializationError::DataCellError(_) | DeserializationError::ValidationError(_) => { + None + } } } } diff --git a/crates/re_viewer/src/blueprint/panel_view.rs b/crates/re_viewer/src/blueprint/panel_view.rs index 154bcc39a670..06ca6917ac0f 100644 --- a/crates/re_viewer/src/blueprint/panel_view.rs +++ b/crates/re_viewer/src/blueprint/panel_view.rs @@ -43,19 +43,7 @@ impl From for bool { } } -impl<'a> From for ::std::borrow::Cow<'a, PanelView> { - #[inline] - fn from(value: PanelView) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a PanelView> for ::std::borrow::Cow<'a, PanelView> { - #[inline] - fn from(value: &'a PanelView) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(PanelView); impl ::re_types_core::Loggable for PanelView { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_viewport/src/blueprint/auto_space_views.rs b/crates/re_viewport/src/blueprint/auto_space_views.rs index 090373347d3d..b1bf0c7093b0 100644 --- a/crates/re_viewport/src/blueprint/auto_space_views.rs +++ b/crates/re_viewport/src/blueprint/auto_space_views.rs @@ -42,19 +42,7 @@ impl From for bool { } } -impl<'a> From for ::std::borrow::Cow<'a, AutoSpaceViews> { - #[inline] - fn from(value: AutoSpaceViews) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a AutoSpaceViews> for ::std::borrow::Cow<'a, AutoSpaceViews> { - #[inline] - fn from(value: &'a AutoSpaceViews) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(AutoSpaceViews); impl ::re_types_core::Loggable for AutoSpaceViews { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_viewport/src/blueprint/space_view_component.rs b/crates/re_viewport/src/blueprint/space_view_component.rs index 57d4d0f4d561..2dfaf058511e 100644 --- a/crates/re_viewport/src/blueprint/space_view_component.rs +++ b/crates/re_viewport/src/blueprint/space_view_component.rs @@ -43,19 +43,7 @@ impl From for crate::SpaceViewBlueprint { } } -impl<'a> From for ::std::borrow::Cow<'a, SpaceViewComponent> { - #[inline] - fn from(value: SpaceViewComponent) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a SpaceViewComponent> for ::std::borrow::Cow<'a, SpaceViewComponent> { - #[inline] - fn from(value: &'a SpaceViewComponent) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(SpaceViewComponent); impl ::re_types_core::Loggable for SpaceViewComponent { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_viewport/src/blueprint/space_view_maximized.rs b/crates/re_viewport/src/blueprint/space_view_maximized.rs index 1ec00c288174..cd9657e559f7 100644 --- a/crates/re_viewport/src/blueprint/space_view_maximized.rs +++ b/crates/re_viewport/src/blueprint/space_view_maximized.rs @@ -42,19 +42,7 @@ impl From for Option { } } -impl<'a> From for ::std::borrow::Cow<'a, SpaceViewMaximized> { - #[inline] - fn from(value: SpaceViewMaximized) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a SpaceViewMaximized> for ::std::borrow::Cow<'a, SpaceViewMaximized> { - #[inline] - fn from(value: &'a SpaceViewMaximized) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(SpaceViewMaximized); impl ::re_types_core::Loggable for SpaceViewMaximized { type Name = ::re_types_core::ComponentName; diff --git a/crates/re_viewport/src/blueprint/viewport_layout.rs b/crates/re_viewport/src/blueprint/viewport_layout.rs index 6d490a9ca489..afc3a0d31366 100644 --- a/crates/re_viewport/src/blueprint/viewport_layout.rs +++ b/crates/re_viewport/src/blueprint/viewport_layout.rs @@ -36,19 +36,7 @@ pub struct ViewportLayout { pub auto_layout: bool, } -impl<'a> From for ::std::borrow::Cow<'a, ViewportLayout> { - #[inline] - fn from(value: ViewportLayout) -> Self { - std::borrow::Cow::Owned(value) - } -} - -impl<'a> From<&'a ViewportLayout> for ::std::borrow::Cow<'a, ViewportLayout> { - #[inline] - fn from(value: &'a ViewportLayout) -> Self { - std::borrow::Cow::Borrowed(value) - } -} +::re_types_core::macros::impl_into_cow!(ViewportLayout); impl ::re_types_core::Loggable for ViewportLayout { type Name = ::re_types_core::ComponentName; diff --git a/docs/content/reference/types/datatypes.md b/docs/content/reference/types/datatypes.md index d7a1d3ebae83..bd9c1a7050ce 100644 --- a/docs/content/reference/types/datatypes.md +++ b/docs/content/reference/types/datatypes.md @@ -30,6 +30,7 @@ Data types are the lowest layer of the data model hierarchy * [`Transform3D`](datatypes/transform3d.md) * [`TranslationAndMat3x3`](datatypes/translation_and_mat3x3.md) * [`TranslationRotationScale3D`](datatypes/translation_rotation_scale3d.md) +* [`UInt32`](datatypes/uint32.md) * [`UVec2D`](datatypes/uvec2d.md) * [`UVec3D`](datatypes/uvec3d.md) * [`UVec4D`](datatypes/uvec4d.md) diff --git a/docs/content/reference/types/datatypes/.gitattributes b/docs/content/reference/types/datatypes/.gitattributes index 5b7704c1188d..8908077d0e0b 100644 --- a/docs/content/reference/types/datatypes/.gitattributes +++ b/docs/content/reference/types/datatypes/.gitattributes @@ -24,6 +24,7 @@ tensor_dimension.md linguist-generated=true transform3d.md linguist-generated=true translation_and_mat3x3.md linguist-generated=true translation_rotation_scale3d.md linguist-generated=true +uint32.md linguist-generated=true utf8.md linguist-generated=true uvec2d.md linguist-generated=true uvec3d.md linguist-generated=true diff --git a/docs/content/reference/types/datatypes/uint32.md b/docs/content/reference/types/datatypes/uint32.md new file mode 100644 index 000000000000..29656ee2e286 --- /dev/null +++ b/docs/content/reference/types/datatypes/uint32.md @@ -0,0 +1,12 @@ +--- +title: "UInt32" +--- + +A 32bit unsigned integer. + + +## Links + * 🐍 [Python API docs for `UInt32`](https://ref.rerun.io/docs/python/stable/common/datatypes#rerun.datatypes.UInt32) + * 🦀 [Rust API docs for `UInt32`](https://docs.rs/rerun/latest/rerun/datatypes/struct.UInt32.html) + + diff --git a/rerun_cpp/src/rerun/datatypes.hpp b/rerun_cpp/src/rerun/datatypes.hpp index 1c1596c67961..db6ee81223d6 100644 --- a/rerun_cpp/src/rerun/datatypes.hpp +++ b/rerun_cpp/src/rerun/datatypes.hpp @@ -25,6 +25,7 @@ #include "datatypes/transform3d.hpp" #include "datatypes/translation_and_mat3x3.hpp" #include "datatypes/translation_rotation_scale3d.hpp" +#include "datatypes/uint32.hpp" #include "datatypes/utf8.hpp" #include "datatypes/uvec2d.hpp" #include "datatypes/uvec3d.hpp" diff --git a/rerun_cpp/src/rerun/datatypes/.gitattributes b/rerun_cpp/src/rerun/datatypes/.gitattributes index feb75fb5632a..2a5bb68060ed 100644 --- a/rerun_cpp/src/rerun/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/datatypes/.gitattributes @@ -47,6 +47,8 @@ translation_and_mat3x3.cpp linguist-generated=true translation_and_mat3x3.hpp linguist-generated=true translation_rotation_scale3d.cpp linguist-generated=true translation_rotation_scale3d.hpp linguist-generated=true +uint32.cpp linguist-generated=true +uint32.hpp linguist-generated=true utf8.cpp linguist-generated=true utf8.hpp linguist-generated=true uvec2d.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/datatypes/uint32.cpp b/rerun_cpp/src/rerun/datatypes/uint32.cpp new file mode 100644 index 000000000000..6715bb5cc6e5 --- /dev/null +++ b/rerun_cpp/src/rerun/datatypes/uint32.cpp @@ -0,0 +1,47 @@ +// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/re_types/definitions/rerun/datatypes/uint32.fbs". + +#include "uint32.hpp" + +#include +#include + +namespace rerun { + namespace datatypes { + const std::shared_ptr& UInt32::arrow_datatype() { + static const auto datatype = arrow::uint32(); + return datatype; + } + + Result> UInt32::new_arrow_array_builder( + arrow::MemoryPool* memory_pool + ) { + if (memory_pool == nullptr) { + return Error(ErrorCode::UnexpectedNullArgument, "Memory pool is null."); + } + + return Result(std::make_shared(memory_pool)); + } + + Error UInt32::fill_arrow_array_builder( + arrow::UInt32Builder* builder, const UInt32* elements, size_t num_elements + ) { + if (builder == nullptr) { + return Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); + } + if (elements == nullptr) { + return Error( + ErrorCode::UnexpectedNullArgument, + "Cannot serialize null pointer to arrow array." + ); + } + + static_assert(sizeof(*elements) == sizeof(elements->value)); + ARROW_RETURN_NOT_OK( + builder->AppendValues(&elements->value, static_cast(num_elements)) + ); + + return Error::ok(); + } + } // namespace datatypes +} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/uint32.hpp b/rerun_cpp/src/rerun/datatypes/uint32.hpp new file mode 100644 index 000000000000..17335cbdac2c --- /dev/null +++ b/rerun_cpp/src/rerun/datatypes/uint32.hpp @@ -0,0 +1,52 @@ +// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/re_types/definitions/rerun/datatypes/uint32.fbs". + +#pragma once + +#include "../result.hpp" + +#include +#include +#include + +namespace arrow { + template + class NumericBuilder; + + class DataType; + class MemoryPool; + class UInt32Type; + using UInt32Builder = NumericBuilder; +} // namespace arrow + +namespace rerun { + namespace datatypes { + /// **Datatype**: A 32bit unsigned integer. + struct UInt32 { + uint32_t value; + + public: + UInt32() = default; + + UInt32(uint32_t _value) : value(std::move(_value)) {} + + UInt32& operator=(uint32_t _value) { + value = std::move(_value); + return *this; + } + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype(); + + /// Creates a new array builder with an array of this type. + static Result> new_arrow_array_builder( + arrow::MemoryPool* memory_pool + ); + + /// Fills an arrow array builder with an array of this type. + static Error fill_arrow_array_builder( + arrow::UInt32Builder* builder, const UInt32* elements, size_t num_elements + ); + }; + } // namespace datatypes +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes index b8fb7c7c8dab..5d1fe077b76f 100644 --- a/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes @@ -25,6 +25,7 @@ tensor_dimension.py linguist-generated=true transform3d.py linguist-generated=true translation_and_mat3x3.py linguist-generated=true translation_rotation_scale3d.py linguist-generated=true +uint32.py linguist-generated=true utf8.py linguist-generated=true uvec2d.py linguist-generated=true uvec3d.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/datatypes/__init__.py index 69391c80fcb1..aa7a383709e2 100644 --- a/rerun_py/rerun_sdk/rerun/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/datatypes/__init__.py @@ -73,6 +73,7 @@ TranslationRotationScale3DLike, TranslationRotationScale3DType, ) +from .uint32 import UInt32, UInt32ArrayLike, UInt32Batch, UInt32Like, UInt32Type from .utf8 import Utf8, Utf8ArrayLike, Utf8Batch, Utf8Like, Utf8Type from .uvec2d import UVec2D, UVec2DArrayLike, UVec2DBatch, UVec2DLike, UVec2DType from .uvec3d import UVec3D, UVec3DArrayLike, UVec3DBatch, UVec3DLike, UVec3DType @@ -197,6 +198,11 @@ "TranslationRotationScale3DBatch", "TranslationRotationScale3DLike", "TranslationRotationScale3DType", + "UInt32", + "UInt32ArrayLike", + "UInt32Batch", + "UInt32Like", + "UInt32Type", "UVec2D", "UVec2DArrayLike", "UVec2DBatch", diff --git a/rerun_py/rerun_sdk/rerun/datatypes/uint32.py b/rerun_py/rerun_sdk/rerun/datatypes/uint32.py new file mode 100644 index 000000000000..478a66c2ec2a --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/datatypes/uint32.py @@ -0,0 +1,59 @@ +# DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/python.rs +# Based on "crates/re_types/definitions/rerun/datatypes/uint32.fbs". + +# You can extend this class by creating a "UInt32Ext" class in "uint32_ext.py". + +from __future__ import annotations + +from typing import Any, Sequence, Union + +import numpy as np +import numpy.typing as npt +import pyarrow as pa +from attrs import define, field + +from .._baseclasses import BaseBatch, BaseExtensionType + +__all__ = ["UInt32", "UInt32ArrayLike", "UInt32Batch", "UInt32Like", "UInt32Type"] + + +@define(init=False) +class UInt32: + """**Datatype**: A 32bit unsigned integer.""" + + def __init__(self: Any, value: UInt32Like): + """Create a new instance of the UInt32 datatype.""" + + # You can define your own __init__ function as a member of UInt32Ext in uint32_ext.py + self.__attrs_init__(value=value) + + value: int = field(converter=int) + + def __array__(self, dtype: npt.DTypeLike = None) -> npt.NDArray[Any]: + # You can define your own __array__ function as a member of UInt32Ext in uint32_ext.py + return np.asarray(self.value, dtype=dtype) + + def __int__(self) -> int: + return int(self.value) + + +UInt32Like = UInt32 +UInt32ArrayLike = Union[ + UInt32, + Sequence[UInt32Like], +] + + +class UInt32Type(BaseExtensionType): + _TYPE_NAME: str = "rerun.datatypes.UInt32" + + def __init__(self) -> None: + pa.ExtensionType.__init__(self, pa.uint32(), self._TYPE_NAME) + + +class UInt32Batch(BaseBatch[UInt32ArrayLike]): + _ARROW_TYPE = UInt32Type() + + @staticmethod + def _native_to_pa_array(data: UInt32ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError # You need to implement native_to_pa_array_override in uint32_ext.py diff --git a/scripts/lint.py b/scripts/lint.py index 7a8d2c3276de..0538df7b7932 100755 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -659,6 +659,7 @@ def main() -> None: "./.github/workflows/reusable_checks.yml", # zombie TODO hunting job "./CODE_STYLE.md", "./crates/re_types_builder/src/reflection.rs", # auto-generated + "./examples/python/detect_and_track_objects/cache/version.txt", "./examples/rust/objectron/src/objectron.rs", # auto-generated "./scripts/lint.py", # we contain all the patterns we are linting against "./scripts/zombie_todos.py",