pub trait Loggable: Sized + 'static + Send + Sync + Clone + SizeBytes {
type Name: Display;
// Required methods
fn name() -> Self::Name;
fn arrow_datatype() -> DataType;
fn to_arrow_opt<'a>(
data: impl IntoIterator<Item = Option<impl Into<Cow<'a, Self>>>>
) -> Result<Box<dyn Array>, SerializationError>
where Self: 'a;
// Provided methods
fn extended_arrow_datatype() -> DataType { ... }
fn arrow_field() -> Field { ... }
fn to_arrow<'a>(
data: impl IntoIterator<Item = impl Into<Cow<'a, Self>>>
) -> Result<Box<dyn Array>, SerializationError>
where Self: 'a { ... }
fn from_arrow(
data: &(dyn Array + 'static)
) -> Result<Vec<Self>, DeserializationError> { ... }
fn from_arrow_opt(
data: &(dyn Array + 'static)
) -> Result<Vec<Option<Self>>, DeserializationError> { ... }
}
Expand description
A Loggable
represents a single instance in an array of loggable data.
Internally, Arrow, and by extension Rerun, only deal with arrays of data. We refer to individual entries in these arrays as instances.
Datatype
and Component
are specialization of the Loggable
trait that are
automatically implemented based on the type used for Loggable::Name
.
Implementing the Loggable
trait (and by extension Datatype
/Component
)
automatically derives the LoggableBatch
implementation (and by extension
DatatypeBatch
/ComponentBatch
), which makes it possible to work with lists’ worth of data
in a generic fashion.
Required Associated Types§
Required Methods§
sourcefn arrow_datatype() -> DataType
fn arrow_datatype() -> DataType
The underlying arrow2::datatypes::DataType
, excluding datatype extensions.
sourcefn to_arrow_opt<'a>(
data: impl IntoIterator<Item = Option<impl Into<Cow<'a, Self>>>>
) -> Result<Box<dyn Array>, SerializationError>where
Self: 'a,
fn to_arrow_opt<'a>(
data: impl IntoIterator<Item = Option<impl Into<Cow<'a, Self>>>>
) -> Result<Box<dyn Array>, SerializationError>where
Self: 'a,
Given an iterator of options of owned or reference values to the current
Loggable
, serializes them into an Arrow array.
The Arrow array’s datatype will match Loggable::arrow_field
.
When using Rerun’s builtin components & datatypes, this can only fail if the data exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, 2^63 for large arrays).
Provided Methods§
sourcefn extended_arrow_datatype() -> DataType
fn extended_arrow_datatype() -> DataType
The underlying arrow2::datatypes::DataType
, including datatype extensions.
The default implementation will simply wrap Self::arrow_datatype
in an extension called
Self::name
, which is what you want in most cases.
sourcefn arrow_field() -> Field
fn arrow_field() -> Field
The underlying arrow2::datatypes::Field
, including datatype extensions.
The default implementation will simply wrap Self::extended_arrow_datatype
in a
arrow2::datatypes::Field
, which is what you want in most cases (e.g. because you want
to declare the field as nullable).
sourcefn to_arrow<'a>(
data: impl IntoIterator<Item = impl Into<Cow<'a, Self>>>
) -> Result<Box<dyn Array>, SerializationError>where
Self: 'a,
fn to_arrow<'a>(
data: impl IntoIterator<Item = impl Into<Cow<'a, Self>>>
) -> Result<Box<dyn Array>, SerializationError>where
Self: 'a,
Given an iterator of owned or reference values to the current Loggable
, serializes
them into an Arrow array.
The Arrow array’s datatype will match Loggable::arrow_field
.
When using Rerun’s builtin components & datatypes, this can only fail if the data exceeds the maximum number of entries in an Arrow array (2^31 for standard arrays, 2^63 for large arrays).
sourcefn from_arrow(
data: &(dyn Array + 'static)
) -> Result<Vec<Self>, DeserializationError>
fn from_arrow( data: &(dyn Array + 'static) ) -> Result<Vec<Self>, DeserializationError>
Given an Arrow array, deserializes it into a collection of Loggable
s.
This will never fail if the Arrow array’s datatype matches the one returned by
Loggable::arrow_field
.
sourcefn from_arrow_opt(
data: &(dyn Array + 'static)
) -> Result<Vec<Option<Self>>, DeserializationError>
fn from_arrow_opt( data: &(dyn Array + 'static) ) -> Result<Vec<Option<Self>>, DeserializationError>
Given an Arrow array, deserializes it into a collection of optional Loggable
s.
This will never fail if the Arrow array’s datatype matches the one returned by
Loggable::arrow_field
.