From 2e2a98838c862866ea584984cfe240f755ffd48a Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 23 Aug 2024 12:47:52 +0200 Subject: [PATCH] Remove `Datatype` and `DatatypeBatch` (#7256) Remove unused old traits. Part of a lot of clean up I want to while we head towards: * https://github.com/rerun-io/rerun/issues/7245 * #3741 --- crates/store/re_types/src/lib.rs | 2 +- crates/store/re_types_core/src/lib.rs | 8 +++--- crates/store/re_types_core/src/loggable.rs | 21 ++++---------- .../store/re_types_core/src/loggable_batch.rs | 28 +------------------ crates/top/re_sdk/src/lib.rs | 6 ++-- docs/snippets/all/tutorials/custom_data.rs | 2 +- 6 files changed, 16 insertions(+), 51 deletions(-) diff --git a/crates/store/re_types/src/lib.rs b/crates/store/re_types/src/lib.rs index 97fd657e0949..be1e099670d1 100644 --- a/crates/store/re_types/src/lib.rs +++ b/crates/store/re_types/src/lib.rs @@ -227,7 +227,7 @@ pub mod components { /// The low-level datatypes that [`components`] are built from. /// -/// They all implement the [`Datatype`] trait. +/// They all implement the [`Loggable`] trait. pub mod datatypes { // Some datatypes are so fundamental and used everywhere that we want them to be exposed diff --git a/crates/store/re_types_core/src/lib.rs b/crates/store/re_types_core/src/lib.rs index bf3145ca491d..86fa6374cf42 100644 --- a/crates/store/re_types_core/src/lib.rs +++ b/crates/store/re_types_core/src/lib.rs @@ -9,7 +9,7 @@ //! When multiple instances of a [`Component`] are put together in an array, they yield a //! [`ComponentBatch`]: the atomic unit of (de)serialization. //! -//! Internally, [`Component`]s are implemented using many different [`Datatype`]s. +//! Internally, [`Component`]s are implemented using many different [`Loggable`]s. //! //! ## Feature flags #![doc = document_features::document_features!()] @@ -95,8 +95,8 @@ pub use self::{ }, arrow_buffer::ArrowBuffer, arrow_string::ArrowString, - loggable::{Component, ComponentName, ComponentNameSet, Datatype, DatatypeName, Loggable}, - loggable_batch::{ComponentBatch, DatatypeBatch, LoggableBatch, MaybeOwnedComponentBatch}, + loggable::{Component, ComponentName, ComponentNameSet, DatatypeName, Loggable}, + loggable_batch::{ComponentBatch, LoggableBatch, MaybeOwnedComponentBatch}, result::{ DeserializationError, DeserializationResult, ResultExt, SerializationError, SerializationResult, _Backtrace, @@ -117,7 +117,7 @@ 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 +/// Fundamental datatypes that are implemented in `re_types_core` directly for convenience and /// dependency optimization. /// /// There are also re-exported by `re_types`. diff --git a/crates/store/re_types_core/src/loggable.rs b/crates/store/re_types_core/src/loggable.rs index 8f4871fe5bfb..cd84f6d9ca56 100644 --- a/crates/store/re_types_core/src/loggable.rs +++ b/crates/store/re_types_core/src/loggable.rs @@ -5,7 +5,7 @@ use crate::{ }; #[allow(unused_imports)] // used in docstrings -use crate::{Archetype, ComponentBatch, DatatypeBatch, LoggableBatch}; +use crate::{Archetype, ComponentBatch, LoggableBatch}; // --- @@ -14,13 +14,12 @@ use crate::{Archetype, ComponentBatch, DatatypeBatch, LoggableBatch}; /// Internally, Arrow, and by extension Rerun, only deal with arrays of data. /// We refer to individual entries in these arrays as instances. /// -/// [`Datatype`] and [`Component`] are specialization of the [`Loggable`] trait that are -/// automatically implemented based on the type used for [`Loggable::Name`]. +/// [`Component`] is a specialization of the [`Loggable`] trait where [`Loggable::Name`] == +/// [`ComponentName`]. /// -/// Implementing the [`Loggable`] trait (and by extension [`Datatype`]/[`Component`]) -/// automatically derives the [`LoggableBatch`] implementation (and by extension -/// [`DatatypeBatch`]/[`ComponentBatch`]), which makes it possible to work with lists' worth of data -/// in a generic fashion. +/// Implementing the [`Loggable`] trait (and by extension [`Component`]) automatically derives the +/// [`LoggableBatch`] implementation (and by extension [`ComponentBatch`]), which makes it possible to +/// work with lists' worth of data in a generic fashion. pub trait Loggable: 'static + Send + Sync + Clone + Sized + SizeBytes { type Name: std::fmt::Display; @@ -127,14 +126,6 @@ pub trait Loggable: 'static + Send + Sync + Clone + Sized + SizeBytes { } } -/// A [`Datatype`] describes plain old data that can be used by any number of [`Component`]s. -/// -/// Any [`Loggable`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically implements -/// [`Datatype`]. -pub trait Datatype: Loggable {} - -impl> Datatype for L {} - /// A [`Component`] describes semantic data that can be used by any number of [`Archetype`]s. /// /// Any [`Loggable`] with a [`Loggable::Name`] set to [`ComponentName`] automatically implements diff --git a/crates/store/re_types_core/src/loggable_batch.rs b/crates/store/re_types_core/src/loggable_batch.rs index 46f34f177166..d7a9d6b5e2b2 100644 --- a/crates/store/re_types_core/src/loggable_batch.rs +++ b/crates/store/re_types_core/src/loggable_batch.rs @@ -1,4 +1,4 @@ -use crate::{Component, ComponentName, Datatype, DatatypeName, Loggable, SerializationResult}; +use crate::{Component, ComponentName, Loggable, SerializationResult}; #[allow(unused_imports)] // used in docstrings use crate::Archetype; @@ -34,12 +34,6 @@ pub trait LoggableBatch { fn to_arrow(&self) -> SerializationResult>; } -/// A [`DatatypeBatch`] represents an array's worth of [`Datatype`] instances. -/// -/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`DatatypeName`] automatically -/// implements [`DatatypeBatch`]. -pub trait DatatypeBatch: LoggableBatch {} - /// A [`ComponentBatch`] represents an array's worth of [`Component`] instances. /// /// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`ComponentName`] automatically @@ -143,8 +137,6 @@ impl LoggableBatch for L { } } -impl DatatypeBatch for D {} - impl ComponentBatch for C {} // --- Unary Option --- @@ -173,8 +165,6 @@ impl LoggableBatch for Option { } } -impl DatatypeBatch for Option {} - impl ComponentBatch for Option {} // --- Vec --- @@ -203,8 +193,6 @@ impl LoggableBatch for Vec { } } -impl DatatypeBatch for Vec {} - impl ComponentBatch for Vec {} // --- Vec