Trait re_types_core::AsComponents

source ·
pub trait AsComponents {
    // Required method
    fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>;

    // Provided method
    fn to_arrow(&self) -> SerializationResult<Vec<(Field, Box<dyn Array>)>> { ... }
}
Expand description

Describes the interface for interpreting an object as a bundle of Components.

§Custom bundles

While, in most cases, component bundles are code generated from our IDL definitions, it is possible to manually extend existing bundles, or even implement fully custom ones.

All AsComponents methods are optional to implement, with the exception of AsComponents::as_component_batches, which describes how the bundle can be interpreted as a set of ComponentBatches: arrays of components that are ready to be serialized.

Have a look at our Custom Data Loader example to learn more about handwritten bundles.

Required Methods§

source

fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>

Exposes the object’s contents as a set of ComponentBatchs.

This is the main mechanism for easily extending builtin archetypes or even writing fully custom ones. Have a look at our Custom Data Loader example to learn more about extending archetypes.

Provided Methods§

source

fn to_arrow(&self) -> SerializationResult<Vec<(Field, Box<dyn Array>)>>

Serializes all non-null Components of this bundle into Arrow arrays.

The default implementation will simply serialize the result of Self::as_component_batches as-is, which is what you want in 99.9% of cases.

Implementors§