Trait rerun::AsComponents
source · pub trait AsComponents {
// Required method
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>;
// Provided method
fn to_arrow(
&self
) -> Result<Vec<(Field, Box<dyn Array>)>, SerializationError> { ... }
}
Expand description
Describes the interface for interpreting an object as a bundle of Component
s.
§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 ComponentBatch
es: 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§
sourcefn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
Exposes the object’s contents as a set of ComponentBatch
s.
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§
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 Component
s 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.