Trait re_sdk::AsComponents
source · pub trait AsComponents {
// Required method
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>;
// Provided methods
fn num_instances(&self) -> usize { ... }
fn to_arrow(
&self
) -> Result<Vec<(Field, Box<dyn Array>)>, SerializationError> { ... }
}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 example to learn more about handwritten bundles.
Required Methods§
sourcefn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
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 example to learn more about extending archetypes.
Provided Methods§
sourcefn num_instances(&self) -> usize
fn num_instances(&self) -> usize
The number of instances in each batch.
If not implemented, the number of instances will be determined by the longest batch in the bundle.
Each batch returned by as_component_batches should have this number of elements,
or 1 in the case it is a splat, or 0 in the case that component is being cleared.
sourcefn to_arrow(&self) -> Result<Vec<(Field, Box<dyn Array>)>, SerializationError>
fn to_arrow(&self) -> Result<Vec<(Field, Box<dyn Array>)>, SerializationError>
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.