#![doc = document_features::document_features!()]
pub mod arrow_msg;
mod data_cell;
mod data_row;
mod data_table;
pub mod example_components;
pub mod hash;
mod index;
mod num_instances;
pub mod path;
mod time;
pub mod time_point;
mod time_range;
mod time_real;
#[cfg(not(target_arch = "wasm32"))]
mod data_table_batcher;
use std::sync::Arc;
pub use self::arrow_msg::ArrowMsg;
pub use self::data_cell::{DataCell, DataCellError, DataCellInner, DataCellResult};
pub use self::data_row::{
DataCellRow, DataCellVec, DataReadError, DataReadResult, DataRow, DataRowError, DataRowResult,
RowId,
};
pub use self::data_table::{
DataCellColumn, DataCellOptVec, DataTable, DataTableError, DataTableResult, EntityPathVec,
ErasedTimeVec, NumInstancesVec, RowIdVec, TableId, TimePointVec, METADATA_KIND,
METADATA_KIND_CONTROL, METADATA_KIND_DATA,
};
pub use self::index::*;
pub use self::num_instances::NumInstances;
pub use self::path::*;
pub use self::time::{Duration, Time, TimeZone};
pub use self::time_point::{TimeInt, TimePoint, TimeType, Timeline, TimelineName};
pub use self::time_range::{TimeRange, TimeRangeF};
pub use self::time_real::TimeReal;
#[cfg(not(target_arch = "wasm32"))]
pub use self::data_table_batcher::{
DataTableBatcher, DataTableBatcherConfig, DataTableBatcherError,
};
mod load_file;
#[cfg(not(target_arch = "wasm32"))]
pub use self::load_file::data_cells_from_file_path;
pub use self::load_file::{data_cells_from_file_contents, FromFileError};
pub mod external {
pub use arrow2;
pub use re_tuid;
pub use re_types_core;
}
#[macro_export]
macro_rules! impl_into_enum {
($from_ty: ty, $enum_name: ident, $to_enum_variant: ident) => {
impl From<$from_ty> for $enum_name {
#[inline]
fn from(value: $from_ty) -> Self {
Self::$to_enum_variant(value)
}
}
};
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum StoreKind {
Recording,
Blueprint,
}
impl std::fmt::Display for StoreKind {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Recording => "Recording".fmt(f),
Self::Blueprint => "Blueprint".fmt(f),
}
}
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct StoreId {
pub kind: StoreKind,
pub id: Arc<String>,
}
impl StoreId {
#[inline]
pub fn random(kind: StoreKind) -> Self {
Self {
kind,
id: Arc::new(uuid::Uuid::new_v4().to_string()),
}
}
#[inline]
pub fn from_uuid(kind: StoreKind, uuid: uuid::Uuid) -> Self {
Self {
kind,
id: Arc::new(uuid.to_string()),
}
}
#[inline]
pub fn from_string(kind: StoreKind, str: String) -> Self {
Self {
kind,
id: Arc::new(str),
}
}
#[inline]
pub fn as_str(&self) -> &str {
self.id.as_str()
}
}
impl std::fmt::Display for StoreId {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.id.fmt(f)
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ApplicationId(pub String);
impl From<&str> for ApplicationId {
fn from(s: &str) -> Self {
Self(s.into())
}
}
impl From<String> for ApplicationId {
fn from(s: String) -> Self {
Self(s)
}
}
impl ApplicationId {
pub fn unknown() -> Self {
Self("unknown_app_id".to_owned())
}
pub fn as_str(&self) -> &str {
self.0.as_str()
}
}
impl std::fmt::Display for ApplicationId {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
#[must_use]
#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[allow(clippy::large_enum_variant)]
pub enum LogMsg {
SetStoreInfo(SetStoreInfo),
ArrowMsg(StoreId, ArrowMsg),
}
impl LogMsg {
pub fn store_id(&self) -> &StoreId {
match self {
Self::SetStoreInfo(msg) => &msg.info.store_id,
Self::ArrowMsg(store_id, _) => store_id,
}
}
}
impl_into_enum!(SetStoreInfo, LogMsg, SetStoreInfo);
#[must_use]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct SetStoreInfo {
pub row_id: RowId,
pub info: StoreInfo,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct StoreInfo {
pub application_id: ApplicationId,
pub store_id: StoreId,
pub is_official_example: bool,
pub started: Time,
pub store_source: StoreSource,
pub store_kind: StoreKind,
}
impl StoreInfo {
pub fn is_app_default_blueprint(&self) -> bool {
self.application_id.as_str() == self.store_id.as_str()
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct PythonVersion {
pub major: u8,
pub minor: u8,
pub patch: u8,
pub suffix: String,
}
impl std::fmt::Display for PythonVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self {
major,
minor,
patch,
suffix,
} = self;
write!(f, "{major}.{minor}.{patch}{suffix}")
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FileSource {
Cli,
DragAndDrop,
FileDialog,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum StoreSource {
Unknown,
CSdk,
PythonSdk(PythonVersion),
RustSdk {
rustc_version: String,
llvm_version: String,
},
File {
file_source: FileSource,
},
Viewer,
Other(String),
}
impl std::fmt::Display for StoreSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Unknown => "Unknown".fmt(f),
Self::CSdk => "C SDK".fmt(f),
Self::PythonSdk(version) => write!(f, "Python {version} SDK"),
Self::RustSdk { rustc_version, .. } => write!(f, "Rust SDK (rustc {rustc_version})"),
Self::File { file_source, .. } => match file_source {
FileSource::Cli => write!(f, "File via CLI"),
FileSource::DragAndDrop => write!(f, "File via drag-and-drop"),
FileSource::FileDialog => write!(f, "File via file dialog"),
},
Self::Viewer => write!(f, "Viewer-generated"),
Self::Other(string) => format!("{string:?}").fmt(f), }
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum PathOp {
ClearComponents(EntityPath),
ClearRecursive(EntityPath),
}
impl PathOp {
pub fn clear(recursive: bool, entity_path: EntityPath) -> Self {
if recursive {
PathOp::ClearRecursive(entity_path)
} else {
PathOp::ClearComponents(entity_path)
}
}
pub fn entity_path(&self) -> &EntityPath {
match &self {
PathOp::ClearComponents(path) | PathOp::ClearRecursive(path) => path,
}
}
}
#[inline]
pub fn build_log_time(log_time: Time) -> (Timeline, TimeInt) {
(Timeline::log_time(), log_time.into())
}
#[inline]
pub fn build_frame_nr(frame_nr: TimeInt) -> (Timeline, TimeInt) {
(Timeline::new("frame_nr", TimeType::Sequence), frame_nr)
}