#![doc = document_features::document_features!()]
pub const DEFAULT_DISPLAY_DECIMALS: usize = 3;
mod archetype;
pub mod arrow_helpers;
mod arrow_string;
pub mod arrow_zip_validity;
mod as_components;
mod component_descriptor;
mod id;
mod loggable;
mod loggable_batch;
pub mod reflection;
mod result;
mod tuid;
mod view;
pub use self::{
archetype::{
Archetype, ArchetypeFieldName, ArchetypeName, ArchetypeReflectionMarker,
GenericIndicatorComponent, NamedIndicatorComponent,
},
arrow_string::ArrowString,
as_components::AsComponents,
component_descriptor::ComponentDescriptor,
id::{ChunkId, RowId},
loggable::{
Component, ComponentName, ComponentNameSet, DatatypeName, Loggable,
UnorderedComponentNameSet,
},
loggable_batch::{
ComponentBatch, LoggableBatch, SerializedComponentBatch, SerializedComponentColumn,
},
result::{
DeserializationError, DeserializationResult, ResultExt, SerializationError,
SerializationResult, _Backtrace,
},
tuid::tuids_to_arrow,
view::{View, ViewClassIdentifier},
};
pub mod archetypes;
pub mod components;
pub mod datatypes;
#[path = "macros.rs"]
mod _macros;
pub mod macros {
pub use super::impl_into_cow;
}
pub mod external {
pub use anyhow;
pub use arrow;
pub use re_tuid;
}
#[macro_export]
macro_rules! static_assert_struct_has_fields {
($strct:ty, $($field:ident: $field_typ:ty),+ $(,)?) => {
const _: fn(&$strct) = |s: &$strct| {
$(let _: &$field_typ = &s.$field;)+
};
}
}
#[doc(hidden)] #[allow(clippy::unnecessary_wraps)] pub fn try_serialize_field<C: crate::Component>(
descriptor: ComponentDescriptor,
instances: impl IntoIterator<Item = impl Into<C>>,
) -> Option<SerializedComponentBatch> {
let res = C::to_arrow(
instances
.into_iter()
.map(|v| std::borrow::Cow::Owned(v.into())),
);
match res {
Ok(array) => Some(SerializedComponentBatch::new(array, descriptor)),
#[cfg(debug_assertions)]
Err(err) => {
panic!(
"failed to serialize data for {descriptor}: {}",
re_error::format_ref(&err)
)
}
#[cfg(not(debug_assertions))]
Err(err) => {
re_log::error!(
%descriptor,
"failed to serialize data: {}",
re_error::format_ref(&err)
);
None
}
}
}
#[doc(hidden)] pub fn indicator_column<A: Archetype>(
num_rows: usize,
) -> SerializationResult<SerializedComponentColumn> {
let SerializedComponentColumn {
list_array,
descriptor,
} = A::indicator().into();
let (field, _offsets, values, _nulls) = list_array.into_parts();
let offsets = arrow::buffer::OffsetBuffer::new_zeroed(num_rows);
let nulls = None;
arrow::array::ListArray::try_new(field, offsets, values, nulls)
.map(|list_array| SerializedComponentColumn {
list_array,
descriptor,
})
.map_err(Into::into)
}