re_types/blueprint/archetypes/
tensor_slice_selection.rs#![allow(unused_imports)]
#![allow(unused_parens)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::cloned_instead_of_copied)]
#![allow(clippy::map_flatten)]
#![allow(clippy::needless_question_mark)]
#![allow(clippy::new_without_default)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
use ::re_types_core::external::arrow2;
use ::re_types_core::ComponentName;
use ::re_types_core::SerializationResult;
use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)]
pub struct TensorSliceSelection {
pub width: Option<crate::components::TensorWidthDimension>,
pub height: Option<crate::components::TensorHeightDimension>,
pub indices: Option<Vec<crate::components::TensorDimensionIndexSelection>>,
pub slider: Option<Vec<crate::blueprint::components::TensorDimensionIndexSlider>>,
}
impl ::re_types_core::SizeBytes for TensorSliceSelection {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.width.heap_size_bytes()
+ self.height.heap_size_bytes()
+ self.indices.heap_size_bytes()
+ self.slider.heap_size_bytes()
}
#[inline]
fn is_pod() -> bool {
<Option<crate::components::TensorWidthDimension>>::is_pod()
&& <Option<crate::components::TensorHeightDimension>>::is_pod()
&& <Option<Vec<crate::components::TensorDimensionIndexSelection>>>::is_pod()
&& <Option<Vec<crate::blueprint::components::TensorDimensionIndexSlider>>>::is_pod()
}
}
static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> =
once_cell::sync::Lazy::new(|| []);
static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> =
once_cell::sync::Lazy::new(|| {
["rerun.blueprint.components.TensorSliceSelectionIndicator".into()]
});
static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 4usize]> =
once_cell::sync::Lazy::new(|| {
[
"rerun.components.TensorWidthDimension".into(),
"rerun.components.TensorHeightDimension".into(),
"rerun.components.TensorDimensionIndexSelection".into(),
"rerun.blueprint.components.TensorDimensionIndexSlider".into(),
]
});
static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 5usize]> =
once_cell::sync::Lazy::new(|| {
[
"rerun.blueprint.components.TensorSliceSelectionIndicator".into(),
"rerun.components.TensorWidthDimension".into(),
"rerun.components.TensorHeightDimension".into(),
"rerun.components.TensorDimensionIndexSelection".into(),
"rerun.blueprint.components.TensorDimensionIndexSlider".into(),
]
});
impl TensorSliceSelection {
pub const NUM_COMPONENTS: usize = 5usize;
}
pub type TensorSliceSelectionIndicator =
::re_types_core::GenericIndicatorComponent<TensorSliceSelection>;
impl ::re_types_core::Archetype for TensorSliceSelection {
type Indicator = TensorSliceSelectionIndicator;
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.blueprint.archetypes.TensorSliceSelection".into()
}
#[inline]
fn display_name() -> &'static str {
"Tensor slice selection"
}
#[inline]
fn indicator() -> MaybeOwnedComponentBatch<'static> {
static INDICATOR: TensorSliceSelectionIndicator = TensorSliceSelectionIndicator::DEFAULT;
MaybeOwnedComponentBatch::Ref(&INDICATOR)
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [ComponentName]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentName]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [ComponentName]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [ComponentName]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn arrow2::array::Array>)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();
use ::re_types_core::{Loggable as _, ResultExt as _};
let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data
.into_iter()
.map(|(name, array)| (name.full_name(), array))
.collect();
let width = if let Some(array) = arrays_by_name.get("rerun.components.TensorWidthDimension")
{
<crate::components::TensorWidthDimension>::from_arrow_opt(&**array)
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#width")?
.into_iter()
.next()
.flatten()
} else {
None
};
let height =
if let Some(array) = arrays_by_name.get("rerun.components.TensorHeightDimension") {
<crate::components::TensorHeightDimension>::from_arrow_opt(&**array)
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#height")?
.into_iter()
.next()
.flatten()
} else {
None
};
let indices = if let Some(array) =
arrays_by_name.get("rerun.components.TensorDimensionIndexSelection")
{
Some({
<crate::components::TensorDimensionIndexSelection>::from_arrow_opt(&**array)
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#indices")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#indices")?
})
} else {
None
};
let slider = if let Some(array) =
arrays_by_name.get("rerun.blueprint.components.TensorDimensionIndexSlider")
{
Some({
<crate::blueprint::components::TensorDimensionIndexSlider>::from_arrow_opt(&**array)
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#slider")?
.into_iter()
.map(|v| v.ok_or_else(DeserializationError::missing_data))
.collect::<DeserializationResult<Vec<_>>>()
.with_context("rerun.blueprint.archetypes.TensorSliceSelection#slider")?
})
} else {
None
};
Ok(Self {
width,
height,
indices,
slider,
})
}
}
impl ::re_types_core::AsComponents for TensorSliceSelection {
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>> {
re_tracing::profile_function!();
use ::re_types_core::Archetype as _;
[
Some(Self::indicator()),
self.width
.as_ref()
.map(|comp| (comp as &dyn ComponentBatch).into()),
self.height
.as_ref()
.map(|comp| (comp as &dyn ComponentBatch).into()),
self.indices
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()),
self.slider
.as_ref()
.map(|comp_batch| (comp_batch as &dyn ComponentBatch).into()),
]
.into_iter()
.flatten()
.collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for TensorSliceSelection {}
impl TensorSliceSelection {
#[inline]
pub fn new() -> Self {
Self {
width: None,
height: None,
indices: None,
slider: None,
}
}
#[inline]
pub fn with_width(mut self, width: impl Into<crate::components::TensorWidthDimension>) -> Self {
self.width = Some(width.into());
self
}
#[inline]
pub fn with_height(
mut self,
height: impl Into<crate::components::TensorHeightDimension>,
) -> Self {
self.height = Some(height.into());
self
}
#[inline]
pub fn with_indices(
mut self,
indices: impl IntoIterator<Item = impl Into<crate::components::TensorDimensionIndexSelection>>,
) -> Self {
self.indices = Some(indices.into_iter().map(Into::into).collect());
self
}
#[inline]
pub fn with_slider(
mut self,
slider: impl IntoIterator<
Item = impl Into<crate::blueprint::components::TensorDimensionIndexSlider>,
>,
) -> Self {
self.slider = Some(slider.into_iter().map(Into::into).collect());
self
}
}