re_types

Trait Archetype

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

    // Required methods
    fn name() -> ArchetypeName;
    fn display_name() -> &'static str;
    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>)>,
    ) -> Result<Self, DeserializationError>
       where Self: Sized { ... }
    fn from_arrow_components(
        data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>,
    ) -> Result<Self, DeserializationError>
       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 unit-length 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 display_name() -> &'static str

Readable name for displaying in ui.

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>)>, ) -> Result<Self, DeserializationError>
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>)>, ) -> Result<Self, DeserializationError>
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Archetype for MyPoints

Implementors§

Source§

impl Archetype for AnnotationContext

Source§

impl Archetype for Arrows2D

Source§

impl Archetype for Arrows3D

Source§

impl Archetype for Asset3D

Source§

impl Archetype for AssetVideo

Source§

impl Archetype for BarChart

Source§

impl Archetype for Boxes2D

Source§

impl Archetype for Boxes3D

Source§

impl Archetype for Capsules3D

Source§

impl Archetype for Clear

Source§

impl Archetype for DepthImage

Source§

impl Archetype for DisconnectedSpace

Source§

impl Archetype for Ellipsoids3D

Source§

impl Archetype for EncodedImage

Source§

impl Archetype for GeoLineStrings

Source§

impl Archetype for GeoPoints

Source§

impl Archetype for Image

Source§

impl Archetype for InstancePoses3D

Source§

impl Archetype for LineStrips2D

Source§

impl Archetype for LineStrips3D

Source§

impl Archetype for Mesh3D

Source§

impl Archetype for Pinhole

Source§

impl Archetype for Points2D

Source§

impl Archetype for Points3D

Source§

impl Archetype for Scalar

Source§

impl Archetype for SegmentationImage

Source§

impl Archetype for SeriesLine

Source§

impl Archetype for SeriesPoint

Source§

impl Archetype for Tensor

Source§

impl Archetype for TextDocument

Source§

impl Archetype for TextLog

Source§

impl Archetype for Transform3D

Source§

impl Archetype for VideoFrameReference

Source§

impl Archetype for ViewCoordinates

Source§

impl Archetype for Background

Source§

impl Archetype for DataframeQuery

Source§

impl Archetype for MapBackground

Source§

impl Archetype for MapZoom

Source§

impl Archetype for PlotLegend

Source§

impl Archetype for ScalarAxis

Source§

impl Archetype for SpaceViewBlueprint

Source§

impl Archetype for SpaceViewContents

Source§

impl Archetype for TensorScalarMapping

Source§

impl Archetype for TensorSliceSelection

Source§

impl Archetype for TensorViewFit

Source§

impl Archetype for VisibleTimeRanges

Source§

impl Archetype for VisualBounds2D