Trait ComponentBatch

Source
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§

Source

fn to_arrow(&self) -> Result<Arc<dyn Array>, SerializationError>

Serializes the batch into an Arrow array.

Provided Methods§

Source

fn to_arrow_list_array( &self, ) -> Result<GenericListArray<i32>, SerializationError>

Serializes the batch into an Arrow list array with a single component per list.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<L> ComponentBatch for Option<L>
where L: Clone + Loggable,

Source§

impl<L> ComponentBatch for [L]
where L: Loggable,

Source§

impl<L> ComponentBatch for Vec<Option<L>>
where L: Loggable,

Source§

impl<L> ComponentBatch for Vec<L>
where L: Clone + Loggable,

Source§

impl<L> ComponentBatch for [Option<L>]
where L: Loggable,

Source§

impl<L, const N: usize> ComponentBatch for [L; N]
where L: Loggable,

Source§

impl<L, const N: usize> ComponentBatch for [Option<L>; N]
where L: Loggable,

Implementors§

Source§

impl<L> ComponentBatch for L
where L: Clone + Loggable,