pub trait ComponentBatch {
// Required method
fn to_arrow(&self) -> Result<Arc<dyn Array>, SerializationError>;
// Provided methods
fn to_arrow_list_array(
&self,
) -> Result<GenericListArray<i32>, SerializationError> { ... }
fn serialized(
&self,
component_descr: ComponentDescriptor,
) -> Option<SerializedComponentBatch> { ... }
fn try_serialized(
&self,
component_descr: ComponentDescriptor,
) -> Result<SerializedComponentBatch, SerializationError> { ... }
}Expand description
A ComponentBatch represents an array’s worth of Loggable instances, ready to be
serialized.
ComponentBatch is carefully designed to be erasable (“object-safe”), so that it is possible
to build heterogeneous collections of ComponentBatchs (e.g. Vec<dyn ComponentBatch>).
This erasability is what makes extending Archetypes possible with little effort.
You should almost never need to implement ComponentBatch manually, as it is already
blanket implemented for most common use cases (arrays/vectors/slices of loggables, etc).
Required Methods§
Provided Methods§
Sourcefn to_arrow_list_array(
&self,
) -> Result<GenericListArray<i32>, SerializationError>
fn to_arrow_list_array( &self, ) -> Result<GenericListArray<i32>, SerializationError>
Serializes the batch into an Arrow list array with a single component per list.
Sourcefn serialized(
&self,
component_descr: ComponentDescriptor,
) -> Option<SerializedComponentBatch>
fn serialized( &self, component_descr: ComponentDescriptor, ) -> Option<SerializedComponentBatch>
Serializes the contents of this ComponentBatch.
Once serialized, the data is ready to be logged into Rerun via the AsComponents trait.
§Fallibility
There are very few ways in which serialization can fail, all of which are very rare to hit
in practice.
One such example is trying to serialize data with more than 2^31 elements into a ListArray.
For that reason, this method favors a nice user experience over error handling: errors will merely be logged, not returned (except in debug builds, where all errors panic).
See also ComponentBatch::try_serialized.
Sourcefn try_serialized(
&self,
component_descr: ComponentDescriptor,
) -> Result<SerializedComponentBatch, SerializationError>
fn try_serialized( &self, component_descr: ComponentDescriptor, ) -> Result<SerializedComponentBatch, SerializationError>
Serializes the contents of this ComponentBatch.
Once serialized, the data is ready to be logged into Rerun via the AsComponents trait.
§Fallibility
There are very few ways in which serialization can fail, all of which are very rare to hit in practice.
For that reason, it generally makes sense to favor a nice user experience over error handling
in most cases, see ComponentBatch::serialized.