Skip to content

Implement new AsComponents trait/protocol #3383

@jleibs

Description

@jleibs

This is the minimal API surface needed to be provided by a user to log a custom thing.

In python:

class AsComponents(Protocol):
    """Describes interface for interpreting an object as a collection of Rerun Components."""

    def as_component_batches(self) -> Iterable[ComponentBatchLike]:
        """
        Returns an iterable of `ComponentBatchLike` objects.

        Each object in the iterable must adhere to the `ComponentBatchLike`
        interface. All of the batches should have the same length, or length 1
        if the component is a splat, or 0 if the component is being cleared.
        """ 

def log(
    entity_path: str,
    entity: AsComponents | Iterable[ComponentBatchLike],
    timeless: bool = False,
    recording: RecordingStream | None = None,
) -> None:

In rust:

pub trait AsComponents
    #[inline]
    fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>> {
        vec![]
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions