Trait re_types_core::Archetype

source ·
pub trait Archetype {
    type Indicator: 'static + ComponentBatch + Default;

    // Required methods
    fn name() -> ArchetypeName;
    fn required_components() -> Cow<'static, [ComponentName]>;

    // Provided methods
    fn indicator() -> MaybeOwnedComponentBatch<'static> { ... }
    fn recommended_components() -> Cow<'static, [ComponentName]> { ... }
    fn optional_components() -> Cow<'static, [ComponentName]> { ... }
    fn all_components() -> Cow<'static, [ComponentName]> { ... }
    fn from_arrow(
        data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
    ) -> DeserializationResult<Self>
       where Self: Sized { ... }
    fn from_arrow_components(
        data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>
    ) -> DeserializationResult<Self>
       where Self: Sized { ... }
}
Expand description

An archetype is a high-level construct that represents a set of Components that usually play well with each other (i.e. they compose nicely).

Internally, it is no different than a collection of components, but working at that higher layer of abstraction opens opportunities for nicer APIs & tools that wouldn’t be possible otherwise.

E.g. consider the crate::archetypes::Points3D archetype, which represents the set of components to consider when working with a 3D point cloud within Rerun.

Required Associated Types§

source

type Indicator: 'static + ComponentBatch + Default

The associated indicator component, whose presence indicates that the high-level archetype-based APIs were used to log the data.

§Internal representation

Indicator components are always-splatted null arrays. Their names follow the pattern rerun.components.{ArchetypeName}Indicator, e.g. rerun.components.Points3DIndicator.

Since null arrays aren’t actually arrays and we don’t actually have any data to shuffle around per-se, we can’t implement the usual Loggable traits. For this reason, indicator components directly implement LoggableBatch instead, and bypass the entire iterator machinery.

Required Methods§

source

fn name() -> ArchetypeName

The fully-qualified name of this archetype, e.g. rerun.archetypes.Points2D.

source

fn required_components() -> Cow<'static, [ComponentName]>

Returns the names of all components that must be provided by the user when constructing this archetype.

Provided Methods§

source

fn indicator() -> MaybeOwnedComponentBatch<'static>

Creates a ComponentBatch out of the associated Self::Indicator component.

This allows for associating arbitrary indicator components with arbitrary data. Check out the manual_indicator API example to see what’s possible.

source

fn recommended_components() -> Cow<'static, [ComponentName]>

Returns the names of all components that should be provided by the user when constructing this archetype.

source

fn optional_components() -> Cow<'static, [ComponentName]>

Returns the names of all components that may be provided by the user when constructing this archetype.

source

fn all_components() -> Cow<'static, [ComponentName]>

Returns the names of all components that must, should and may be provided by the user when constructing this archetype.

The default implementation always does the right thing, at the cost of some runtime allocations. If you know all your components statically, you can override this method to get rid of the extra allocations.

source

fn from_arrow( data: impl IntoIterator<Item = (Field, Box<dyn Array>)> ) -> DeserializationResult<Self>
where Self: Sized,

Given an iterator of Arrow arrays and their respective field metadata, deserializes them into this archetype.

Arrow arrays that are unknown to this Archetype will simply be ignored and a warning logged to stderr.

source

fn from_arrow_components( data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> DeserializationResult<Self>
where Self: Sized,

Given an iterator of Arrow arrays and their respective ComponentNames, deserializes them into this archetype.

Arrow arrays that are unknown to this Archetype will simply be ignored and a warning logged to stderr.

Object Safety§

This trait is not object safe.

Implementors§