Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused Datatype and DatatypeBatch #7256

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/store/re_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions crates/store/re_types_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!()]
Expand Down Expand Up @@ -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,
Expand All @@ -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`.
Expand Down
21 changes: 6 additions & 15 deletions crates/store/re_types_core/src/loggable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};

#[allow(unused_imports)] // used in docstrings
use crate::{Archetype, ComponentBatch, DatatypeBatch, LoggableBatch};
use crate::{Archetype, ComponentBatch, LoggableBatch};

// ---

Expand All @@ -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;

Expand Down Expand Up @@ -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<Name = DatatypeName> {}

impl<L: Loggable<Name = DatatypeName>> 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
Expand Down
28 changes: 1 addition & 27 deletions crates/store/re_types_core/src/loggable_batch.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -34,12 +34,6 @@ pub trait LoggableBatch {
fn to_arrow(&self) -> SerializationResult<Box<dyn ::arrow2::array::Array>>;
}

/// 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<Name = DatatypeName> {}

/// A [`ComponentBatch`] represents an array's worth of [`Component`] instances.
///
/// Any [`LoggableBatch`] with a [`Loggable::Name`] set to [`ComponentName`] automatically
Expand Down Expand Up @@ -143,8 +137,6 @@ impl<L: Clone + Loggable> LoggableBatch for L {
}
}

impl<D: Datatype> DatatypeBatch for D {}

impl<C: Component> ComponentBatch for C {}

// --- Unary Option ---
Expand Down Expand Up @@ -173,8 +165,6 @@ impl<L: Clone + Loggable> LoggableBatch for Option<L> {
}
}

impl<D: Datatype> DatatypeBatch for Option<D> {}

impl<C: Component> ComponentBatch for Option<C> {}

// --- Vec ---
Expand Down Expand Up @@ -203,8 +193,6 @@ impl<L: Clone + Loggable> LoggableBatch for Vec<L> {
}
}

impl<D: Datatype> DatatypeBatch for Vec<D> {}

impl<C: Component> ComponentBatch for Vec<C> {}

// --- Vec<Option> ---
Expand Down Expand Up @@ -236,8 +224,6 @@ impl<L: Loggable> LoggableBatch for Vec<Option<L>> {
}
}

impl<D: Datatype> DatatypeBatch for Vec<Option<D>> {}

impl<C: Component> ComponentBatch for Vec<Option<C>> {}

// --- Array ---
Expand Down Expand Up @@ -266,8 +252,6 @@ impl<L: Loggable, const N: usize> LoggableBatch for [L; N] {
}
}

impl<D: Datatype, const N: usize> DatatypeBatch for [D; N] {}

impl<C: Component, const N: usize> ComponentBatch for [C; N] {}

// --- Array<Option> ---
Expand Down Expand Up @@ -299,8 +283,6 @@ impl<L: Loggable, const N: usize> LoggableBatch for [Option<L>; N] {
}
}

impl<D: Datatype, const N: usize> DatatypeBatch for [Option<D>; N] {}

impl<C: Component, const N: usize> ComponentBatch for [Option<C>; N] {}

// --- Slice ---
Expand Down Expand Up @@ -329,8 +311,6 @@ impl<'a, L: Loggable> LoggableBatch for &'a [L] {
}
}

impl<'a, D: Datatype> DatatypeBatch for &'a [D] {}

impl<'a, C: Component> ComponentBatch for &'a [C] {}

// --- Slice<Option> ---
Expand Down Expand Up @@ -362,8 +342,6 @@ impl<'a, L: Loggable> LoggableBatch for &'a [Option<L>] {
}
}

impl<'a, D: Datatype> DatatypeBatch for &'a [Option<D>] {}

impl<'a, C: Component> ComponentBatch for &'a [Option<C>] {}

// --- ArrayRef ---
Expand Down Expand Up @@ -392,8 +370,6 @@ impl<'a, L: Loggable, const N: usize> LoggableBatch for &'a [L; N] {
}
}

impl<'a, D: Datatype, const N: usize> DatatypeBatch for &'a [D; N] {}

impl<'a, C: Component, const N: usize> ComponentBatch for &'a [C; N] {}

// --- ArrayRef<Option> ---
Expand Down Expand Up @@ -425,6 +401,4 @@ impl<'a, L: Loggable, const N: usize> LoggableBatch for &'a [Option<L>; N] {
}
}

impl<'a, D: Datatype, const N: usize> DatatypeBatch for &'a [Option<D>; N] {}

impl<'a, C: Component, const N: usize> ComponentBatch for &'a [Option<C>; N] {}
6 changes: 3 additions & 3 deletions crates/top/re_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ pub mod time {
pub use time::{Time, TimePoint, Timeline};

pub use re_types_core::{
Archetype, ArchetypeName, AsComponents, Component, ComponentBatch, ComponentName, Datatype,
DatatypeBatch, DatatypeName, GenericIndicatorComponent, Loggable, LoggableBatch,
MaybeOwnedComponentBatch, NamedIndicatorComponent, SizeBytes,
Archetype, ArchetypeName, AsComponents, Component, ComponentBatch, ComponentName, DatatypeName,
GenericIndicatorComponent, Loggable, LoggableBatch, MaybeOwnedComponentBatch,
NamedIndicatorComponent, SizeBytes,
};

#[cfg(feature = "data_loaders")]
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/tutorials/custom_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl rerun::AsComponents for CustomPoints3D {

// ---

/// A custom [`rerun::Component`] that is backed by a builtin [`rerun::Float32`] scalar [`rerun::Datatype`].
/// A custom [`rerun::Component`] that is backed by a builtin [`rerun::Float32`] scalar.
#[derive(Debug, Clone, Copy)]
struct Confidence(rerun::Float32);

Expand Down
Loading